Shady nagy/net6 (#614)

* udated to .net6

* used the .net6 version RC2

* added editconfig.

* App core new Scoped Namespaces style.

* BlazorAdmin new Scoped Namespaces style.

* Blazor Shared new Scoped Namespaces style.

* Infra new Scoped Namespaces style.

* public api new Scoped Namespaces style.

* web new Scoped Namespaces style.

* FunctionalTests new Scoped Namespaces style.

* Integrational tests new Scoped Namespaces style.

* unit tests new Scoped Namespaces style.

* update github action.

* update github action.

* change the global.
This commit is contained in:
Shady Nagy
2021-11-06 01:55:48 +02:00
committed by GitHub
parent 64f150dc07
commit 9db2feb930
252 changed files with 6307 additions and 6413 deletions

134
.editorconfig Normal file
View File

@@ -0,0 +1,134 @@
###############################
# Core EditorConfig Options #
###############################
root = true
# All files
[*]
indent_style = space
# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
# XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
insert_final_newline = true
charset = utf-8-bom
###############################
# .NET Coding Conventions #
###############################
[*.{cs,vb}]
# Organize usings
dotnet_sort_system_directives_first = true
# this. preferences
dotnet_style_qualification_for_field = false:silent
dotnet_style_qualification_for_property = false:silent
dotnet_style_qualification_for_method = false:silent
dotnet_style_qualification_for_event = false:silent
# Language keywords vs BCL types preferences
dotnet_style_predefined_type_for_locals_parameters_members = true:silent
dotnet_style_predefined_type_for_member_access = true:silent
# Parentheses preferences
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent
# Modifier preferences
dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent
dotnet_style_readonly_field = true:suggestion
# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:silent
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
dotnet_style_prefer_conditional_expression_over_assignment = true:silent
dotnet_style_prefer_conditional_expression_over_return = true:silent
###############################
# Naming Conventions #
###############################
# Style Definitions
dotnet_naming_style.pascal_case_style.capitalization = pascal_case
# Use PascalCase for constant fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.applicable_accessibilities = *
dotnet_naming_symbols.constant_fields.required_modifiers = const
###############################
# C# Coding Conventions #
###############################
[*.cs]
# var preferences
csharp_style_var_for_built_in_types = true:silent
csharp_style_var_when_type_is_apparent = true:silent
csharp_style_var_elsewhere = true:silent
# Expression-bodied members
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion
# Modifier preferences
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion
# Expression-level preferences
csharp_prefer_braces = true:silent
csharp_style_deconstructed_variable_declaration = true:suggestion
csharp_prefer_simple_default_expression = true:suggestion
csharp_style_pattern_local_over_anonymous_function = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion
# Namespaces
csharp_style_namespace_declarations = file_scoped:warning
###############################
# C# Formatting Rules #
###############################
# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true
# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left
# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false
# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true
###############################
# VB Coding Conventions #
###############################
[*.vb]
# Modifier preferences
visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:suggestion

View File

@@ -12,7 +12,8 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: '5.0.x'
dotnet-version: '6.0.x'
include-prerelease: true
- name: Build with dotnet
run: dotnet build ./eShopOnWeb.sln --configuration Release

6
global.json Normal file
View File

@@ -0,0 +1,6 @@
{
"sdk": {
"version": "6.0.x",
"rollForward": "latestFeature"
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Microsoft.eShopWeb.ApplicationCore</RootNamespace>
</PropertyGroup>

View File

@@ -1,7 +1,6 @@
namespace Microsoft.eShopWeb
namespace Microsoft.eShopWeb;
public class CatalogSettings
{
public class CatalogSettings
{
public string CatalogBaseUrl { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
namespace Microsoft.eShopWeb.ApplicationCore.Constants
namespace Microsoft.eShopWeb.ApplicationCore.Constants;
public class AuthorizationConstants
{
public class AuthorizationConstants
{
public const string AUTH_KEY = "AuthKeyOfDoomThatMustBeAMinimumNumberOfBytes";
// TODO: Don't use this in production
@@ -9,5 +9,4 @@
// TODO: Change this to an environment variable
public const string JWT_SECRET_KEY = "SecretKeyOfDoomThatMustBeAMinimumNumberOfBytes";
}
}

View File

@@ -1,9 +1,8 @@
namespace Microsoft.eShopWeb.ApplicationCore.Entities
namespace Microsoft.eShopWeb.ApplicationCore.Entities;
// This can easily be modified to be BaseEntity<T> and public T Id to support different key types.
// Using non-generic integer types for simplicity and to ease caching logic
public abstract class BaseEntity
{
// This can easily be modified to be BaseEntity<T> and public T Id to support different key types.
// Using non-generic integer types for simplicity and to ease caching logic
public abstract class BaseEntity
{
public virtual int Id { get; protected set; }
}
}

View File

@@ -1,11 +1,11 @@
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
public class Basket : BaseEntity, IAggregateRoot
{
public class Basket : BaseEntity, IAggregateRoot
{
public string BuyerId { get; private set; }
private readonly List<BasketItem> _items = new List<BasketItem>();
public IReadOnlyCollection<BasketItem> Items => _items.AsReadOnly();
@@ -35,5 +35,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate
{
BuyerId = buyerId;
}
}
}

View File

@@ -1,9 +1,9 @@
using Ardalis.GuardClauses;
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
public class BasketItem : BaseEntity
{
public class BasketItem : BaseEntity
{
public decimal UnitPrice { get; private set; }
public int Quantity { get; private set; }
@@ -30,5 +30,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate
Quantity = quantity;
}
}
}

View File

@@ -1,11 +1,11 @@
using Ardalis.GuardClauses;
using System.Collections.Generic;
using Ardalis.GuardClauses;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System.Collections.Generic;
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BuyerAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BuyerAggregate;
public class Buyer : BaseEntity, IAggregateRoot
{
public class Buyer : BaseEntity, IAggregateRoot
{
public string IdentityGuid { get; private set; }
private List<PaymentMethod> _paymentMethods = new List<PaymentMethod>();
@@ -22,5 +22,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities.BuyerAggregate
Guard.Against.NullOrEmpty(identity, nameof(identity));
IdentityGuid = identity;
}
}
}

View File

@@ -1,9 +1,8 @@
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BuyerAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.BuyerAggregate;
public class PaymentMethod : BaseEntity
{
public class PaymentMethod : BaseEntity
{
public string Alias { get; private set; }
public string CardId { get; private set; } // actual card data must be stored in a PCI compliant system, like Stripe
public string Last4 { get; private set; }
}
}

View File

@@ -1,13 +1,12 @@
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.ApplicationCore.Entities
namespace Microsoft.eShopWeb.ApplicationCore.Entities;
public class CatalogBrand : BaseEntity, IAggregateRoot
{
public class CatalogBrand : BaseEntity, IAggregateRoot
{
public string Brand { get; private set; }
public CatalogBrand(string brand)
{
Brand = brand;
}
}
}

View File

@@ -1,11 +1,11 @@
using Ardalis.GuardClauses;
using System;
using Ardalis.GuardClauses;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System;
namespace Microsoft.eShopWeb.ApplicationCore.Entities
namespace Microsoft.eShopWeb.ApplicationCore.Entities;
public class CatalogItem : BaseEntity, IAggregateRoot
{
public class CatalogItem : BaseEntity, IAggregateRoot
{
public string Name { get; private set; }
public string Description { get; private set; }
public decimal Price { get; private set; }
@@ -62,5 +62,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities
}
PictureUri = $"images\\products\\{pictureName}?{new DateTime().Ticks}";
}
}
}

View File

@@ -1,13 +1,12 @@
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.ApplicationCore.Entities
namespace Microsoft.eShopWeb.ApplicationCore.Entities;
public class CatalogType : BaseEntity, IAggregateRoot
{
public class CatalogType : BaseEntity, IAggregateRoot
{
public string Type { get; private set; }
public CatalogType(string type)
{
Type = type;
}
}
}

View File

@@ -1,7 +1,7 @@
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
public class Address // ValueObject
{
public class Address // ValueObject
{
public string Street { get; private set; }
public string City { get; private set; }
@@ -22,5 +22,4 @@
Country = country;
ZipCode = zipcode;
}
}
}

View File

@@ -1,13 +1,13 @@
using Ardalis.GuardClauses;
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
/// <summary>
/// Represents a snapshot of the item that was ordered. If catalog item details change, details of
/// the item that was part of a completed order should not change.
/// </summary>
public class CatalogItemOrdered // ValueObject
{
/// <summary>
/// Represents a snapshot of the item that was ordered. If catalog item details change, details of
/// the item that was part of a completed order should not change.
/// </summary>
public class CatalogItemOrdered // ValueObject
{
public CatalogItemOrdered(int catalogItemId, string productName, string pictureUri)
{
Guard.Against.OutOfRange(catalogItemId, nameof(catalogItemId), 1, int.MaxValue);
@@ -27,5 +27,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
public int CatalogItemId { get; private set; }
public string ProductName { get; private set; }
public string PictureUri { get; private set; }
}
}

View File

@@ -1,12 +1,12 @@
using Ardalis.GuardClauses;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System;
using System;
using System.Collections.Generic;
using Ardalis.GuardClauses;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
public class Order : BaseEntity, IAggregateRoot
{
public class Order : BaseEntity, IAggregateRoot
{
private Order()
{
// required by EF
@@ -48,5 +48,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
}
return total;
}
}
}

View File

@@ -1,7 +1,7 @@
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate
namespace Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
public class OrderItem : BaseEntity
{
public class OrderItem : BaseEntity
{
public CatalogItemOrdered ItemOrdered { get; private set; }
public decimal UnitPrice { get; private set; }
public int Units { get; private set; }
@@ -17,5 +17,4 @@
UnitPrice = unitPrice;
Units = units;
}
}
}

