public async Task <IActionResult> PutProductInCategory(int id, PublicApi.v1.DTO.ProductInCategory productInCategory) { if (!ModelState.IsValid || id != productInCategory.Id) { return(BadRequest()); } _bll.ProductsInCategory.Update(ProductInCategoryMapper.MapFromExternal(productInCategory)); await _bll.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <PublicApi.v1.DTO.ProductInCategory> > PostProductInCategory(PublicApi.v1.DTO.ProductInCategory productInCategory) { productInCategory = PublicApi.v1.Mappers.ProductInCategoryMapper .MapFromBLL(await _bll.ProductsInCategory.AddAsync(PublicApi.v1.Mappers.ProductInCategoryMapper.MapFromExternal(productInCategory))); await _bll.SaveChangesAsync(); productInCategory = PublicApi.v1.Mappers.ProductInCategoryMapper.MapFromBLL( _bll.ProductsInCategory.GetUpdatesAfterUOWSaveChanges(PublicApi.v1.Mappers.ProductInCategoryMapper.MapFromExternal(productInCategory))); return(CreatedAtAction("GetProductInCategory", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = productInCategory.Id }, productInCategory)); }