public IHttpActionResult Put(AttendeeEdit attendee) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateAttendeeService(); if (!service.UpdateAttendee(attendee)) { return(InternalServerError()); } return(Ok()); }
//Update public bool UpdateAttendee(AttendeeEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Attendees .Single(e => e.EventId == model.EventId && e.AttendeeId == model.AttendeeId); entity.FirstName = model.FirstName; entity.LastName = model.LastName; entity.EventId = model.EventId; entity.AttendeeId = model.AttendeeId; return(ctx.SaveChanges() == 1); } }