public async Task <CreateBrandResponse> AddAsync(CreateBrandRequest brand) { var brandValidatorResult = new CreateBrandValidator().Validate(brand); var errorResult = new List <BaseResponse <CreateBrandResponse, ErrorsResponse> >(); //errorResult.AddRange(brandValidatorResult.Errors.Select(p => new BaseResponse<CreateBrandResponse, ErrorsResponse>().Error.AddError(p.ErrorMessage))); if (!brandValidatorResult.IsValid) { var response = _mapper.Map <CreateBrandResponse>(errorResult); return(response); } var obj = new Brand() { Id = Guid.NewGuid(), Name = brand.Name, }; await _brandRepository.AddAsync(obj); var result = _mapper.Map <CreateBrandResponse>(obj); return(result); }
public EfCreateBrandCommand(WatchesContext context, CreateBrandValidator validator) { _context = context; _validator = validator; }
public EfCreateBrandCommand(PerfumeContext context, CreateBrandValidator validator, IMapper mapper) { _context = context; _validator = validator; _mapper = mapper; }