public bool UpdateGig(int id, GigUpdateResource gig) { using (var context = new OneOffEntities()) { var entity = context .Gigs .SingleOrDefault(e => e.GigId == id); entity.Date = gig.Date; entity.PostalCode = gig.PostalCode; return(context.SaveChanges() == 1); } }
public IHttpActionResult PutGig(int id, GigUpdateResource gig) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var gigService = new GigService(); if (!gigService.UpdateGig(id, gig)) { return(InternalServerError()); } return(Ok()); }