public void AddComment(Comment comment) { using (MsgContext context = new MsgContext()) { var user = new User {Id = comment.UserId}; comment.User = context.Users.Attach(user); context.Comments.Add(comment); context.SaveChanges(); } }
public JsonResult<BaseResponse> AddComment(CommentViewModel comment) { BaseResponse res = new BaseResponse(); Comment c = new Comment() { Text = comment.Text, Msg = comment.Msg, Project = comment.Project, Sprint = comment.Sprint, UserId = comment.User }; _msgService.AddComment(c); res = new BaseResponse { Status = Status.Ok, Description = "Success" }; return Json(res); }