Ejemplo n.º 1
0
 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
     });
 }
Ejemplo n.º 2
0
        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
            });
        }
Ejemplo n.º 3
0
        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));
 }