public async Task <IActionResult> PutProductWithDefect(int id, PublicApi.v1.DTO.ProductWithDefect productWithDefect) { if (!ModelState.IsValid || id != productWithDefect.Id) { return(BadRequest()); } _bll.ProductsWithDefect.Update(ProductWithDefectMapper.MapFromExternal(productWithDefect)); await _bll.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <PublicApi.v1.DTO.ProductWithDefect> > PostProductWithDefect(PublicApi.v1.DTO.ProductWithDefect productWithDefect) { if (!ModelState.IsValid) { return(BadRequest()); } productWithDefect = PublicApi.v1.Mappers.ProductWithDefectMapper .MapFromBLL(await _bll.ProductsWithDefect.AddAsync(PublicApi.v1.Mappers.ProductWithDefectMapper.MapFromExternal(productWithDefect))); await _bll.SaveChangesAsync(); productWithDefect = PublicApi.v1.Mappers.ProductWithDefectMapper.MapFromBLL( _bll.ProductsWithDefect.GetUpdatesAfterUOWSaveChanges(PublicApi.v1.Mappers.ProductWithDefectMapper.MapFromExternal(productWithDefect))); return(CreatedAtAction("GetProductWithDefect", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = productWithDefect.Id }, productWithDefect)); }