public async Task <IActionResult> PutProductSold(int id, PublicApi.v1.DTO.ProductSold productSold) { if (!ModelState.IsValid || id != productSold.Id) { return(BadRequest()); } if (await _bll.ProductsSold.EditProductInSale(id, productSold.ProductId, ProductSoldMapper.MapFromExternal(productSold))) { return(NoContent()); } return(BadRequest()); }
public async Task <ActionResult <ProductSold> > PostProductSold(PublicApi.v1.DTO.ProductSold productSold) { if (!ModelState.IsValid) { return(BadRequest()); } if (await _bll.ProductsSold.AddProductToSale(productSold.ProductId, ProductSoldMapper.MapFromExternal(productSold))) { await _bll.SaveChangesAsync(); productSold = PublicApi.v1.Mappers.ProductSoldMapper.MapFromBLL( _bll.ProductsSold.GetUpdatesAfterUOWSaveChanges( PublicApi.v1.Mappers.ProductSoldMapper.MapFromExternal(productSold))); return(CreatedAtAction("GetProductSold", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = productSold.Id }, productSold)); } return(BadRequest()); }