public IHttpActionResult Post(ErrorCreate error) { if (!ModelState.IsValid) { return(BadRequest($"Your ModelState is invalid and set to {ModelState}")); } var service = CreateErrorService(); if (!service.CreateError(error)) { return(InternalServerError()); } return(Ok("Your error has been posted.")); }
public bool CreateError(ErrorCreate model) { var entity = new Error() { OwnerId = _userId, Title = model.Title, Resolved = model.Resolved, ProjectId = model.ProjectId, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Errors.Add(entity); return(ctx.SaveChanges() == 1); } }