public IHttpActionResult Put(BuildErrorEdit buildError) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateBuildErrorService(); if (!service.UpdateBuildError(buildError)) { return(InternalServerError()); } return(Ok("The build error has been updated!")); }
public bool UpdateBuildError(BuildErrorEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .BuildErrors .Single(e => e.ErrorId == model.ErrorId && e.OwnerId == _userId); entity.Title = model.Title; entity.Resolved = model.Resolved; entity.LineNumber = model.LineNumber; entity.BuildErrorMessage = model.BuildErrorMessage; entity.ModifiedUtc = DateTimeOffset.Now; return(ctx.SaveChanges() == 1); } }