Included file scope namespaces for all files
This commit is contained in:
parent
610707a5b7
commit
5e7de1617e
@ -1,30 +1,29 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC
|
namespace Microsoft.eShopOnContainers.WebMVC;
|
||||||
|
|
||||||
|
public class AppSettings
|
||||||
{
|
{
|
||||||
public class AppSettings
|
|
||||||
{
|
|
||||||
//public Connectionstrings ConnectionStrings { get; set; }
|
//public Connectionstrings ConnectionStrings { get; set; }
|
||||||
public string PurchaseUrl { get; set; }
|
public string PurchaseUrl { get; set; }
|
||||||
public string SignalrHubUrl { get; set; }
|
public string SignalrHubUrl { get; set; }
|
||||||
public bool ActivateCampaignDetailFunction { get; set; }
|
public bool ActivateCampaignDetailFunction { get; set; }
|
||||||
public Logging Logging { get; set; }
|
public Logging Logging { get; set; }
|
||||||
public bool UseCustomizationData { get; set; }
|
public bool UseCustomizationData { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Connectionstrings
|
public class Connectionstrings
|
||||||
{
|
{
|
||||||
public string DefaultConnection { get; set; }
|
public string DefaultConnection { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Logging
|
public class Logging
|
||||||
{
|
{
|
||||||
public bool IncludeScopes { get; set; }
|
public bool IncludeScopes { get; set; }
|
||||||
public Loglevel LogLevel { get; set; }
|
public Loglevel LogLevel { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Loglevel
|
public class Loglevel
|
||||||
{
|
{
|
||||||
public string Default { get; set; }
|
public string Default { get; set; }
|
||||||
public string System { get; set; }
|
public string System { get; set; }
|
||||||
public string Microsoft { get; set; }
|
public string Microsoft { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Authentication;
|
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using System;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
||||||
|
public class AccountController : Controller
|
||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
|
||||||
public class AccountController : Controller
|
|
||||||
{
|
|
||||||
private readonly ILogger<AccountController> _logger;
|
private readonly ILogger<AccountController> _logger;
|
||||||
|
|
||||||
public AccountController(ILogger<AccountController> logger)
|
public AccountController(ILogger<AccountController> logger)
|
||||||
@ -49,5 +39,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
|||||||
return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme,
|
return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme,
|
||||||
new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl });
|
new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl });
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
||||||
|
public class CartController : Controller
|
||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
|
||||||
public class CartController : Controller
|
|
||||||
{
|
|
||||||
private readonly IBasketService _basketSvc;
|
private readonly IBasketService _basketSvc;
|
||||||
private readonly ICatalogService _catalogSvc;
|
private readonly ICatalogService _catalogSvc;
|
||||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||||
@ -85,5 +76,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
|||||||
{
|
{
|
||||||
ViewBag.BasketInoperativeMsg = $"Basket Service is inoperative {ex.GetType().Name} - {ex.Message}";
|
ViewBag.BasketInoperativeMsg = $"Basket Service is inoperative {ex.GetType().Name} - {ex.Message}";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
public class CatalogController : Controller
|
||||||
{
|
{
|
||||||
public class CatalogController : Controller
|
|
||||||
{
|
|
||||||
private ICatalogService _catalogSvc;
|
private ICatalogService _catalogSvc;
|
||||||
|
|
||||||
public CatalogController(ICatalogService catalogSvc) =>
|
public CatalogController(ICatalogService catalogSvc) =>
|
||||||
@ -41,5 +34,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
|||||||
|
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,6 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
namespace WebMVC.Controllers;
|
||||||
|
|
||||||
namespace WebMVC.Controllers
|
public class ErrorController : Controller
|
||||||
{
|
{
|
||||||
public class ErrorController : Controller
|
|
||||||
{
|
|
||||||
public IActionResult Error() => View();
|
public IActionResult Error() => View();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,10 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
namespace Microsoft.eShopOnContainers.WebMVC.Controllers;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
||||||
|
public class OrderController : Controller
|
||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
|
||||||
public class OrderController : Controller
|
|
||||||
{
|
|
||||||
private IOrderingService _orderSvc;
|
private IOrderingService _orderSvc;
|
||||||
private IBasketService _basketSvc;
|
private IBasketService _basketSvc;
|
||||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||||
@ -78,5 +72,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
|||||||
var vm = await _orderSvc.GetMyOrders(user);
|
var vm = await _orderSvc.GetMyOrders(user);
|
||||||
return View(vm);
|
return View(vm);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,16 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
namespace WebMVC.Controllers;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WebMVC.Services.ModelDTOs;
|
|
||||||
|
|
||||||
namespace WebMVC.Controllers
|
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
||||||
|
public class OrderManagementController : Controller
|
||||||
{
|
{
|
||||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
|
||||||
public class OrderManagementController : Controller
|
|
||||||
{
|
|
||||||
private IOrderingService _orderSvc;
|
private IOrderingService _orderSvc;
|
||||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||||
public OrderManagementController(IOrderingService orderSvc, IIdentityParser<ApplicationUser> appUserParser)
|
public OrderManagementController(IOrderingService orderSvc, IIdentityParser<ApplicationUser> appUserParser)
|
||||||
@ -37,5 +29,4 @@ namespace WebMVC.Controllers
|
|||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
using Microsoft.AspNetCore.Authorization;
|
namespace WebMVC.Controllers;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace WebMVC.Controllers
|
class TestPayload
|
||||||
{
|
{
|
||||||
class TestPayload
|
|
||||||
{
|
|
||||||
public int CatalogItemId { get; set; }
|
public int CatalogItemId { get; set; }
|
||||||
|
|
||||||
public string BasketId { get; set; }
|
public string BasketId { get; set; }
|
||||||
|
|
||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public class TestController : Controller
|
public class TestController : Controller
|
||||||
{
|
{
|
||||||
private readonly IHttpClientFactory _client;
|
private readonly IHttpClientFactory _client;
|
||||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||||
|
|
||||||
@ -57,5 +49,4 @@ namespace WebMVC.Controllers
|
|||||||
return Ok(new { response.StatusCode, response.ReasonPhrase });
|
return Ok(new { response.StatusCode, response.ReasonPhrase });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.Extensions;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Extensions
|
public static class HttpClientExtensions
|
||||||
{
|
{
|
||||||
public static class HttpClientExtensions
|
|
||||||
{
|
|
||||||
public static void SetBasicAuthentication(this HttpClient client, string userName, string password) =>
|
public static void SetBasicAuthentication(this HttpClient client, string userName, string password) =>
|
||||||
client.DefaultRequestHeaders.Authorization = new BasicAuthenticationHeaderValue(userName, password);
|
client.DefaultRequestHeaders.Authorization = new BasicAuthenticationHeaderValue(userName, password);
|
||||||
|
|
||||||
@ -16,10 +10,10 @@ namespace Microsoft.eShopOnContainers.WebMVC.Extensions
|
|||||||
|
|
||||||
public static void SetBearerToken(this HttpClient client, string token) =>
|
public static void SetBearerToken(this HttpClient client, string token) =>
|
||||||
client.SetToken(JwtConstants.TokenType, token);
|
client.SetToken(JwtConstants.TokenType, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BasicAuthenticationHeaderValue : AuthenticationHeaderValue
|
public class BasicAuthenticationHeaderValue : AuthenticationHeaderValue
|
||||||
{
|
{
|
||||||
public BasicAuthenticationHeaderValue(string userName, string password)
|
public BasicAuthenticationHeaderValue(string userName, string password)
|
||||||
: base("Basic", EncodeCredential(userName, password))
|
: base("Basic", EncodeCredential(userName, password))
|
||||||
{ }
|
{ }
|
||||||
@ -31,5 +25,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Extensions
|
|||||||
|
|
||||||
return Convert.ToBase64String(encoding.GetBytes(credential));
|
return Convert.ToBase64String(encoding.GetBytes(credential));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
public static class SessionExtensions
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
|
|
||||||
public static class SessionExtensions
|
|
||||||
{
|
{
|
||||||
public static void SetObject(this ISession session, string key, object value) =>
|
public static void SetObject(this ISession session, string key, object value) =>
|
||||||
session.SetString(key,JsonSerializer.Serialize(value));
|
session.SetString(key,JsonSerializer.Serialize(value));
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace WebMVC.Infrastructure
|
namespace WebMVC.Infrastructure;
|
||||||
|
|
||||||
|
public static class API
|
||||||
{
|
{
|
||||||
public static class API
|
|
||||||
{
|
|
||||||
|
|
||||||
public static class Purchase
|
public static class Purchase
|
||||||
{
|
{
|
||||||
@ -82,5 +82,4 @@
|
|||||||
return $"{baseUri}catalogTypes";
|
return $"{baseUri}catalogTypes";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,16 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Authentication;
|
namespace WebMVC.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Net.Http.Headers;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace WebMVC.Infrastructure
|
public class HttpClientAuthorizationDelegatingHandler
|
||||||
{
|
|
||||||
public class HttpClientAuthorizationDelegatingHandler
|
|
||||||
: DelegatingHandler
|
: DelegatingHandler
|
||||||
{
|
{
|
||||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
|
||||||
public HttpClientAuthorizationDelegatingHandler(IHttpContextAccessor httpContextAccessor)
|
public HttpClientAuthorizationDelegatingHandler(IHttpContextAccessor httpContextAccessor)
|
||||||
@ -45,5 +37,4 @@ namespace WebMVC.Infrastructure
|
|||||||
return await _httpContextAccessor.HttpContext
|
return await _httpContextAccessor.HttpContext
|
||||||
.GetTokenAsync(ACCESS_TOKEN);
|
.GetTokenAsync(ACCESS_TOKEN);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,8 @@
|
|||||||
using System;
|
namespace WebMVC.Infrastructure;
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace WebMVC.Infrastructure
|
public class HttpClientRequestIdDelegatingHandler
|
||||||
{
|
|
||||||
public class HttpClientRequestIdDelegatingHandler
|
|
||||||
: DelegatingHandler
|
: DelegatingHandler
|
||||||
{
|
{
|
||||||
|
|
||||||
public HttpClientRequestIdDelegatingHandler()
|
public HttpClientRequestIdDelegatingHandler()
|
||||||
{
|
{
|
||||||
@ -25,5 +20,4 @@ namespace WebMVC.Infrastructure
|
|||||||
|
|
||||||
return await base.SendAsync(request, cancellationToken);
|
return await base.SendAsync(request, cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,18 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Builder;
|
namespace WebMVC.Infrastructure;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using Serilog;
|
using Serilog;
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.IO.Compression;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace WebMVC.Infrastructure
|
public class WebContextSeed
|
||||||
{
|
{
|
||||||
public class WebContextSeed
|
|
||||||
{
|
|
||||||
public static void Seed(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
public static void Seed(IApplicationBuilder applicationBuilder, IWebHostEnvironment env)
|
||||||
{
|
{
|
||||||
var log = Serilog.Log.Logger;
|
var log = Serilog.Log.Logger;
|
||||||
@ -32,7 +22,7 @@ namespace WebMVC.Infrastructure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetPreconfiguredCSS(string contentRootPath, string webroot, Serilog.ILogger log)
|
static void GetPreconfiguredCSS(string contentRootPath, string webroot, ILogger log)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -52,7 +42,7 @@ namespace WebMVC.Infrastructure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void GetPreconfiguredImages(string contentRootPath, string webroot, Serilog.ILogger log)
|
static void GetPreconfiguredImages(string contentRootPath, string webroot, ILogger log)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -92,6 +82,4 @@ namespace WebMVC.Infrastructure
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,13 +1,4 @@
|
|||||||
using Microsoft.AspNetCore;
|
var configuration = GetConfiguration();
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Serilog;
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
var configuration = GetConfiguration();
|
|
||||||
|
|
||||||
Log.Logger = CreateSerilogLogger(configuration);
|
Log.Logger = CreateSerilogLogger(configuration);
|
||||||
|
|
||||||
|
@ -1,18 +1,9 @@
|
|||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WebMVC.Infrastructure;
|
|
||||||
using WebMVC.Services.ModelDTOs;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public class BasketService : IBasketService
|
||||||
{
|
{
|
||||||
public class BasketService : IBasketService
|
|
||||||
{
|
|
||||||
private readonly IOptions<AppSettings> _settings;
|
private readonly IOptions<AppSettings> _settings;
|
||||||
private readonly HttpClient _apiClient;
|
private readonly HttpClient _apiClient;
|
||||||
private readonly ILogger<BasketService> _logger;
|
private readonly ILogger<BasketService> _logger;
|
||||||
@ -126,5 +117,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
|
|
||||||
var response = await _apiClient.PostAsync(uri, basketContent);
|
var response = await _apiClient.PostAsync(uri, basketContent);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WebMVC.Infrastructure;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
public class CatalogService : ICatalogService
|
||||||
{
|
{
|
||||||
public class CatalogService : ICatalogService
|
|
||||||
{
|
|
||||||
private readonly IOptions<AppSettings> _settings;
|
private readonly IOptions<AppSettings> _settings;
|
||||||
private readonly HttpClient _httpClient;
|
private readonly HttpClient _httpClient;
|
||||||
private readonly ILogger<CatalogService> _logger;
|
private readonly ILogger<CatalogService> _logger;
|
||||||
@ -87,5 +77,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
|
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WebMVC.Services.ModelDTOs;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public interface IBasketService
|
||||||
{
|
{
|
||||||
public interface IBasketService
|
|
||||||
{
|
|
||||||
Task<Basket> GetBasket(ApplicationUser user);
|
Task<Basket> GetBasket(ApplicationUser user);
|
||||||
Task AddItemToBasket(ApplicationUser user, int productId);
|
Task AddItemToBasket(ApplicationUser user, int productId);
|
||||||
Task<Basket> UpdateBasket(Basket basket);
|
Task<Basket> UpdateBasket(Basket basket);
|
||||||
Task Checkout(BasketDTO basket);
|
Task Checkout(BasketDTO basket);
|
||||||
Task<Basket> SetQuantities(ApplicationUser user, Dictionary<string, int> quantities);
|
Task<Basket> SetQuantities(ApplicationUser user, Dictionary<string, int> quantities);
|
||||||
Task<Order> GetOrderDraft(string basketId);
|
Task<Order> GetOrderDraft(string basketId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
public interface ICatalogService
|
||||||
{
|
{
|
||||||
public interface ICatalogService
|
|
||||||
{
|
|
||||||
Task<Catalog> GetCatalogItems(int page, int take, int? brand, int? type);
|
Task<Catalog> GetCatalogItems(int page, int take, int? brand, int? type);
|
||||||
Task<IEnumerable<SelectListItem>> GetBrands();
|
Task<IEnumerable<SelectListItem>> GetBrands();
|
||||||
Task<IEnumerable<SelectListItem>> GetTypes();
|
Task<IEnumerable<SelectListItem>> GetTypes();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
using System.Security.Principal;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
public interface IIdentityParser<T>
|
||||||
{
|
{
|
||||||
public interface IIdentityParser<T>
|
|
||||||
{
|
|
||||||
T Parse(IPrincipal principal);
|
T Parse(IPrincipal principal);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,8 @@
|
|||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using System.Collections.Generic;
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WebMVC.Services.ModelDTOs;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
public interface IOrderingService
|
||||||
{
|
{
|
||||||
public interface IOrderingService
|
|
||||||
{
|
|
||||||
Task<List<Order>> GetMyOrders(ApplicationUser user);
|
Task<List<Order>> GetMyOrders(ApplicationUser user);
|
||||||
Task<Order> GetOrder(ApplicationUser user, string orderId);
|
Task<Order> GetOrder(ApplicationUser user, string orderId);
|
||||||
Task CancelOrder(string orderId);
|
Task CancelOrder(string orderId);
|
||||||
@ -14,5 +10,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
Order MapUserInfoIntoOrder(ApplicationUser user, Order order);
|
Order MapUserInfoIntoOrder(ApplicationUser user, Order order);
|
||||||
BasketDTO MapOrderToBasket(Order order);
|
BasketDTO MapOrderToBasket(Order order);
|
||||||
void OverrideUserInfoIntoOrder(Order original, Order destination);
|
void OverrideUserInfoIntoOrder(Order original, Order destination);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Security.Claims;
|
|
||||||
using System.Security.Principal;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
public class IdentityParser : IIdentityParser<ApplicationUser>
|
||||||
{
|
{
|
||||||
public class IdentityParser : IIdentityParser<ApplicationUser>
|
|
||||||
{
|
|
||||||
public ApplicationUser Parse(IPrincipal principal)
|
public ApplicationUser Parse(IPrincipal principal)
|
||||||
{
|
{
|
||||||
// Pattern matching 'is' expression
|
// Pattern matching 'is' expression
|
||||||
@ -36,7 +30,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
}
|
}
|
||||||
throw new ArgumentException(message: "The principal must be a ClaimsPrincipal", paramName: nameof(principal));
|
throw new ArgumentException(message: "The principal must be a ClaimsPrincipal", paramName: nameof(principal));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using System;
|
namespace WebMVC.Services.ModelDTOs;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace WebMVC.Services.ModelDTOs
|
public record BasketDTO
|
||||||
{
|
{
|
||||||
public record BasketDTO
|
|
||||||
{
|
|
||||||
[Required]
|
[Required]
|
||||||
public string City { get; init; }
|
public string City { get; init; }
|
||||||
[Required]
|
[Required]
|
||||||
@ -32,6 +29,4 @@ namespace WebMVC.Services.ModelDTOs
|
|||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public Guid RequestId { get; init; }
|
public Guid RequestId { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
namespace WebMVC.Services.ModelDTOs
|
namespace WebMVC.Services.ModelDTOs;
|
||||||
|
|
||||||
|
public record LocationDTO
|
||||||
{
|
{
|
||||||
public record LocationDTO
|
|
||||||
{
|
|
||||||
public double Longitude { get; init; }
|
public double Longitude { get; init; }
|
||||||
public double Latitude { get; init; }
|
public double Latitude { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,7 @@
|
|||||||
using System.ComponentModel.DataAnnotations;
|
namespace WebMVC.Services.ModelDTOs;
|
||||||
|
|
||||||
namespace WebMVC.Services.ModelDTOs
|
public record OrderDTO
|
||||||
{
|
{
|
||||||
public record OrderDTO
|
|
||||||
{
|
|
||||||
[Required]
|
[Required]
|
||||||
public string OrderNumber { get; init; }
|
public string OrderNumber { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
namespace WebMVC.Services.ModelDTOs
|
namespace WebMVC.Services.ModelDTOs;
|
||||||
|
|
||||||
|
public record OrderProcessAction
|
||||||
{
|
{
|
||||||
public record OrderProcessAction
|
|
||||||
{
|
|
||||||
public string Code { get; }
|
public string Code { get; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
|
|
||||||
@ -16,5 +16,4 @@
|
|||||||
Code = code;
|
Code = code;
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,9 @@
|
|||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||||
using Microsoft.Extensions.Options;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Net.Http;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using WebMVC.Infrastructure;
|
|
||||||
using WebMVC.Services.ModelDTOs;
|
|
||||||
using System.Text.Json;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public class OrderingService : IOrderingService
|
||||||
{
|
{
|
||||||
public class OrderingService : IOrderingService
|
|
||||||
{
|
|
||||||
private HttpClient _httpClient;
|
private HttpClient _httpClient;
|
||||||
private readonly string _remoteServiceBaseUrl;
|
private readonly string _remoteServiceBaseUrl;
|
||||||
private readonly IOptions<AppSettings> _settings;
|
private readonly IOptions<AppSettings> _settings;
|
||||||
@ -145,5 +137,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
|||||||
RequestId = order.RequestId
|
RequestId = order.RequestId
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,7 @@
|
|||||||
using Devspaces.Support;
|
namespace Microsoft.eShopOnContainers.WebMVC;
|
||||||
using HealthChecks.UI.Client;
|
|
||||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.DataProtection;
|
|
||||||
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
|
|
||||||
using Microsoft.AspNetCore.Hosting;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
|
||||||
using Microsoft.Extensions.Diagnostics.HealthChecks;
|
|
||||||
using Microsoft.Extensions.Hosting;
|
|
||||||
using Microsoft.IdentityModel.Logging;
|
|
||||||
using StackExchange.Redis;
|
|
||||||
using System;
|
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
|
||||||
using WebMVC.Infrastructure;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC
|
public class Startup
|
||||||
{
|
{
|
||||||
public class Startup
|
|
||||||
{
|
|
||||||
public Startup(IConfiguration configuration)
|
public Startup(IConfiguration configuration)
|
||||||
{
|
{
|
||||||
Configuration = configuration;
|
Configuration = configuration;
|
||||||
@ -98,10 +77,10 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ServiceCollectionExtensions
|
static class ServiceCollectionExtensions
|
||||||
{
|
{
|
||||||
|
|
||||||
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
@ -208,5 +187,4 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
public class Cart : ViewComponent
|
||||||
{
|
{
|
||||||
public class Cart : ViewComponent
|
|
||||||
{
|
|
||||||
private readonly IBasketService _cartSvc;
|
private readonly IBasketService _cartSvc;
|
||||||
|
|
||||||
public Cart(IBasketService cartSvc) => _cartSvc = cartSvc;
|
public Cart(IBasketService cartSvc) => _cartSvc = cartSvc;
|
||||||
@ -33,5 +27,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
|||||||
var basket = await _cartSvc.GetBasket(user);
|
var basket = await _cartSvc.GetBasket(user);
|
||||||
return basket.Items.Count;
|
return basket.Items.Count;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
|
||||||
using System;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
public class CartList : ViewComponent
|
||||||
{
|
{
|
||||||
public class CartList : ViewComponent
|
|
||||||
{
|
|
||||||
private readonly IBasketService _cartSvc;
|
private readonly IBasketService _cartSvc;
|
||||||
|
|
||||||
public CartList(IBasketService cartSvc) => _cartSvc = cartSvc;
|
public CartList(IBasketService cartSvc) => _cartSvc = cartSvc;
|
||||||
@ -29,5 +23,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Task<Basket> GetItemsAsync(ApplicationUser user) => _cartSvc.GetBasket(user);
|
private Task<Basket> GetItemsAsync(ApplicationUser user) => _cartSvc.GetBasket(user);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||||
|
public class CardExpirationAttribute : ValidationAttribute
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
|
||||||
public class CardExpirationAttribute : ValidationAttribute
|
|
||||||
{
|
|
||||||
public override bool IsValid(object value)
|
public override bool IsValid(object value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
@ -27,5 +24,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using System;
|
namespace WebMVC.ViewModels.Annotations;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace WebMVC.ViewModels.Annotations
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||||
|
public class LatitudeCoordinate : ValidationAttribute
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
|
||||||
public class LatitudeCoordinate : ValidationAttribute
|
|
||||||
{
|
|
||||||
protected override ValidationResult
|
protected override ValidationResult
|
||||||
IsValid(object value, ValidationContext validationContext)
|
IsValid(object value, ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
@ -18,5 +15,4 @@ namespace WebMVC.ViewModels.Annotations
|
|||||||
|
|
||||||
return ValidationResult.Success;
|
return ValidationResult.Success;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using System;
|
namespace WebMVC.ViewModels.Annotations;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace WebMVC.ViewModels.Annotations
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
||||||
|
public class LongitudeCoordinate : ValidationAttribute
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = true)]
|
|
||||||
public class LongitudeCoordinate : ValidationAttribute
|
|
||||||
{
|
|
||||||
protected override ValidationResult
|
protected override ValidationResult
|
||||||
IsValid(object value, ValidationContext validationContext)
|
IsValid(object value, ValidationContext validationContext)
|
||||||
{
|
{
|
||||||
@ -18,5 +15,4 @@ namespace WebMVC.ViewModels.Annotations
|
|||||||
|
|
||||||
return ValidationResult.Success;
|
return ValidationResult.Success;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Identity;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
// Add profile data for application users by adding properties to the ApplicationUser class
|
||||||
|
public class ApplicationUser : IdentityUser
|
||||||
{
|
{
|
||||||
// Add profile data for application users by adding properties to the ApplicationUser class
|
|
||||||
public class ApplicationUser : IdentityUser
|
|
||||||
{
|
|
||||||
public string CardNumber { get; set; }
|
public string CardNumber { get; set; }
|
||||||
public string SecurityNumber { get; set; }
|
public string SecurityNumber { get; set; }
|
||||||
public string Expiration { get; set; }
|
public string Expiration { get; set; }
|
||||||
@ -24,5 +21,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
[Required]
|
[Required]
|
||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
public record Basket
|
||||||
{
|
{
|
||||||
public record Basket
|
|
||||||
{
|
|
||||||
// Use property initializer syntax.
|
// Use property initializer syntax.
|
||||||
// While this is often more useful for read only
|
// While this is often more useful for read only
|
||||||
// auto implemented properties, it can simplify logic
|
// auto implemented properties, it can simplify logic
|
||||||
@ -17,5 +13,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|||||||
{
|
{
|
||||||
return Math.Round(Items.Sum(x => x.UnitPrice * x.Quantity), 2);
|
return Math.Round(Items.Sum(x => x.UnitPrice * x.Quantity), 2);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public record BasketItem
|
||||||
{
|
{
|
||||||
public record BasketItem
|
|
||||||
{
|
|
||||||
public string Id { get; init; }
|
public string Id { get; init; }
|
||||||
public int ProductId { get; init; }
|
public int ProductId { get; init; }
|
||||||
public string ProductName { get; init; }
|
public string ProductName { get; init; }
|
||||||
@ -9,5 +9,4 @@
|
|||||||
public decimal OldUnitPrice { get; init; }
|
public decimal OldUnitPrice { get; init; }
|
||||||
public int Quantity { get; init; }
|
public int Quantity { get; init; }
|
||||||
public string PictureUrl { get; init; }
|
public string PictureUrl { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
public record Campaign
|
||||||
{
|
{
|
||||||
public record Campaign
|
|
||||||
{
|
|
||||||
public int PageIndex { get; init; }
|
public int PageIndex { get; init; }
|
||||||
public int PageSize { get; init; }
|
public int PageSize { get; init; }
|
||||||
public int Count { get; init; }
|
public int Count { get; init; }
|
||||||
public List<CampaignItem> Data { get; init; }
|
public List<CampaignItem> Data { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,9 +1,7 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
public record CampaignItem
|
||||||
{
|
{
|
||||||
public record CampaignItem
|
|
||||||
{
|
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
|
|
||||||
public string Name { get; init; }
|
public string Name { get; init; }
|
||||||
@ -16,5 +14,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|||||||
|
|
||||||
public string PictureUri { get; init; }
|
public string PictureUri { get; init; }
|
||||||
public string DetailsUri { get; init; }
|
public string DetailsUri { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,8 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CartViewModels;
|
||||||
|
|
||||||
|
public class CartComponentViewModel
|
||||||
{
|
{
|
||||||
public class CartComponentViewModel
|
|
||||||
{
|
|
||||||
public int ItemsCount { get; set; }
|
public int ItemsCount { get; set; }
|
||||||
public string Disabled => (ItemsCount == 0) ? "is-disabled" : "";
|
public string Disabled => (ItemsCount == 0) ? "is-disabled" : "";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
using System.Collections.Generic;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
public record Catalog
|
||||||
{
|
{
|
||||||
public record Catalog
|
|
||||||
{
|
|
||||||
public int PageIndex { get; init; }
|
public int PageIndex { get; init; }
|
||||||
public int PageSize { get; init; }
|
public int PageSize { get; init; }
|
||||||
public int Count { get; init; }
|
public int Count { get; init; }
|
||||||
public List<CatalogItem> Data { get; init; }
|
public List<CatalogItem> Data { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public record CatalogItem
|
||||||
{
|
{
|
||||||
public record CatalogItem
|
|
||||||
{
|
|
||||||
public int Id { get; init; }
|
public int Id { get; init; }
|
||||||
public string Name { get; init; }
|
public string Name { get; init; }
|
||||||
public string Description { get; init; }
|
public string Description { get; init; }
|
||||||
@ -11,5 +11,4 @@
|
|||||||
public string CatalogBrand { get; init; }
|
public string CatalogBrand { get; init; }
|
||||||
public int CatalogTypeId { get; init; }
|
public int CatalogTypeId { get; init; }
|
||||||
public string CatalogType { get; init; }
|
public string CatalogType { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,16 +1,11 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels
|
public class IndexViewModel
|
||||||
{
|
{
|
||||||
public class IndexViewModel
|
|
||||||
{
|
|
||||||
public IEnumerable<CatalogItem> CatalogItems { get; set; }
|
public IEnumerable<CatalogItem> CatalogItems { get; set; }
|
||||||
public IEnumerable<SelectListItem> Brands { get; set; }
|
public IEnumerable<SelectListItem> Brands { get; set; }
|
||||||
public IEnumerable<SelectListItem> Types { get; set; }
|
public IEnumerable<SelectListItem> Types { get; set; }
|
||||||
public int? BrandFilterApplied { get; set; }
|
public int? BrandFilterApplied { get; set; }
|
||||||
public int? TypesFilterApplied { get; set; }
|
public int? TypesFilterApplied { get; set; }
|
||||||
public PaginationInfo PaginationInfo { get; set; }
|
public PaginationInfo PaginationInfo { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,7 @@
|
|||||||
using System;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text.Json;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
public class NumberToStringConverter : JsonConverter<string>
|
||||||
{
|
{
|
||||||
public class NumberToStringConverter : JsonConverter<string>
|
|
||||||
{
|
|
||||||
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
public override string Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
{
|
{
|
||||||
if (reader.TokenType == JsonTokenType.Number)
|
if (reader.TokenType == JsonTokenType.Number)
|
||||||
@ -30,5 +23,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|||||||
{
|
{
|
||||||
writer.WriteStringValue(value);
|
writer.WriteStringValue(value);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public record Header
|
||||||
{
|
{
|
||||||
public record Header
|
|
||||||
{
|
|
||||||
public string Controller { get; init; }
|
public string Controller { get; init; }
|
||||||
public string Text { get; init; }
|
public string Text { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,16 +1,7 @@
|
|||||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.ComponentModel.DataAnnotations;
|
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using WebMVC.Services.ModelDTOs;
|
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
public class Order
|
||||||
{
|
{
|
||||||
public class Order
|
|
||||||
{
|
|
||||||
[JsonConverter(typeof(NumberToStringConverter))]
|
[JsonConverter(typeof(NumberToStringConverter))]
|
||||||
public string OrderNumber { get; set; }
|
public string OrderNumber { get; set; }
|
||||||
|
|
||||||
@ -92,10 +83,9 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum CardType
|
public enum CardType
|
||||||
{
|
{
|
||||||
AMEX = 1
|
AMEX = 1
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||||
|
|
||||||
|
public record OrderItem
|
||||||
{
|
{
|
||||||
public record OrderItem
|
|
||||||
{
|
|
||||||
public int ProductId { get; init; }
|
public int ProductId { get; init; }
|
||||||
|
|
||||||
public string ProductName { get; init; }
|
public string ProductName { get; init; }
|
||||||
@ -13,5 +13,4 @@
|
|||||||
public int Units { get; init; }
|
public int Units { get; init; }
|
||||||
|
|
||||||
public string PictureUrl { get; init; }
|
public string PictureUrl { get; init; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination
|
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
|
||||||
|
|
||||||
|
public class PaginationInfo
|
||||||
{
|
{
|
||||||
public class PaginationInfo
|
|
||||||
{
|
|
||||||
public int TotalItems { get; set; }
|
public int TotalItems { get; set; }
|
||||||
public int ItemsPerPage { get; set; }
|
public int ItemsPerPage { get; set; }
|
||||||
public int ActualPage { get; set; }
|
public int ActualPage { get; set; }
|
||||||
public int TotalPages { get; set; }
|
public int TotalPages { get; set; }
|
||||||
public string Previous { get; set; }
|
public string Previous { get; set; }
|
||||||
public string Next { get; set; }
|
public string Next { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user