public UrgentProblemDataModel(UrgentProblem problem) { this.Id = problem.Id; this.PostDate = problem.PostDate; this.EndDate = problem.EndDate; this.Status = problem.Status; this.Text = problem.Text; this.UserId = problem.UserId; }
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)); }