public IHttpActionResult Put(CompanyProfileEdit company) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCompanyProfileService(); if (!service.UpdateCompany(company)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateCompany(CompanyProfileEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Companies .Single(e => e.CompanyID == model.CompanyID); entity.CompanyID = model.CompanyID; entity.CompanyName = model.CompanyName; entity.CategoryID = model.CategoryID; return(ctx.SaveChanges() == 1); } }