public IHttpActionResult Put(RoutineEdit routine) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateRoutineService(); if (!service.UpdateRoutine(routine)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateRoutine(RoutineEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Routines .Single(e => e.RoutineId == model.RoutineID && e.UserId == _userId); entity.RoutineName = model.RoutineName; entity.RoutineDescription = model.RoutineDescription; return(ctx.SaveChanges() == 1); } }