View File

@@ -1,11 +1,10 @@
using System;
namespace Microsoft.eShopWeb.ApplicationCore.Exceptions
namespace Microsoft.eShopWeb.ApplicationCore.Exceptions;
public class BasketNotFoundException : Exception
{
public class BasketNotFoundException : Exception
{
public BasketNotFoundException(int basketId) : base($"No basket found with id {basketId}")
{
}
}
}

View File

@@ -1,14 +1,12 @@
using System;
namespace Microsoft.eShopWeb.ApplicationCore.Exceptions
{
namespace Microsoft.eShopWeb.ApplicationCore.Exceptions;
public class DuplicateException : Exception
{
public class DuplicateException : Exception
{
public DuplicateException(string message) : base(message)
{
}
}
}

View File

@@ -1,9 +1,9 @@
using System;
namespace Microsoft.eShopWeb.ApplicationCore.Exceptions
namespace Microsoft.eShopWeb.ApplicationCore.Exceptions;
public class EmptyBasketOnCheckoutException : Exception
{
public class EmptyBasketOnCheckoutException : Exception
{
public EmptyBasketOnCheckoutException()
: base($"Basket cannot have 0 items on checkout")
{
@@ -20,5 +20,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Exceptions
public EmptyBasketOnCheckoutException(string message, Exception innerException) : base(message, innerException)
{
}
}
}

View File

@@ -1,12 +1,12 @@
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Exceptions;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Exceptions;
namespace Ardalis.GuardClauses
namespace Ardalis.GuardClauses;
public static class BasketGuards
{
public static class BasketGuards
{
public static void NullBasket(this IGuardClause guardClause, int basketId, Basket basket)
{
if (basket == null)
@@ -18,5 +18,4 @@ namespace Ardalis.GuardClauses
if (!basketItems.Any())
throw new EmptyBasketOnCheckoutException();
}
}
}

View File

@@ -1,9 +1,9 @@
using System.Text.Json;
namespace Microsoft.eShopWeb
namespace Microsoft.eShopWeb;
public static class JsonExtensions
{
public static class JsonExtensions
{
private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
{
PropertyNameCaseInsensitive = true
@@ -14,5 +14,4 @@ namespace Microsoft.eShopWeb
public static string ToJson<T>(this T obj) =>
JsonSerializer.Serialize<T>(obj, _jsonOptions);
}
}

View File

@@ -1,5 +1,4 @@
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
{
public interface IAggregateRoot
{ }
}
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IAggregateRoot
{ }

View File

@@ -1,12 +1,11 @@
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
/// <summary>
/// This type eliminates the need to depend directly on the ASP.NET Core logging types.
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IAppLogger<T>
{
/// <summary>
/// This type eliminates the need to depend directly on the ASP.NET Core logging types.
/// </summary>
/// <typeparam name="T"></typeparam>
public interface IAppLogger<T>
{
void LogInformation(string message, params object[] args);
void LogWarning(string message, params object[] args);
}
}

View File

@@ -1,9 +1,8 @@
using System.Threading.Tasks;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IBasketQueryService
{
public interface IBasketQueryService
{
Task<int> CountTotalBasketItems(string username);
}
}

View File

@@ -1,14 +1,13 @@
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IBasketService
{
public interface IBasketService
{
Task TransferBasketAsync(string anonymousId, string userName);
Task<Basket> AddItemToBasket(string username, int catalogItemId, decimal price, int quantity = 1);
Task<Basket> SetQuantities(int basketId, Dictionary<string, int> quantities);
Task DeleteBasketAsync(int basketId);
}
}

View File

@@ -1,10 +1,8 @@
using System.Threading.Tasks;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
{
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IEmailSender
{
public interface IEmailSender
{
Task SendEmailAsync(string email, string subject, string message);
}
}

View File

@@ -1,10 +1,9 @@
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IOrderService
{
public interface IOrderService
{
Task CreateOrderAsync(int basketId, Address shippingAddress);
}
}

View File

@@ -1,8 +1,7 @@
using Ardalis.Specification;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IReadRepository<T> : IReadRepositoryBase<T> where T : class, IAggregateRoot
{
public interface IReadRepository<T> : IReadRepositoryBase<T> where T : class, IAggregateRoot
{
}
}

View File

@@ -1,8 +1,7 @@
using Ardalis.Specification;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IRepository<T> : IRepositoryBase<T> where T : class, IAggregateRoot
{
public interface IRepository<T> : IRepositoryBase<T> where T : class, IAggregateRoot
{
}
}

View File

@@ -1,9 +1,8 @@
using System.Threading.Tasks;
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface ITokenClaimsService
{
public interface ITokenClaimsService
{
Task<string> GetTokenAsync(string userName);
}
}

View File

@@ -1,7 +1,6 @@
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces
namespace Microsoft.eShopWeb.ApplicationCore.Interfaces;
public interface IUriComposer
{
public interface IUriComposer
{
string ComposePicUri(string uriTemplate);
}
}

View File

@@ -1,14 +1,14 @@
using Ardalis.GuardClauses;
using System.Collections.Generic;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.ApplicationCore.Specifications;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Microsoft.eShopWeb.ApplicationCore.Services
namespace Microsoft.eShopWeb.ApplicationCore.Services;
public class BasketService : IBasketService
{
public class BasketService : IBasketService
{
private readonly IRepository<Basket> _basketRepository;
private readonly IAppLogger<BasketService> _logger;
@@ -83,5 +83,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Services
await _basketRepository.UpdateAsync(userBasket);
await _basketRepository.DeleteAsync(anonymousBasket);
}
}
}

View File

@@ -1,16 +1,16 @@
using Ardalis.GuardClauses;
using System.Linq;
using System.Threading.Tasks;
using Ardalis.GuardClauses;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using Microsoft.eShopWeb.ApplicationCore.Specifications;
using System.Linq;
using System.Threading.Tasks;
namespace Microsoft.eShopWeb.ApplicationCore.Services
namespace Microsoft.eShopWeb.ApplicationCore.Services;
public class OrderService : IOrderService
{
public class OrderService : IOrderService
{
private readonly IRepository<Order> _orderRepository;
private readonly IUriComposer _uriComposer;
private readonly IRepository<Basket> _basketRepository;
@@ -50,5 +50,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Services
await _orderRepository.AddAsync(order);
}
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.ApplicationCore.Services
namespace Microsoft.eShopWeb.ApplicationCore.Services;
public class UriComposer : IUriComposer
{
public class UriComposer : IUriComposer
{
private readonly CatalogSettings _catalogSettings;
public UriComposer(CatalogSettings catalogSettings) => _catalogSettings = catalogSettings;
@@ -12,5 +12,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Services
{
return uriTemplate.Replace("http://catalogbaseurltobereplaced", _catalogSettings.CatalogBaseUrl);
}
}
}

View File

@@ -1,10 +1,10 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public sealed class BasketWithItemsSpecification : Specification<Basket>, ISingleResultSpecification
{
public sealed class BasketWithItemsSpecification : Specification<Basket>, ISingleResultSpecification
{
public BasketWithItemsSpecification(int basketId)
{
Query
@@ -18,5 +18,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
.Where(b => b.BuyerId == buyerId)
.Include(b => b.Items);
}
}
}

View File

@@ -1,10 +1,10 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public class CatalogFilterPaginatedSpecification : Specification<CatalogItem>
{
public class CatalogFilterPaginatedSpecification : Specification<CatalogItem>
{
public CatalogFilterPaginatedSpecification(int skip, int take, int? brandId, int? typeId)
: base()
{
@@ -17,5 +17,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
(!typeId.HasValue || i.CatalogTypeId == typeId))
.Skip(skip).Take(take);
}
}
}

View File

@@ -1,14 +1,13 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public class CatalogFilterSpecification : Specification<CatalogItem>
{
public class CatalogFilterSpecification : Specification<CatalogItem>
{
public CatalogFilterSpecification(int? brandId, int? typeId)
{
Query.Where(i => (!brandId.HasValue || i.CatalogBrandId == brandId) &&
(!typeId.HasValue || i.CatalogTypeId == typeId));
}
}
}

View File

@@ -1,13 +1,12 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public class CatalogItemNameSpecification : Specification<CatalogItem>
{
public class CatalogItemNameSpecification : Specification<CatalogItem>
{
public CatalogItemNameSpecification(string catalogItemName)
{
Query.Where(item => catalogItemName == item.Name);
}
}
}

View File

@@ -1,15 +1,14 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using System;
using System;
using System.Linq;
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public class CatalogItemsSpecification : Specification<CatalogItem>
{
public class CatalogItemsSpecification : Specification<CatalogItem>
{
public CatalogItemsSpecification(params int[] ids)
{
Query.Where(c => ids.Contains(c.Id));
}
}
}

View File

@@ -1,15 +1,14 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public class CustomerOrdersWithItemsSpecification : Specification<Order>
{
public class CustomerOrdersWithItemsSpecification : Specification<Order>
{
public CustomerOrdersWithItemsSpecification(string buyerId)
{
Query.Where(o => o.BuyerId == buyerId)
.Include(o => o.OrderItems)
.ThenInclude(i => i.ItemOrdered);
}
}
}

View File

@@ -1,10 +1,10 @@
using Ardalis.Specification;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
namespace Microsoft.eShopWeb.ApplicationCore.Specifications
namespace Microsoft.eShopWeb.ApplicationCore.Specifications;
public class OrderWithItemsByIdSpec : Specification<Order>, ISingleResultSpecification
{
public class OrderWithItemsByIdSpec : Specification<Order>, ISingleResultSpecification
{
public OrderWithItemsByIdSpec(int orderId)
{
Query
@@ -12,5 +12,4 @@ namespace Microsoft.eShopWeb.ApplicationCore.Specifications
.Include(o => o.OrderItems)
.ThenInclude(i => i.ItemOrdered);
}
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>

View File

@@ -1,17 +1,17 @@
using BlazorShared.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Logging;
using System;
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Net.Http.Json;
using System.Security.Claims;
using System.Threading.Tasks;
using BlazorShared.Authorization;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.Logging;
namespace BlazorAdmin
namespace BlazorAdmin;
public class CustomAuthStateProvider : AuthenticationStateProvider
{
public class CustomAuthStateProvider : AuthenticationStateProvider
{
// TODO: Get Default Cache Duration from Config
private static readonly TimeSpan UserCacheRefreshInterval = TimeSpan.FromSeconds(60);
@@ -83,5 +83,4 @@ namespace BlazorAdmin
return new ClaimsPrincipal(identity);
}
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Components;
namespace BlazorAdmin.Helpers
namespace BlazorAdmin.Helpers;
public class BlazorComponent : ComponentBase
{
public class BlazorComponent : ComponentBase
{
private readonly RefreshBroadcast _refresh = RefreshBroadcast.Instance;
protected override void OnInitialized()
@@ -22,5 +22,4 @@ namespace BlazorAdmin.Helpers
StateHasChanged();
}
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Components;
namespace BlazorAdmin.Helpers
namespace BlazorAdmin.Helpers;
public class BlazorLayoutComponent : LayoutComponentBase
{
public class BlazorLayoutComponent : LayoutComponentBase
{
private readonly RefreshBroadcast _refresh = RefreshBroadcast.Instance;
protected override void OnInitialized()
@@ -21,5 +21,4 @@ namespace BlazorAdmin.Helpers
{
StateHasChanged();
}
}
}

View File

@@ -1,9 +1,9 @@
using System;
namespace BlazorAdmin.Helpers
namespace BlazorAdmin.Helpers;
internal sealed class RefreshBroadcast
{
internal sealed class RefreshBroadcast
{
private static readonly Lazy<RefreshBroadcast>
Lazy =
new Lazy<RefreshBroadcast>
@@ -20,5 +20,4 @@ namespace BlazorAdmin.Helpers
{
RefreshRequested?.Invoke();
}
}
}

View File

@@ -1,11 +1,11 @@
using BlazorAdmin.Services;
using System;
using BlazorAdmin.Services;
using Microsoft.AspNetCore.Components;
using System;
namespace BlazorAdmin.Helpers
namespace BlazorAdmin.Helpers;
public class ToastComponent : ComponentBase, IDisposable
{
public class ToastComponent : ComponentBase, IDisposable
{
[Inject]
ToastService ToastService
{
@@ -84,5 +84,4 @@ namespace BlazorAdmin.Helpers
{
ToastService.OnShow -= ShowToast;
}
}
}

View File

@@ -1,10 +1,10 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.JSInterop;
namespace BlazorAdmin.JavaScript
namespace BlazorAdmin.JavaScript;
public class Cookies
{
public class Cookies
{
private readonly IJSRuntime _jsRuntime;
public Cookies(IJSRuntime jsRuntime)
@@ -21,5 +21,4 @@ namespace BlazorAdmin.JavaScript
{
return await _jsRuntime.InvokeAsync<string>(JSInteropConstants.GetCookie, name);
}
}
}

View File

@@ -1,10 +1,10 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.JSInterop;
namespace BlazorAdmin.JavaScript
namespace BlazorAdmin.JavaScript;
public class Css
{
public class Css
{
private readonly IJSRuntime _jsRuntime;
public Css(IJSRuntime jsRuntime)
@@ -21,5 +21,4 @@ namespace BlazorAdmin.JavaScript
{
return await _jsRuntime.InvokeAsync<string>(JSInteropConstants.HideBodyOverflow);
}
}
}

View File

@@ -1,11 +1,10 @@
namespace BlazorAdmin.JavaScript
namespace BlazorAdmin.JavaScript;
public static class JSInteropConstants
{
public static class JSInteropConstants
{
public static string DeleteCookie => "deleteCookie";
public static string GetCookie => "getCookie";
public static string RouteOutside => "routeOutside";
public static string HideBodyOverflow => "hideBodyOverflow";
public static string ShowBodyOverflow => "showBodyOverflow";
}
}

View File

@@ -1,10 +1,10 @@
using Microsoft.JSInterop;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.JSInterop;
namespace BlazorAdmin.JavaScript
namespace BlazorAdmin.JavaScript;
public class Route
{
public class Route
{
private readonly IJSRuntime _jsRuntime;
public Route(IJSRuntime jsRuntime)
@@ -16,5 +16,4 @@ namespace BlazorAdmin.JavaScript
{
await _jsRuntime.InvokeAsync<string>(JSInteropConstants.RouteOutside, path);
}
}
}

View File

@@ -1,13 +1,13 @@
using BlazorAdmin.Helpers;
using System.Collections.Generic;
using System.Threading.Tasks;
using BlazorAdmin.Helpers;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace BlazorAdmin.Pages.CatalogItemPage
namespace BlazorAdmin.Pages.CatalogItemPage;
public partial class List : BlazorComponent
{
public partial class List : BlazorComponent
{
[Microsoft.AspNetCore.Components.Inject]
public ICatalogItemService CatalogItemService { get; set; }
@@ -65,5 +65,4 @@ namespace BlazorAdmin.Pages.CatalogItemPage
catalogItems = await CatalogItemService.List();
StateHasChanged();
}
}
}

View File

@@ -1,3 +1,6 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using BlazorAdmin.Services;
using Blazored.LocalStorage;
using BlazorShared;
@@ -7,14 +10,11 @@ using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace BlazorAdmin
namespace BlazorAdmin;
public class Program
{
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
@@ -52,5 +52,4 @@ namespace BlazorAdmin
await localStorageService.RemoveItemAsync(typeof(CatalogBrand).Name);
await localStorageService.RemoveItemAsync(typeof(CatalogType).Name);
}
}
}

View File

@@ -1,9 +1,9 @@
using System;
namespace BlazorAdmin.Services
namespace BlazorAdmin.Services;
public class CacheEntry<T>
{
public class CacheEntry<T>
{
public CacheEntry(T item)
{
Value = item;
@@ -15,5 +15,4 @@ namespace BlazorAdmin.Services
public T Value { get; set; }
public DateTime DateCreated { get; set; } = DateTime.UtcNow;
}
}

View File

@@ -1,16 +1,16 @@
using Blazored.LocalStorage;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Blazored.LocalStorage;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
namespace BlazorAdmin.Services
namespace BlazorAdmin.Services;
public class CachedCatalogItemServiceDecorator : ICatalogItemService
{
public class CachedCatalogItemServiceDecorator : ICatalogItemService
{
private readonly ILocalStorageService _localStorageService;
private readonly CatalogItemService _catalogItemService;
private ILogger<CachedCatalogItemServiceDecorator> _logger;
@@ -110,5 +110,4 @@ namespace BlazorAdmin.Services
var entry = new CacheEntry<List<CatalogItem>>(items);
await _localStorageService.SetItemAsync(key, entry);
}
}
}

View File

@@ -1,18 +1,18 @@
using Blazored.LocalStorage;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Blazored.LocalStorage;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace BlazorAdmin.Services
{
public class CachedCatalogLookupDataServiceDecorator<TLookupData, TReponse>
namespace BlazorAdmin.Services;
public class CachedCatalogLookupDataServiceDecorator<TLookupData, TReponse>
: ICatalogLookupDataService<TLookupData>
where TLookupData : LookupData
where TReponse : ILookupDataResponse<TLookupData>
{
{
private readonly ILocalStorageService _localStorageService;
private readonly CatalogLookupDataService<TLookupData, TReponse> _catalogTypeService;
private ILogger<CachedCatalogLookupDataServiceDecorator<TLookupData, TReponse>> _logger;
@@ -49,5 +49,4 @@ namespace BlazorAdmin.Services
await _localStorageService.SetItemAsync(key, entry);
return types;
}
}
}

View File

@@ -1,15 +1,15 @@
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
namespace BlazorAdmin.Services
namespace BlazorAdmin.Services;
public class CatalogItemService : ICatalogItemService
{
public class CatalogItemService : ICatalogItemService
{
private readonly ICatalogLookupDataService<CatalogBrand> _brandService;
private readonly ICatalogLookupDataService<CatalogType> _typeService;
private readonly HttpService _httpService;
@@ -93,5 +93,4 @@ namespace BlazorAdmin.Services
}
return items;
}
}
}

View File

@@ -1,22 +1,22 @@
using BlazorShared;
using BlazorShared.Attributes;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Json;
using System.Reflection;
using System.Threading.Tasks;
using BlazorShared;
using BlazorShared.Attributes;
using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.Logging;
namespace BlazorAdmin.Services
{
public class CatalogLookupDataService<TLookupData, TReponse>
namespace BlazorAdmin.Services;
public class CatalogLookupDataService<TLookupData, TReponse>
: ICatalogLookupDataService<TLookupData>
where TLookupData : LookupData
where TReponse : ILookupDataResponse<TLookupData>
{
{
private readonly HttpClient _httpClient;
private readonly ILogger<CatalogLookupDataService<TLookupData, TReponse>> _logger;
@@ -39,5 +39,4 @@ namespace BlazorAdmin.Services
var response = await _httpClient.GetFromJsonAsync<TReponse>($"{_apiUrl}{endpointName}");
return response.List;
}
}
}

View File

@@ -1,14 +1,14 @@
using BlazorShared;
using BlazorShared.Models;
using System.Net.Http;
using System.Net.Http;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using BlazorShared;
using BlazorShared.Models;
namespace BlazorAdmin.Services
namespace BlazorAdmin.Services;
public class HttpService
{
public class HttpService
{
private readonly HttpClient _httpClient;
private readonly ToastService _toastService;
private readonly string _apiUrl;
@@ -92,5 +92,4 @@ namespace BlazorAdmin.Services
PropertyNameCaseInsensitive = true
});
}
}
}

