public IHttpActionResult Put(CampusEdit campus) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_campusService.UpdateCampus(campus)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateCampus(CampusEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Campuses .Single(e => e.CampusId == model.CampusId); entity.Name = model.Name; entity.Address = model.Address; entity.PhoneNumber = model.PhoneNumber; return(ctx.SaveChanges() == 1); } }