feat(FastProductCreateDialog),refactor(Pages),refactor(Commands)
-ADD FAST PRODUCT CREATE DIALOG -Refactor page and layout and fix some responsive issues -Refactor brand and product command and return Guid in response createrelease
parent
de7a70c6c9
commit
52ccd68228
|
@ -20,8 +20,7 @@ public class PageController : ICarterModule
|
||||||
|
|
||||||
group.MapGet("slug/{pageSlug}", GetPageAsync)
|
group.MapGet("slug/{pageSlug}", GetPageAsync)
|
||||||
.WithDisplayName("Get Page")
|
.WithDisplayName("Get Page")
|
||||||
.HasApiVersion(1.0)
|
.HasApiVersion(1.0);
|
||||||
.RequireAuthorization(builder => builder.AddAuthenticationSchemes("Bearer").RequireAuthenticatedUser().RequireClaim(CustomClaimType.Permission, ApplicationPermission.ViewPages, ApplicationPermission.ManagePages));
|
|
||||||
|
|
||||||
group.MapGet("type/{type}", GetPageByTypeAsync)
|
group.MapGet("type/{type}", GetPageByTypeAsync)
|
||||||
.WithDisplayName("Get Page")
|
.WithDisplayName("Get Page")
|
||||||
|
|
|
@ -99,12 +99,12 @@ public class SeedController : ICarterModule
|
||||||
Dictionary<int, Guid> brands = new Dictionary<int, Guid>();
|
Dictionary<int, Guid> brands = new Dictionary<int, Guid>();
|
||||||
var baseBrand = await mediator.Send(new CreateBrandCommand("بدون برند","NoBrand", "محصولات بدون برند", false,string.Empty,
|
var baseBrand = await mediator.Send(new CreateBrandCommand("بدون برند","NoBrand", "محصولات بدون برند", false,string.Empty,
|
||||||
new List<StorageFileSDto>()), cancellationToken);
|
new List<StorageFileSDto>()), cancellationToken);
|
||||||
brands.Add(0, baseBrand.Id);
|
brands.Add(0, baseBrand);
|
||||||
foreach (var requestDto in request)
|
foreach (var requestDto in request)
|
||||||
{
|
{
|
||||||
var sDto = await mediator.Send(new CreateBrandCommand(requestDto.Name,string.Empty, requestDto.Description, false,
|
var sDto = await mediator.Send(new CreateBrandCommand(requestDto.Name,string.Empty, requestDto.Description, false,
|
||||||
string.Empty, new List<StorageFileSDto>()), cancellationToken);
|
string.Empty, new List<StorageFileSDto>()), cancellationToken);
|
||||||
brands.Add(requestDto.BaseBrandId,sDto.Id);
|
brands.Add(requestDto.BaseBrandId,sDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypedResults.Ok(brands);
|
return TypedResults.Ok(brands);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
namespace Netina.Domain.CommandQueries.Commands;
|
namespace Netina.Domain.CommandQueries.Commands;
|
||||||
|
|
||||||
public sealed record CreateBrandCommand(string PersianName,string EnglishName, string Description , bool HasSpecialPage , string PageUrl, List<StorageFileSDto> Files) : IRequest<BrandSDto>;
|
public sealed record CreateBrandCommand(string PersianName,string EnglishName, string Description , bool HasSpecialPage , string PageUrl, List<StorageFileSDto> Files) : IRequest<Guid>;
|
||||||
|
|
||||||
public sealed record UpdateBrandCommand(Guid Id,string PersianName, string EnglishName, string Description, bool HasSpecialPage, string PageUrl, List<StorageFileSDto> Files) : IRequest<bool>;
|
public sealed record UpdateBrandCommand(Guid Id,string PersianName, string EnglishName, string Description, bool HasSpecialPage, string PageUrl, List<StorageFileSDto> Files) : IRequest<bool>;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
namespace Netina.Repository.Handlers.Brands;
|
namespace Netina.Repository.Handlers.Brands;
|
||||||
|
|
||||||
public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , BrandSDto>
|
public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , Guid>
|
||||||
{
|
{
|
||||||
private readonly IRepositoryWrapper _repositoryWrapper;
|
private readonly IRepositoryWrapper _repositoryWrapper;
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , Br
|
||||||
{
|
{
|
||||||
_repositoryWrapper = repositoryWrapper;
|
_repositoryWrapper = repositoryWrapper;
|
||||||
}
|
}
|
||||||
public async Task<BrandSDto> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
|
public async Task<Guid> Handle(CreateBrandCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var ent = Brand.Create(request.PersianName,request.EnglishName, request.Description, request.HasSpecialPage, request.PageUrl);
|
var ent = Brand.Create(request.PersianName,request.EnglishName, request.Description, request.HasSpecialPage, request.PageUrl);
|
||||||
foreach (var file in request.Files)
|
foreach (var file in request.Files)
|
||||||
|
@ -19,6 +19,6 @@ public class CreateBrandCommandHandler : IRequestHandler<CreateBrandCommand , Br
|
||||||
}
|
}
|
||||||
_repositoryWrapper.SetRepository<Brand>().Add(ent);
|
_repositoryWrapper.SetRepository<Brand>().Add(ent);
|
||||||
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
await _repositoryWrapper.SaveChangesAsync(cancellationToken);
|
||||||
return ent.AdaptToSDto();
|
return ent.Id;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,10 +10,5 @@ public class CreateBrandCommandValidator : AbstractValidator<CreateBrandCommand>
|
||||||
.NotNull()
|
.NotNull()
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithMessage("نام فارسی برند را وارد کنید");
|
.WithMessage("نام فارسی برند را وارد کنید");
|
||||||
|
|
||||||
RuleFor(r => r.EnglishName)
|
|
||||||
.NotNull()
|
|
||||||
.NotEmpty()
|
|
||||||
.WithMessage("نام انگلیسی برند را وارد کنید");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -11,15 +11,15 @@ public class CreateProductCommandValidator : AbstractValidator<CreateProductComm
|
||||||
.NotEmpty()
|
.NotEmpty()
|
||||||
.WithMessage("نام فارسی کالا مورد نظر را وارد کنید");
|
.WithMessage("نام فارسی کالا مورد نظر را وارد کنید");
|
||||||
|
|
||||||
RuleFor(d => d.EnglishName)
|
//RuleFor(d => d.EnglishName)
|
||||||
.NotNull()
|
// .NotNull()
|
||||||
.NotEmpty()
|
// .NotEmpty()
|
||||||
.WithMessage("نام انگلیسی کالا مورد نظر را وارد کنید");
|
// .WithMessage("نام انگلیسی کالا مورد نظر را وارد کنید");
|
||||||
|
|
||||||
RuleFor(d => d.Summery)
|
//RuleFor(d => d.Summery)
|
||||||
.NotNull()
|
// .NotNull()
|
||||||
.NotEmpty()
|
// .NotEmpty()
|
||||||
.WithMessage("توضیحات کوتاه کالا مورد نظر را وارد کنید");
|
// .WithMessage("توضیحات کوتاه کالا مورد نظر را وارد کنید");
|
||||||
|
|
||||||
RuleFor(d => d.CategoryId)
|
RuleFor(d => d.CategoryId)
|
||||||
.NotEqual(Guid.Empty)
|
.NotEqual(Guid.Empty)
|
||||||
|
|
Loading…
Reference in New Issue