View File

@@ -1,18 +1,18 @@
using System;
using System.Timers;
namespace BlazorAdmin.Services
namespace BlazorAdmin.Services;
public enum ToastLevel
{
public enum ToastLevel
{
Info,
Success,
Warning,
Error
}
}
public class ToastService : IDisposable
{
public class ToastService : IDisposable
{
public event Action<string, ToastLevel> OnShow;
public event Action OnHide;
private Timer Countdown;
@@ -51,5 +51,4 @@ namespace BlazorAdmin.Services
{
Countdown?.Dispose();
}
}
}

View File

@@ -3,20 +3,19 @@ using BlazorShared.Interfaces;
using BlazorShared.Models;
using Microsoft.Extensions.DependencyInjection;
namespace BlazorAdmin
namespace BlazorAdmin;
public static class ServicesConfiguration
{
public static class ServicesConfiguration
{
public static IServiceCollection AddBlazorServices(this IServiceCollection services)
{
services.AddScoped<ICatalogLookupDataService<CatalogBrand>, CachedCatalogLookupDataServiceDecorator<CatalogBrand,CatalogBrandResponse>>();
services.AddScoped<ICatalogLookupDataService<CatalogBrand>, CachedCatalogLookupDataServiceDecorator<CatalogBrand, CatalogBrandResponse>>();
services.AddScoped<CatalogLookupDataService<CatalogBrand, CatalogBrandResponse>>();
services.AddScoped<ICatalogLookupDataService<CatalogType>, CachedCatalogLookupDataServiceDecorator<CatalogType,CatalogTypeResponse>>();
services.AddScoped<ICatalogLookupDataService<CatalogType>, CachedCatalogLookupDataServiceDecorator<CatalogType, CatalogTypeResponse>>();
services.AddScoped<CatalogLookupDataService<CatalogType, CatalogTypeResponse>>();
services.AddScoped<ICatalogItemService, CachedCatalogItemServiceDecorator>();
services.AddScoped<CatalogItemService>();
return services;
}
}
}

