public void CreateComment(Comment comment) { using (var uow = new UnitOfWork(_appConfigConnection)) { uow.CommentRepository.Create(comment); } }
/// <summary> /// Insert comment record /// </summary> /// <param name="comment">Comment model</param> public void Create(Comment comment) { using (var command = new SqlCommand("sp_CreateComment", _connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@CreatorId", comment.CreatorId); command.Parameters.AddWithValue("@RequestId", comment.RequestId); command.Parameters.AddWithValue("@CommentText", comment.CommentText); command.ExecuteNonQuery(); } }
public static Comment Map(SqlDataReader record) { if (record == null) throw new ArgumentNullException("record"); var commment = new Comment { Id = (int)record["Id"], CreatorId = (int)record["CreatorId"], RequestId = (int)record["RequestId"], CommentText = (string)record["CommentText"] }; return commment; }
public ActionResult AddComent(CommentModel commentModel) { if (ModelState.IsValid) { var comment = new Comment { CommentText = commentModel.CommentText, CreatorId = commentModel.CreatorId, RequestId = commentModel.RequestId }; _userBl.CreateComment(comment); return RedirectToAction("GetRequestDetails" + "/" + Convert.ToString(commentModel.RequestId), "UserProfile"); } return View(commentModel); }