public void AddStock([FromBody] AddStockRequest request) { var product = repo.Get(p => p.Id == request.Id); product.Stock += request.Amount; repo.UpdateOne(product); }
public static AddStockCommand ToServiceCommand(AddStockRequest apiRequest) { if (apiRequest == null) { return(null); } return(new AddStockCommand(apiRequest.ProductId, apiRequest.Quantity)); }
public async Task <ActionResult <Stock> > AddStock(Guid wholesalerId, [FromBody] AddStockRequest addStockRequest) { addStockRequest.WholesalerId = wholesalerId; var result = await _wholesalerService.AddStockAsync(_mapper.Map <Stock>(addStockRequest)); if (result.IsFailure && result.ErrorCode == ResultErrorCode.Validation) { return(UnprocessableEntity(result.ErrorMessage)); } if (result.IsFailure && result.ErrorCode == ResultErrorCode.NotFound) { return(NotFound(result.ErrorMessage)); } return(Ok()); }