private static RefactorThis.Models.Product Map(CreateOrUpdateProductRequest dtoProduct) { return(new RefactorThis.Models.Product { Name = dtoProduct.Name, Description = dtoProduct.Description, Price = dtoProduct.Price, DeliveryPrice = dtoProduct.DeliveryPrice }); }
public async Task <ProductCreatedResponse> CreateProductAsync(CreateOrUpdateProductRequest body) { _validator.ValidateRequest(body); var dbProduct = Map(body); var productId = await _repository.CreateProduct(dbProduct); return(new ProductCreatedResponse { Id = productId }); }
public async Task UpdateProductAsync(Guid id, CreateOrUpdateProductRequest body) { _validator.ValidateRequest(body); var dbProduct = Map(body); var numberOfRowsAffected = await _repository.UpdateProduct(id, dbProduct); if (numberOfRowsAffected == 0) { throw new NotFoundException($"No product found with Id: {id}"); } }
public System.Threading.Tasks.Task UpdateProduct(System.Guid id, [Microsoft.AspNetCore.Mvc.FromBody] CreateOrUpdateProductRequest body) { return(_implementation.UpdateProductAsync(id, body)); }
public System.Threading.Tasks.Task <ProductCreatedResponse> CreateProduct([Microsoft.AspNetCore.Mvc.FromBody] CreateOrUpdateProductRequest body) { return(_implementation.CreateProductAsync(body)); }