View File

@@ -1,14 +1,14 @@
using Microsoft.AspNetCore.Components.Forms;
namespace BlazorAdmin.Shared
namespace BlazorAdmin.Shared;
/// <summary>
/// This is needed until 5.0 ships with native support
/// https://www.pragimtech.com/blog/blazor/inputselect-does-not-support-system.int32/
/// </summary>
/// <typeparam name="TValue"></typeparam>
public class CustomInputSelect<TValue> : InputSelect<TValue>
{
/// <summary>
/// This is needed until 5.0 ships with native support
/// https://www.pragimtech.com/blog/blazor/inputselect-does-not-support-system.int32/
/// </summary>
/// <typeparam name="TValue"></typeparam>
public class CustomInputSelect<TValue> : InputSelect<TValue>
{
protected override bool TryParseValueFromString(string value, out TValue result,
out string validationErrorMessage)
{
@@ -34,5 +34,4 @@ namespace BlazorAdmin.Shared
out validationErrorMessage);
}
}
}
}

View File

@@ -1,9 +1,8 @@
using System;
namespace BlazorShared.Attributes
namespace BlazorShared.Attributes;
public class EndpointAttribute : Attribute
{
public class EndpointAttribute : Attribute
{
public string Name { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
namespace BlazorShared.Authorization
namespace BlazorShared.Authorization;
public class ClaimValue
{
public class ClaimValue
{
public ClaimValue()
{
}
@@ -14,5 +14,4 @@
public string Type { get; set; }
public string Value { get; set; }
}
}

View File

@@ -1,10 +1,9 @@
namespace BlazorShared.Authorization
namespace BlazorShared.Authorization;
public static class Constants
{
public static class Constants
{
public static class Roles
{
public const string ADMINISTRATORS = "Administrators";
}
}
}

View File

@@ -1,14 +1,13 @@
using System.Collections.Generic;
namespace BlazorShared.Authorization
namespace BlazorShared.Authorization;
public class UserInfo
{
public class UserInfo
{
public static readonly UserInfo Anonymous = new UserInfo();
public bool IsAuthenticated { get; set; }
public string NameClaimType { get; set; }
public string RoleClaimType { get; set; }
public string Token { get; set; }
public IEnumerable<ClaimValue> Claims { get; set; }
}
}

View File

@@ -1,10 +1,9 @@
namespace BlazorShared
namespace BlazorShared;
public class BaseUrlConfiguration
{
public class BaseUrlConfiguration
{
public const string CONFIG_NAME = "baseUrls";
public string ApiBase { get; set; }
public string WebBase { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>BlazorShared</RootNamespace>
<AssemblyName>BlazorShared</AssemblyName>
</PropertyGroup>

View File

@@ -2,15 +2,14 @@
using System.Threading.Tasks;
using BlazorShared.Models;
namespace BlazorShared.Interfaces
namespace BlazorShared.Interfaces;
public interface ICatalogItemService
{
public interface ICatalogItemService
{
Task<CatalogItem> Create(CreateCatalogItemRequest catalogItem);
Task<CatalogItem> Edit(CatalogItem catalogItem);
Task<string> Delete(int id);
Task<CatalogItem> GetById(int id);
Task<List<CatalogItem>> ListPaged(int pageSize);
Task<List<CatalogItem>> List();
}
}

View File

@@ -1,11 +1,10 @@
using BlazorShared.Models;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;
using BlazorShared.Models;
namespace BlazorShared.Interfaces
namespace BlazorShared.Interfaces;
public interface ICatalogLookupDataService<TLookupData> where TLookupData : LookupData
{
public interface ICatalogLookupDataService<TLookupData> where TLookupData : LookupData
{
Task<List<TLookupData>> List();
}
}

View File

@@ -1,10 +1,9 @@
using BlazorShared.Models;
using System.Collections.Generic;
using System.Collections.Generic;
using BlazorShared.Models;
namespace BlazorShared.Interfaces
namespace BlazorShared.Interfaces;
public interface ILookupDataResponse<TLookupData> where TLookupData : LookupData
{
public interface ILookupDataResponse<TLookupData> where TLookupData : LookupData
{
List<TLookupData> List { get; set; }
}
}

View File

@@ -1,9 +1,8 @@
using BlazorShared.Attributes;
namespace BlazorShared.Models
namespace BlazorShared.Models;
[Endpoint(Name = "catalog-brands")]
public class CatalogBrand : LookupData
{
[Endpoint(Name = "catalog-brands")]
public class CatalogBrand : LookupData
{
}
}

View File

@@ -1,12 +1,11 @@
using BlazorShared.Interfaces;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using BlazorShared.Interfaces;
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class CatalogBrandResponse : ILookupDataResponse<CatalogBrand>
{
public class CatalogBrandResponse : ILookupDataResponse<CatalogBrand>
{
[JsonPropertyName("CatalogBrands")]
public List<CatalogBrand> List { get; set; } = new List<CatalogBrand>();
}
}

View File

@@ -4,10 +4,10 @@ using System.IO;
using System.Threading.Tasks;
using BlazorInputFile;
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class CatalogItem
{
public class CatalogItem
{
public int Id { get; set; }
public int CatalogTypeId { get; set; }
@@ -62,7 +62,7 @@ namespace BlazorShared.Models
public static async Task<string> DataToBase64(IFileListEntry fileItem)
{
using ( var reader = new StreamReader(fileItem.Data))
using (var reader = new StreamReader(fileItem.Data))
{
using (var memStream = new MemoryStream())
{
@@ -84,5 +84,4 @@ namespace BlazorShared.Models
string.Equals(extension, ".gif", StringComparison.OrdinalIgnoreCase) ||
string.Equals(extension, ".jpeg", StringComparison.OrdinalIgnoreCase);
}
}
}

View File

@@ -1,9 +1,8 @@
using BlazorShared.Attributes;
namespace BlazorShared.Models
namespace BlazorShared.Models;
[Endpoint(Name = "catalog-types")]
public class CatalogType : LookupData
{
[Endpoint(Name = "catalog-types")]
public class CatalogType : LookupData
{
}
}

View File

@@ -1,13 +1,12 @@
using BlazorShared.Interfaces;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using BlazorShared.Interfaces;
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class CatalogTypeResponse : ILookupDataResponse<CatalogType>
{
public class CatalogTypeResponse : ILookupDataResponse<CatalogType>
{
[JsonPropertyName("CatalogTypes")]
public List<CatalogType> List { get; set; } = new List<CatalogType>();
}
}

View File

@@ -1,9 +1,9 @@
using System.ComponentModel.DataAnnotations;
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class CreateCatalogItemRequest
{
public class CreateCatalogItemRequest
{
public int CatalogTypeId { get; set; }
public int CatalogBrandId { get; set; }
@@ -24,5 +24,4 @@ namespace BlazorShared.Models
public string PictureBase64 { get; set; } = string.Empty;
public string PictureName { get; set; } = string.Empty;
}
}

View File

@@ -1,7 +1,6 @@
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class CreateCatalogItemResponse
{
public class CreateCatalogItemResponse
{
public CatalogItem CatalogItem { get; set; } = new CatalogItem();
}
}

View File

@@ -1,7 +1,6 @@
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class DeleteCatalogItemResponse
{
public class DeleteCatalogItemResponse
{
public string Status { get; set; } = "Deleted";
}
}

View File

@@ -1,7 +1,6 @@
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class EditCatalogItemResult
{
public class EditCatalogItemResult
{
public CatalogItem CatalogItem { get; set; } = new CatalogItem();
}
}

View File

@@ -1,14 +1,13 @@
using System.Text.Json;
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class ErrorDetails
{
public class ErrorDetails
{
public int StatusCode { get; set; }
public string Message { get; set; }
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@@ -1,8 +1,7 @@
namespace BlazorShared.Models
namespace BlazorShared.Models;
public abstract class LookupData
{
public abstract class LookupData
{
public int Id { get; set; }
public string Name { get; set; }
}
}

View File

@@ -1,10 +1,9 @@
using System.Collections.Generic;
namespace BlazorShared.Models
namespace BlazorShared.Models;
public class PagedCatalogItemResponse
{
public class PagedCatalogItemResponse
{
public List<CatalogItem> CatalogItems { get; set; } = new List<CatalogItem>();
public int PageCount { get; set; } = 0;
}
}

View File

@@ -1,12 +1,12 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
using System.Linq;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.Infrastructure.Data
namespace Microsoft.eShopWeb.Infrastructure.Data;
public class BasketQueryService : IBasketQueryService
{
public class BasketQueryService : IBasketQueryService
{
private readonly CatalogContext _dbContext;
public BasketQueryService(CatalogContext dbContext)
@@ -23,5 +23,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
return totalItems;
}
}
}

View File

@@ -1,14 +1,13 @@
using Microsoft.EntityFrameworkCore;
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
using System.Reflection;
namespace Microsoft.eShopWeb.Infrastructure.Data
namespace Microsoft.eShopWeb.Infrastructure.Data;
public class CatalogContext : DbContext
{
public class CatalogContext : DbContext
{
public CatalogContext(DbContextOptions<CatalogContext> options) : base(options)
{
}
@@ -26,5 +25,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
base.OnModelCreating(builder);
builder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
}
}
}

View File

@@ -1,14 +1,14 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.Extensions.Logging;
using System;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Entities;
using Microsoft.Extensions.Logging;
namespace Microsoft.eShopWeb.Infrastructure.Data
namespace Microsoft.eShopWeb.Infrastructure.Data;
public class CatalogContextSeed
{
public class CatalogContextSeed
{
public static async Task SeedAsync(CatalogContext catalogContext,
ILoggerFactory loggerFactory, int retry = 0)
{
@@ -97,5 +97,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data
new(2,5, "Prism White TShirt", "Prism White TShirt", 12, "http://catalogbaseurltobereplaced/images/products/12.png")
};
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class BasketConfiguration : IEntityTypeConfiguration<Basket>
{
public class BasketConfiguration : IEntityTypeConfiguration<Basket>
{
public void Configure(EntityTypeBuilder<Basket> builder)
{
var navigation = builder.Metadata.FindNavigation(nameof(Basket.Items));
@@ -15,5 +15,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
.IsRequired()
.HasMaxLength(256);
}
}
}

View File

@@ -2,15 +2,14 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities.BasketAggregate;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class BasketItemConfiguration : IEntityTypeConfiguration<BasketItem>
{
public class BasketItemConfiguration : IEntityTypeConfiguration<BasketItem>
{
public void Configure(EntityTypeBuilder<BasketItem> builder)
{
builder.Property(bi => bi.UnitPrice)
.IsRequired(true)
.HasColumnType("decimal(18,2)");
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class CatalogBrandConfiguration : IEntityTypeConfiguration<CatalogBrand>
{
public class CatalogBrandConfiguration : IEntityTypeConfiguration<CatalogBrand>
{
public void Configure(EntityTypeBuilder<CatalogBrand> builder)
{
builder.HasKey(ci => ci.Id);
@@ -18,5 +18,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
.IsRequired()
.HasMaxLength(100);
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class CatalogItemConfiguration : IEntityTypeConfiguration<CatalogItem>
{
public class CatalogItemConfiguration : IEntityTypeConfiguration<CatalogItem>
{
public void Configure(EntityTypeBuilder<CatalogItem> builder)
{
builder.ToTable("Catalog");
@@ -33,5 +33,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
.WithMany()
.HasForeignKey(ci => ci.CatalogTypeId);
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class CatalogTypeConfiguration : IEntityTypeConfiguration<CatalogType>
{
public class CatalogTypeConfiguration : IEntityTypeConfiguration<CatalogType>
{
public void Configure(EntityTypeBuilder<CatalogType> builder)
{
builder.HasKey(ci => ci.Id);
@@ -18,5 +18,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
.IsRequired()
.HasMaxLength(100);
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class OrderConfiguration : IEntityTypeConfiguration<Order>
{
public class OrderConfiguration : IEntityTypeConfiguration<Order>
{
public void Configure(EntityTypeBuilder<Order> builder)
{
var navigation = builder.Metadata.FindNavigation(nameof(Order.OrderItems));
@@ -40,5 +40,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
.IsRequired();
});
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Microsoft.eShopWeb.ApplicationCore.Entities.OrderAggregate;
namespace Microsoft.eShopWeb.Infrastructure.Data.Config
namespace Microsoft.eShopWeb.Infrastructure.Data.Config;
public class OrderItemConfiguration : IEntityTypeConfiguration<OrderItem>
{
public class OrderItemConfiguration : IEntityTypeConfiguration<OrderItem>
{
public void Configure(EntityTypeBuilder<OrderItem> builder)
{
builder.OwnsOne(i => i.ItemOrdered, io =>
@@ -21,5 +21,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Config
.IsRequired(true)
.HasColumnType("decimal(18,2)");
}
}
}

View File

@@ -1,12 +1,11 @@
using Ardalis.Specification.EntityFrameworkCore;
using Microsoft.eShopWeb.ApplicationCore.Interfaces;
namespace Microsoft.eShopWeb.Infrastructure.Data
namespace Microsoft.eShopWeb.Infrastructure.Data;
public class EfRepository<T> : RepositoryBase<T>, IReadRepository<T>, IRepository<T> where T : class, IAggregateRoot
{
public class EfRepository<T> : RepositoryBase<T>, IReadRepository<T>, IRepository<T> where T : class, IAggregateRoot
{
public EfRepository(CatalogContext dbContext) : base(dbContext)
{
}
}
}

View File

@@ -1,12 +1,11 @@
namespace Microsoft.eShopWeb.Infrastructure.Data
namespace Microsoft.eShopWeb.Infrastructure.Data;
public class FileItem
{
public class FileItem
{
public string FileName { get; set; }
public string Url { get; set; }
public long Size { get; set; }
public string Ext { get; set; }
public string Type { get; set; }
public string DataBase64 { get; set; }
}
}

View File

@@ -1,10 +1,10 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations;
public partial class InitialModel : Migration
{
public partial class InitialModel : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateSequence(
@@ -203,5 +203,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
migrationBuilder.DropSequence(
name: "catalog_type_hilo");
}
}
}

View File

@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations;
public partial class FixBuyerId : Migration
{
public partial class FixBuyerId : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
@@ -49,5 +49,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Data.Migrations
oldType: "nvarchar(256)",
oldMaxLength: 256);
}
}
}

View File

@@ -2,10 +2,10 @@
using Microsoft.EntityFrameworkCore;
namespace Microsoft.eShopWeb.Infrastructure.Identity
namespace Microsoft.eShopWeb.Infrastructure.Identity;
public class AppIdentityDbContext : IdentityDbContext<ApplicationUser>
{
public class AppIdentityDbContext : IdentityDbContext<ApplicationUser>
{
public AppIdentityDbContext(DbContextOptions<AppIdentityDbContext> options)
: base(options)
{
@@ -18,6 +18,4 @@ namespace Microsoft.eShopWeb.Infrastructure.Identity
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
}
}
}

Some files were not shown because too many files have changed in this diff Show More