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 string PurchaseUrl { get; set; }
|
||||
public string SignalrHubUrl { get; set; }
|
||||
public bool ActivateCampaignDetailFunction { get; set; }
|
||||
public Logging Logging { get; set; }
|
||||
public bool UseCustomizationData { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Connectionstrings
|
||||
{
|
||||
public class Connectionstrings
|
||||
{
|
||||
public string DefaultConnection { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Logging
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
public bool IncludeScopes { get; set; }
|
||||
public Loglevel LogLevel { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
public class Loglevel
|
||||
{
|
||||
public class Loglevel
|
||||
{
|
||||
public string Default { get; set; }
|
||||
public string System { get; set; }
|
||||
public string Microsoft { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
public AccountController(ILogger<AccountController> logger)
|
||||
@ -49,5 +39,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
return new SignOutResult(OpenIdConnectDefaults.AuthenticationScheme,
|
||||
new AspNetCore.Authentication.AuthenticationProperties { RedirectUri = homeUrl });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
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;
|
||||
|
||||
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 ICatalogService _catalogSvc;
|
||||
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}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
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;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
public class CatalogController : Controller
|
||||
{
|
||||
public class CatalogController : Controller
|
||||
{
|
||||
private ICatalogService _catalogSvc;
|
||||
|
||||
public CatalogController(ICatalogService catalogSvc) =>
|
||||
@ -41,5 +34,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,10 @@
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
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;
|
||||
|
||||
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 IBasketService _basketSvc;
|
||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||
@ -78,5 +72,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Controllers
|
||||
var vm = await _orderSvc.GetMyOrders(user);
|
||||
return View(vm);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
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;
|
||||
|
||||
namespace WebMVC.Controllers
|
||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
||||
public class OrderManagementController : Controller
|
||||
{
|
||||
[Authorize(AuthenticationSchemes = OpenIdConnectDefaults.AuthenticationScheme)]
|
||||
public class OrderManagementController : Controller
|
||||
{
|
||||
private IOrderingService _orderSvc;
|
||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||
public OrderManagementController(IOrderingService orderSvc, IIdentityParser<ApplicationUser> appUserParser)
|
||||
@ -37,5 +29,4 @@ namespace WebMVC.Controllers
|
||||
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,17 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
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;
|
||||
|
||||
namespace WebMVC.Controllers
|
||||
class TestPayload
|
||||
{
|
||||
class TestPayload
|
||||
{
|
||||
public int CatalogItemId { get; set; }
|
||||
|
||||
public string BasketId { get; set; }
|
||||
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
public class TestController : Controller
|
||||
{
|
||||
[Authorize]
|
||||
public class TestController : Controller
|
||||
{
|
||||
private readonly IHttpClientFactory _client;
|
||||
private readonly IIdentityParser<ApplicationUser> _appUserParser;
|
||||
|
||||
@ -57,5 +49,4 @@ namespace WebMVC.Controllers
|
||||
return Ok(new { response.StatusCode, response.ReasonPhrase });
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,7 @@
|
||||
using System;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Extensions;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Extensions
|
||||
public static class HttpClientExtensions
|
||||
{
|
||||
public static class HttpClientExtensions
|
||||
{
|
||||
public static void SetBasicAuthentication(this HttpClient client, string userName, string 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) =>
|
||||
client.SetToken(JwtConstants.TokenType, token);
|
||||
}
|
||||
}
|
||||
|
||||
public class BasicAuthenticationHeaderValue : AuthenticationHeaderValue
|
||||
{
|
||||
public class BasicAuthenticationHeaderValue : AuthenticationHeaderValue
|
||||
{
|
||||
public BasicAuthenticationHeaderValue(string userName, string password)
|
||||
: base("Basic", EncodeCredential(userName, password))
|
||||
{ }
|
||||
@ -31,5 +25,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Extensions
|
||||
|
||||
return Convert.ToBase64String(encoding.GetBytes(credential));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,4 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Text.Json;
|
||||
|
||||
|
||||
public static class SessionExtensions
|
||||
public static class SessionExtensions
|
||||
{
|
||||
public static void SetObject(this ISession session, string key, object 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
|
||||
{
|
||||
@ -82,5 +82,4 @@
|
||||
return $"{baseUri}catalogTypes";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,8 @@
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
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;
|
||||
|
||||
namespace WebMVC.Infrastructure
|
||||
{
|
||||
public class HttpClientAuthorizationDelegatingHandler
|
||||
public class HttpClientAuthorizationDelegatingHandler
|
||||
: DelegatingHandler
|
||||
{
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
|
||||
public HttpClientAuthorizationDelegatingHandler(IHttpContextAccessor httpContextAccessor)
|
||||
@ -45,5 +37,4 @@ namespace WebMVC.Infrastructure
|
||||
return await _httpContextAccessor.HttpContext
|
||||
.GetTokenAsync(ACCESS_TOKEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,8 @@
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
namespace WebMVC.Infrastructure;
|
||||
|
||||
namespace WebMVC.Infrastructure
|
||||
{
|
||||
public class HttpClientRequestIdDelegatingHandler
|
||||
public class HttpClientRequestIdDelegatingHandler
|
||||
: DelegatingHandler
|
||||
{
|
||||
{
|
||||
|
||||
public HttpClientRequestIdDelegatingHandler()
|
||||
{
|
||||
@ -25,5 +20,4 @@ namespace WebMVC.Infrastructure
|
||||
|
||||
return await base.SendAsync(request, cancellationToken);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,18 +1,8 @@
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.eShopOnContainers.WebMVC;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Options;
|
||||
namespace WebMVC.Infrastructure;
|
||||
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)
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -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
|
||||
{
|
||||
@ -92,6 +82,4 @@ namespace WebMVC.Infrastructure
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,13 +1,4 @@
|
||||
using Microsoft.AspNetCore;
|
||||
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();
|
||||
var configuration = GetConfiguration();
|
||||
|
||||
Log.Logger = CreateSerilogLogger(configuration);
|
||||
|
||||
|
@ -1,18 +1,9 @@
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
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;
|
||||
|
||||
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 HttpClient _apiClient;
|
||||
private readonly ILogger<BasketService> _logger;
|
||||
@ -126,5 +117,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
|
||||
var response = await _apiClient.PostAsync(uri, basketContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
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;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
public class CatalogService : ICatalogService
|
||||
{
|
||||
public class CatalogService : ICatalogService
|
||||
{
|
||||
private readonly IOptions<AppSettings> _settings;
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly ILogger<CatalogService> _logger;
|
||||
@ -87,5 +77,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,13 @@
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using WebMVC.Services.ModelDTOs;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
|
||||
public interface IBasketService
|
||||
{
|
||||
public interface IBasketService
|
||||
{
|
||||
Task<Basket> GetBasket(ApplicationUser user);
|
||||
Task AddItemToBasket(ApplicationUser user, int productId);
|
||||
Task<Basket> UpdateBasket(Basket basket);
|
||||
Task Checkout(BasketDTO basket);
|
||||
Task<Basket> SetQuantities(ApplicationUser user, Dictionary<string, int> quantities);
|
||||
Task<Order> GetOrderDraft(string basketId);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,8 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
public interface ICatalogService
|
||||
{
|
||||
public interface ICatalogService
|
||||
{
|
||||
Task<Catalog> GetCatalogItems(int page, int take, int? brand, int? type);
|
||||
Task<IEnumerable<SelectListItem>> GetBrands();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using WebMVC.Services.ModelDTOs;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
public interface IOrderingService
|
||||
{
|
||||
public interface IOrderingService
|
||||
{
|
||||
Task<List<Order>> GetMyOrders(ApplicationUser user);
|
||||
Task<Order> GetOrder(ApplicationUser user, string orderId);
|
||||
Task CancelOrder(string orderId);
|
||||
@ -14,5 +10,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
Order MapUserInfoIntoOrder(ApplicationUser user, Order order);
|
||||
BasketDTO MapOrderToBasket(Order order);
|
||||
void OverrideUserInfoIntoOrder(Order original, Order destination);
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,7 @@
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Principal;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
public class IdentityParser : IIdentityParser<ApplicationUser>
|
||||
{
|
||||
public class IdentityParser : IIdentityParser<ApplicationUser>
|
||||
{
|
||||
public ApplicationUser Parse(IPrincipal principal)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace WebMVC.Services.ModelDTOs;
|
||||
|
||||
namespace WebMVC.Services.ModelDTOs
|
||||
public record BasketDTO
|
||||
{
|
||||
public record BasketDTO
|
||||
{
|
||||
[Required]
|
||||
public string City { get; init; }
|
||||
[Required]
|
||||
@ -32,6 +29,4 @@ namespace WebMVC.Services.ModelDTOs
|
||||
|
||||
[Required]
|
||||
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 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]
|
||||
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 Name { get; }
|
||||
|
||||
@ -16,5 +16,4 @@
|
||||
Code = code;
|
||||
Name = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,17 +1,9 @@
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
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;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
|
||||
public class OrderingService : IOrderingService
|
||||
{
|
||||
public class OrderingService : IOrderingService
|
||||
{
|
||||
private HttpClient _httpClient;
|
||||
private readonly string _remoteServiceBaseUrl;
|
||||
private readonly IOptions<AppSettings> _settings;
|
||||
@ -145,5 +137,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.Services
|
||||
RequestId = order.RequestId
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +1,7 @@
|
||||
using Devspaces.Support;
|
||||
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;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC
|
||||
public class Startup
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration 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)
|
||||
{
|
||||
@ -208,5 +187,4 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
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;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
||||
public class Cart : ViewComponent
|
||||
{
|
||||
public class Cart : ViewComponent
|
||||
{
|
||||
private readonly IBasketService _cartSvc;
|
||||
|
||||
public Cart(IBasketService cartSvc) => _cartSvc = cartSvc;
|
||||
@ -33,5 +27,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
||||
var basket = await _cartSvc.GetBasket(user);
|
||||
return basket.Items.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,13 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.eShopOnContainers.WebMVC.Services;
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewComponents
|
||||
public class CartList : ViewComponent
|
||||
{
|
||||
public class CartList : ViewComponent
|
||||
{
|
||||
private readonly IBasketService _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);
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations;
|
||||
|
||||
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)
|
||||
{
|
||||
if (value == null)
|
||||
@ -27,5 +24,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.Annotations
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace WebMVC.ViewModels.Annotations;
|
||||
|
||||
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
|
||||
IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
@ -18,5 +15,4 @@ namespace WebMVC.ViewModels.Annotations
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace WebMVC.ViewModels.Annotations;
|
||||
|
||||
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
|
||||
IsValid(object value, ValidationContext validationContext)
|
||||
{
|
||||
@ -18,5 +15,4 @@ namespace WebMVC.ViewModels.Annotations
|
||||
|
||||
return ValidationResult.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
|
||||
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 SecurityNumber { get; set; }
|
||||
public string Expiration { get; set; }
|
||||
@ -24,5 +21,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public string LastName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
public record Basket
|
||||
{
|
||||
public record Basket
|
||||
{
|
||||
// Use property initializer syntax.
|
||||
// While this is often more useful for read only
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 int ProductId { get; init; }
|
||||
public string ProductName { get; init; }
|
||||
@ -9,5 +9,4 @@
|
||||
public decimal OldUnitPrice { get; init; }
|
||||
public int Quantity { 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 PageSize { get; init; }
|
||||
public int Count { 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 string Name { get; init; }
|
||||
@ -16,5 +14,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
|
||||
public string PictureUri { 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 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 PageSize { get; init; }
|
||||
public int Count { 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 string Name { get; init; }
|
||||
public string Description { get; init; }
|
||||
@ -11,5 +11,4 @@
|
||||
public string CatalogBrand { get; init; }
|
||||
public int CatalogTypeId { get; init; }
|
||||
public string CatalogType { get; init; }
|
||||
}
|
||||
}
|
@ -1,16 +1,11 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
|
||||
using System.Collections.Generic;
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels
|
||||
public class IndexViewModel
|
||||
{
|
||||
public class IndexViewModel
|
||||
{
|
||||
public IEnumerable<CatalogItem> CatalogItems { get; set; }
|
||||
public IEnumerable<SelectListItem> Brands { get; set; }
|
||||
public IEnumerable<SelectListItem> Types { get; set; }
|
||||
public int? BrandFilterApplied { get; set; }
|
||||
public int? TypesFilterApplied { get; set; }
|
||||
public PaginationInfo PaginationInfo { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,7 @@
|
||||
using System;
|
||||
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;
|
||||
|
||||
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)
|
||||
{
|
||||
if (reader.TokenType == JsonTokenType.Number)
|
||||
@ -30,5 +23,4 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
{
|
||||
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 Text { get; init; }
|
||||
}
|
||||
}
|
@ -1,16 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
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;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
public class Order
|
||||
{
|
||||
public class Order
|
||||
{
|
||||
[JsonConverter(typeof(NumberToStringConverter))]
|
||||
public string OrderNumber { get; set; }
|
||||
|
||||
@ -92,10 +83,9 @@ namespace Microsoft.eShopOnContainers.WebMVC.ViewModels
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public enum CardType
|
||||
{
|
||||
AMEX = 1
|
||||
}
|
||||
}
|
||||
|
||||
public enum CardType
|
||||
{
|
||||
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 string ProductName { get; init; }
|
||||
@ -13,5 +13,4 @@
|
||||
public int Units { 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 ItemsPerPage { get; set; }
|
||||
public int ActualPage { get; set; }
|
||||
public int TotalPages { get; set; }
|
||||
public string Previous { get; set; }
|
||||
public string Next { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user