public IHttpActionResult Delete(int id) { var problem = this.Data.UrgentProblems.Find(id); if (problem == null) { return(NotFound()); } var model = new UrgentProblemDataModel(problem); this.Data.UrgentProblems.Delete(problem); this.Data.SaveChanges(); return(Ok(model)); }
public IHttpActionResult Update(int id, UrgentProblemDataModel model) { var problem = this.Data.UrgentProblems.Find(id); if (problem == null) { return(NotFound()); } problem.Text = model.Text; problem.Status = model.Status; problem.PostDate = model.PostDate; problem.EndDate = model.EndDate; this.Data.SaveChanges(); model.Id = problem.Id; return(Ok(model)); }
public IHttpActionResult Create(UrgentProblemDataModel model) { model.UserId = User.Identity.GetUserId(); model.UserName = User.Identity.GetUserName(); var problem = new UrgentProblem { Text = model.Text, PostDate = model.PostDate, EndDate = model.EndDate, UserId = model.UserId, Status = model.Status, }; this.Data.UrgentProblems.Add(problem); this.Data.SaveChanges(); model.Id = problem.Id; return Ok(model); }
public IHttpActionResult Create(UrgentProblemDataModel model) { model.UserId = User.Identity.GetUserId(); model.UserName = User.Identity.GetUserName(); var problem = new UrgentProblem { Text = model.Text, PostDate = model.PostDate, EndDate = model.EndDate, UserId = model.UserId, Status = model.Status, }; this.Data.UrgentProblems.Add(problem); this.Data.SaveChanges(); model.Id = problem.Id; return(Ok(model)); }
public IHttpActionResult Update(int id, UrgentProblemDataModel model) { var problem = this.Data.UrgentProblems.Find(id); if (problem == null) { return NotFound(); } problem.Text = model.Text; problem.Status = model.Status; problem.PostDate = model.PostDate; problem.EndDate = model.EndDate; this.Data.SaveChanges(); model.Id = problem.Id; return Ok(model); }
public IHttpActionResult Delete(int id) { var problem = this.Data.UrgentProblems.Find(id); if (problem == null) { return NotFound(); } var model = new UrgentProblemDataModel(problem); this.Data.UrgentProblems.Delete(problem); this.Data.SaveChanges(); return Ok(model); }