public IHttpActionResult Put(UpdatePosting posting) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreatePostingService(); if (!service.UpdatePosting(posting)) { return(InternalServerError()); } return(Ok()); }
public bool UpdatePosting(UpdatePosting model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Postings .Single(e => e.PostingID == model.PostingID && e.OwnerID == _userId); entity.Title = model.Title; entity.ExpirationDateUtc = model.ExpirationDateUtc; entity.ModifiedDateUtc = DateTimeOffset.UtcNow; entity.PostingStatus = model.PostingStatus; entity.PositionType = model.PositionType; entity.HiringManager = model.HiringManager; entity.Urgent = model.Urgent; return(ctx.SaveChanges() == 1); } }