public async Task <IActionResult> PutProductCompany(int id, v1_0_DTO.ProductCompany productCompany) { if (id != productCompany.Id) { return(BadRequest()); } _bll.ProductCompanies.Update(v1_0_Mapper.ProductCompanyMapper.MapFromExternal(productCompany)); await _bll.SaveChangesAsync(); return(NoContent()); }
public static internalDTO.ProductCompany MapFromExternal(externalDTO.ProductCompany productCompany) { var res = productCompany == null ? null : new internalDTO.ProductCompany { Id = productCompany.Id, ProductId = productCompany.ProductId, Product = ProductMapper.MapFromExternal(productCompany.Product), CompanyId = productCompany.CompanyId, Company = CompanyMapper.MapFromExternal(productCompany.Company) }; return(res); }
public async Task <ActionResult <v1_0_DTO.ProductCompany> > PostProductCompany(v1_0_DTO.ProductCompany productCompany) { productCompany = v1_0_Mapper.ProductCompanyMapper.MapFromBLL( await _bll.ProductCompanies.AddAsync(v1_0_Mapper.ProductCompanyMapper.MapFromExternal(productCompany))); await _bll.SaveChangesAsync(); productCompany = v1_0_Mapper.ProductCompanyMapper.MapFromBLL( _bll.ProductCompanies.GetUpdatesAfterUOWSaveChanges( v1_0_Mapper.ProductCompanyMapper.MapFromExternal(productCompany))); return(CreatedAtAction("GetProductCompany", new { version = HttpContext.GetRequestedApiVersion().ToString(), id = productCompany.Id }, productCompany)); }