diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj index 54a6f1d4b..757d869e2 100644 --- a/src/Application/Application.csproj +++ b/src/Application/Application.csproj @@ -7,16 +7,16 @@ latest - + - + - - + + - + diff --git a/src/Application/Features/Brands/Commands/Import/ImportBrandsCommand.cs b/src/Application/Features/Brands/Commands/Import/ImportBrandsCommand.cs index 3d621cc0f..77d965bbe 100644 --- a/src/Application/Features/Brands/Commands/Import/ImportBrandsCommand.cs +++ b/src/Application/Features/Brands/Commands/Import/ImportBrandsCommand.cs @@ -61,12 +61,13 @@ public async Task> Handle(ImportBrandsCommand request, CancellationT var importedBrands = result.Data; var errors = new List(); var errorsOccurred = false; + var validatedBrands = new List(); foreach (var brand in importedBrands) { var validationResult = await _addBrandValidator.ValidateAsync(_mapper.Map(brand), cancellationToken); if (validationResult.IsValid) { - await _unitOfWork.Repository().AddAsync(brand); + validatedBrands.Add(brand); } else { @@ -80,6 +81,7 @@ public async Task> Handle(ImportBrandsCommand request, CancellationT return await Result.FailAsync(errors); } + await _unitOfWork.Repository().AddRangeAsync(validatedBrands.ToArray()); await _unitOfWork.CommitAndRemoveCache(cancellationToken, ApplicationConstants.Cache.GetAllBrandsCacheKey); return await Result.SuccessAsync(result.Data.Count(), result.Messages[0]); } diff --git a/src/Application/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommand.cs b/src/Application/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommand.cs index 130aecbf4..15051945f 100644 --- a/src/Application/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommand.cs +++ b/src/Application/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommand.cs @@ -1,9 +1,4 @@ #nullable enable -using System; -using System.ComponentModel.DataAnnotations; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; using AutoMapper; using BlazorHero.CleanArchitecture.Application.Interfaces.Repositories; using BlazorHero.CleanArchitecture.Domain.Contracts; @@ -13,6 +8,11 @@ using MediatR; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Localization; +using System; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; namespace BlazorHero.CleanArchitecture.Application.Features.ExtendedAttributes.Commands.AddEdit { @@ -47,6 +47,31 @@ public class AddEditExtendedAttributeCommand DateTime = date?.Date.Add(time ?? new TimeSpan(0, 0, 0)); public string? Json { get; set; } diff --git a/src/Application/Interfaces/Repositories/IRepositoryAsync.cs b/src/Application/Interfaces/Repositories/IRepositoryAsync.cs index a371db1de..055df2284 100644 --- a/src/Application/Interfaces/Repositories/IRepositoryAsync.cs +++ b/src/Application/Interfaces/Repositories/IRepositoryAsync.cs @@ -17,6 +17,8 @@ public interface IRepositoryAsync where T : class, IEntity Task AddAsync(T entity); + Task AddRangeAsync(params T[] entities); + Task UpdateAsync(T entity); Task DeleteAsync(T entity); diff --git a/src/Application/Validators/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommandValidator.cs b/src/Application/Validators/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommandValidator.cs index 35e93f855..0036d4ed6 100644 --- a/src/Application/Validators/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommandValidator.cs +++ b/src/Application/Validators/Features/ExtendedAttributes/Commands/AddEdit/AddEditExtendedAttributeCommandValidator.cs @@ -41,6 +41,7 @@ IStringLocalizer localizer When(request => request.Type == EntityExtendedAttributeType.DateTime, () => { RuleFor(request => request.DateTime).NotNull().WithMessage(x => string.Format(localizer["DateTime value is required using {0} type!"], x.Type.ToString())); + RuleFor(request => request.Date).NotNull().WithMessage(x => string.Format(localizer["DateTime value is required using {0} type!"], x.Type.ToString())); }); When(request => request.Type == EntityExtendedAttributeType.Json, () => diff --git a/src/Client.Infrastructure/Client.Infrastructure.csproj b/src/Client.Infrastructure/Client.Infrastructure.csproj index 58c6f184c..0c58f400d 100644 --- a/src/Client.Infrastructure/Client.Infrastructure.csproj +++ b/src/Client.Infrastructure/Client.Infrastructure.csproj @@ -7,13 +7,13 @@ latest - + - - - - - + + + + + diff --git a/src/Client/Client.csproj b/src/Client/Client.csproj index 870a08e9d..1a180acf8 100644 --- a/src/Client/Client.csproj +++ b/src/Client/Client.csproj @@ -14,18 +14,18 @@ - - - - + + + + - - - + + + - - + + diff --git a/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor b/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor index 1779bbbde..337c082dc 100644 --- a/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor +++ b/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor @@ -64,20 +64,10 @@ else if (AddEditExtendedAttributeModel.Type == EntityExtendedAttributeType.DateTime) { - - - @_localizer["Clear"] - @_localizer["Cancel"] - @_localizer["Ok"] - + - - - @_localizer["Clear"] - @_localizer["Cancel"] - @_localizer["Ok"] - + } diff --git a/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor.cs b/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor.cs index a08838c64..ce16de151 100644 --- a/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor.cs +++ b/src/Client/Shared/Components/AddEditExtendedAttributeModal.razor.cs @@ -17,7 +17,6 @@ public class AddEditExtendedAttributeModalLocalization { // for localization } - public partial class AddEditExtendedAttributeModal where TEntity : AuditableEntity, IEntityWithExtendedAttributes, IEntity where TExtendedAttribute : AuditableEntityExtendedAttribute, IEntity @@ -34,8 +33,7 @@ public partial class AddEditExtendedAttributeModal AddEditExtendedAttributeModel.Date == null; public void Cancel() { MudDialog.Cancel(); @@ -57,7 +55,6 @@ private async Task SaveAsync() break; case EntityExtendedAttributeType.DateTime: AddEditExtendedAttributeModel.DateTime ??= new DateTime(0, 0, 0); - AddEditExtendedAttributeModel.DateTime += _time ?? new TimeSpan(0, 0, 0); AddEditExtendedAttributeModel.Decimal = null; AddEditExtendedAttributeModel.Text = null; AddEditExtendedAttributeModel.Json = null; diff --git a/src/Client/wwwroot/index.html b/src/Client/wwwroot/index.html index 31942e45f..46ebe3440 100644 --- a/src/Client/wwwroot/index.html +++ b/src/Client/wwwroot/index.html @@ -8,7 +8,7 @@ - + @@ -68,6 +68,6 @@ - + \ No newline at end of file diff --git a/src/Infrastructure.Shared/Infrastructure.Shared.csproj b/src/Infrastructure.Shared/Infrastructure.Shared.csproj index 7c16e6a52..b482f8450 100644 --- a/src/Infrastructure.Shared/Infrastructure.Shared.csproj +++ b/src/Infrastructure.Shared/Infrastructure.Shared.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -11,7 +11,7 @@ - - + + diff --git a/src/Infrastructure/Infrastructure.csproj b/src/Infrastructure/Infrastructure.csproj index 5bb39c042..7d14bed8b 100644 --- a/src/Infrastructure/Infrastructure.csproj +++ b/src/Infrastructure/Infrastructure.csproj @@ -19,17 +19,17 @@ --> - + - - - - + + + + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Infrastructure/Repositories/RepositoryAsync.cs b/src/Infrastructure/Repositories/RepositoryAsync.cs index 930d6375f..db6c78d76 100644 --- a/src/Infrastructure/Repositories/RepositoryAsync.cs +++ b/src/Infrastructure/Repositories/RepositoryAsync.cs @@ -25,6 +25,11 @@ public async Task AddAsync(T entity) return entity; } + public async Task AddRangeAsync(params T[] entities) + { + await _dbContext.Set().AddRangeAsync(entities); + } + public Task DeleteAsync(T entity) { _dbContext.Set().Remove(entity); diff --git a/src/Server/Server.csproj b/src/Server/Server.csproj index ad4229d13..5ebe0af84 100644 --- a/src/Server/Server.csproj +++ b/src/Server/Server.csproj @@ -22,31 +22,25 @@ - + - - + + + - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + - + - - diff --git a/src/Shared/Shared.csproj b/src/Shared/Shared.csproj index 78583bc34..5cfe2ebe6 100644 --- a/src/Shared/Shared.csproj +++ b/src/Shared/Shared.csproj @@ -8,8 +8,8 @@ - - + +