public IHttpActionResult PutCohort(CohortEdit cohort) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateCohortService(); if (!service.UpdateCohort(cohort)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateCohort(CohortEdit model) { using (var context = new ApplicationDbContext()) { var entity = context .Cohorts .Single(e => e.Id == model.Id); entity.Course = model.Course; entity.Id = model.Id; entity.FullTime = model.FullTime; entity.StartDateUtc = model.StartDateUtc; entity.EndDateUtc = model.EndDateUtc; return(context.SaveChanges() == 1); } }