public IHttpActionResult Put(PostingUpdate model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } PostingService postingService = CreatePostingService(); if (!postingService.UpdatePosting(model)) { return(InternalServerError()); } return(Ok()); }
public bool UpdatePosting(PostingUpdate model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx.PostingTable.Single(e => e.PostID == model.PostID && e.UserID == _userID); entity.Title = model.Title; entity.Details = model.Details; entity.Address = model.Address; entity.City = model.City; entity.State = model.State; entity.NameOfProvider = model.NameOfProvider; entity.Category = model.Category; entity.DateAvailable = model.DateAvailable; entity.IsCompleted = model.IsCompleted; return(ctx.SaveChanges() == 1); } }