public bool DeleteReply(Reply reply) { return mainPostCommandService.DeleteReply(reply); }
public virtual ActionResult AddHint(HintPostVM hintPostVm) { if (ModelState.IsValid) { Reply reply = new Reply(); reply.Content = hintPostVm.Content; reply.UserId = WebSecurity.CurrentUserId; reply.DateCreated = DateTime.Now; reply.Type = ReplyEnum.HINT; bool res = _problemCommandService.AddReply((int)hintPostVm.MainPostId, reply); if (res) { HintItemVM hintItemVm = Mapper.Map<Reply, HintItemVM>(reply); return PartialView("Partials/_AnswerItem", hintItemVm); } else { return null; } } // Model State is not valid return null; }
public bool AddReply(int problemId, Reply reply) { return mainPostCommandService.AddReply(problemId, reply); }
public bool UpdateReply(Reply reply) { return mainPostCommandService.UpdateReply(reply); }
public bool AddReply(int postId, Reply reply) { reply.MainPostId = postId; return replyRepository.Insert(reply); }
public bool UpdateReply(Reply reply) { return replyRepository.Update(reply); }
public void TestGeneralReply() { IProblemCommandService problemCommandService = ObjectFactory.GetInstance<IProblemCommandService>(); IProblemQueryService problemQueryService = ObjectFactory.GetInstance<IProblemQueryService>(); IRepository<Problem> problemRepository = ObjectFactory.GetInstance<IRepository<Problem>>(); bool res; // create test problem Problem problem = ProblemPreaparation.p; // create Reply Reply r = new Reply(); r.Content = "this is an easy reply"; r.DateCreated = DateTime.Now; r.DateModified = DateTime.Now; r.UserId = problem.UserId; r.Type = ReplyEnum.ANSWER; res = problemCommandService.AddReply(problem.Id, r); Assert.IsTrue(r.Id > 0); // retrieve Reply // Get All replies IEnumerable<Reply> replies = problemQueryService.GetAllReplies(problem.Id, ReplyEnum.ANSWER, 0, 0); bool isExist = false; foreach (Reply reply in replies) { if (reply.Id == r.Id && reply.Content == r.Content) { isExist = true; break; } } Assert.IsTrue(isExist); // update reply r.Content = "this is a very very interesting reply"; r.DateModified = DateTime.Now; res = problemCommandService.UpdateReply(r); //test update replies = problemQueryService.GetAllReplies(problem.Id, ReplyEnum.ANSWER, 0, 0); isExist = false; foreach (Reply reply in replies) { if (reply.Id == r.Id && reply.Content == r.Content && DateTime.Compare(reply.DateModified, reply.DateCreated) > 0) { isExist = true; break; } } Assert.IsTrue(isExist); // delete problem res = problemCommandService.DeleteReply(r); Assert.IsTrue(res); //test update replies = problemQueryService.GetAllReplies(problem.Id, ReplyEnum.ANSWER, 0, 0); isExist = false; foreach (Reply reply in replies) { if (reply.Id == r.Id) { isExist = true; break; } } Assert.IsFalse(isExist); ProblemPreaparation.CleanUp(); }