public IHttpActionResult Get() { ReplyService service = CreateReplyService(); var replies = service.GetReplies(); return(Ok(replies)); }
public IHttpActionResult Get() { ReplyService replyService = CreateReplyService(); var comments = replyService.GetReplys(); return(Ok(comments)); }
public async Task CountOfRepliesShouldBeOne() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()); var context = new ApplicationDbContext(options.Options); await context.Users.AddAsync(new ApplicationUser() { Id = "1" }); var repository = new EfDeletableEntityRepository <ReplyOnPostComment>(context); var service = new ReplyService(repository); var model = new AddReplyInputModel() { UserId = "1", CommentId = 1, Description = "test reply", PostId = "1", }; var replyId = await service.AddReplyToPostCommentAsync(model); var actual = await service.GetReplyByIdAsync <ReplyResponseModel>(replyId); Assert.IsType <ReplyResponseModel>(actual); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); int userId = Int32.Parse(context.Request["reply.user.id"]); int TopicId = Int32.Parse(context.Request["reply.topic.id"]); string content = context.Request["reply.content"]; Reply reply = new Reply(); reply.t_u_id = userId; reply.t_t_id = TopicId; reply.content = content; reply.publishtime = DateTime.Now; ReplyService replyService = new ReplyService(); bool b; if (replyService.Add(reply) > 0) { b = true; } else { b = false; } context.Response.Write(b); context.Response.End(); }
public IHttpActionResult Get(int id) { ReplyService service = CreateReplyService(); var reply = service.GetReplyById(id); return(Ok(reply)); }
// Get reply detail by Id /// <summary> /// Get Detailed Information From Single Reply Item By ID /// </summary> /// <param name="Id"></param> /// <returns>Returns ReplyDetail Model</returns> public IHttpActionResult Get(int Id) { ReplyService replyService = CreateReplyService(); var reply = replyService.GetReplyDetail(Id); return(Ok(reply)); }
private ReplyService CreateReplyService() { var userId = User.Identity.GetUserId(); var replyService = new ReplyService(userId); return(replyService); }
/// <summary> /// 增加一条Reply数据 /// </summary> /// <param name="reply"></param> /// <param name="msg"></param> /// <returns>是否成功</returns> public static bool AddReply(Reply reply, out string msg) { ReplyService service = new ReplyService(); try { if (service.Add(reply)) { msg = ADD_SUCCESS; return(true); } else { msg = ADD_FAIL; return(false); } } catch (Exception e) { Console.WriteLine("\n异常信息:\n{0}", e.Message); msg = ADD_FAIL; return(false); } finally { service.CloseConnection(); } }
//gets all Comments public IHttpActionResult GetReply() { ReplyService ReplyService = CreateReplyService(); var Reply = ReplyService.GetReply(); return(Ok(Reply)); }
//get reply by id or by comment public IHttpActionResult GetById(int id) { ReplyService replyService = CreateReplyService(); var replies = replyService.GetRepliesbyCommentId(id); return(Ok(replies)); }
public IHttpActionResult Get(int commentId) { ReplyService replyService = CreateReplyService(); var replies = replyService.GetReplies(commentId); return(Ok(replies)); }
private ReplyService CreateReplyService() { var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ReplyService(userId); return(service); }
//get replies by comment id controller public IHttpActionResult Get(GetCommentReplies id) { ReplyService replyService = CreateReplyService(); var posts = replyService.GetComment(); return(Ok(posts)); }
public IHttpActionResult Get() { ReplyService replyService = CreateReplyService(); var reply = replyService.GetNotes(); return(Ok(reply)); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { //防止请求的page非法 if (!Int32.TryParse(Request["page"], out page)) { page = 1; } int topicid = Int32.Parse(Request["topicId"]); ReplyService replyService = new ReplyService(); ArrayList arrayList = replyService.finfTopicById(topicid, page); topic = (Topic)arrayList[0]; replyList = (List <Reply>)arrayList[1]; pageCode = (string)arrayList[2]; section = (Section)arrayList[3]; } else { } }
public void Return_PostReply_Correctly_By_PostReplyId() { //Arrange var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "Get_Post_By_Id").Options; using (var ctx = new ApplicationDbContext(options)) { ctx.PostReplies.Add(new PostReply { Id = 221, Content = "Test Reply" }); ctx.PostReplies.Add(new PostReply { Id = 111, Content = "Second Reply" }); ctx.SaveChanges(); } //Act using (var ctx = new ApplicationDbContext(options)) { var replyService = new ReplyService(ctx); var reply = replyService.GetById(221); //Assert Assert.AreEqual(reply.Content, "Test Reply"); } }
private ReplyService CreateReplyService() { var author = Guid.Parse(User.Identity.GetUserId()); var replyService = new ReplyService(author); return(replyService); }
public async Task <IHttpActionResult> GetReplyById(int id) { ReplyService service = CreateReplyService(); ReplyDetail reply = await service.GetReplyById(id); return(Ok(reply)); }
public async Task <IHttpActionResult> GetAllReplies() { ReplyService service = CreateReplyService(); List <ReplyListItem> replies = await service.GetAllReplies(); return(Ok(replies)); }
public IHttpActionResult Get(Guid authorId) { ReplyService replyService = CreateReplyService(); var replies = replyService.GetRepliesByAuthorId(authorId); return(Ok(replies)); }
public async Task <ActionResult> DisplayReplies(string questionId) { List <ReplyDTO> replies = (List <ReplyDTO>) await ReplyService.GetAll(); List <ReplyDTO> RepliesChosenFromQuestion = replies.Where(e => e.QuestionId == questionId).ToList(); return(View(RepliesChosenFromQuestion)); }
////GET BY ID public IHttpActionResult GetByCommentId(int id) { ReplyService service = CreateReplyService(); IEnumerable <ReplyListItem> comments = service.GetReplyByCommentId(id); return(Ok(comments)); }
private ReplyService CreateReplyService() { //not sure if line 16 is right var userId = Guid.Parse(User.Identity.GetUserId()); var replyService = new ReplyService(userId); return(replyService); }
public async Task Should_update_reply_and_add_event() { var options = Shared.CreateContextOptions(); var siteId = Guid.NewGuid(); var categoryId = Guid.NewGuid(); var forumId = Guid.NewGuid(); var topicId = Guid.NewGuid(); var category = new Category(categoryId, siteId, "Category", 1, Guid.NewGuid()); var forum = new Forum(forumId, categoryId, "Forum", "my-forum", "My Forum", 1); var topic = Post.CreateTopic(topicId, forumId, Guid.NewGuid(), "Title", "slug", "Content", StatusType.Published); var reply = Post.CreateReply(Guid.NewGuid(), topicId, forumId, Guid.NewGuid(), "Content", StatusType.Published); using (var dbContext = new AtlasDbContext(options)) { dbContext.Categories.Add(category); dbContext.Forums.Add(forum); dbContext.Posts.Add(topic); dbContext.Posts.Add(reply); await dbContext.SaveChangesAsync(); } using (var dbContext = new AtlasDbContext(options)) { var command = Fixture.Build <UpdateReply>() .With(x => x.Id, reply.Id) .With(x => x.SiteId, siteId) .With(x => x.ForumId, forumId) .With(x => x.TopicId, topicId) .Create(); var cacheManager = new Mock <ICacheManager>(); var createValidator = new Mock <IValidator <CreateReply> >(); var updateValidator = new Mock <IValidator <UpdateReply> >(); updateValidator .Setup(x => x.ValidateAsync(command, new CancellationToken())) .ReturnsAsync(new ValidationResult()); var sut = new ReplyService(dbContext, cacheManager.Object, createValidator.Object, updateValidator.Object); await sut.UpdateAsync(command); var updatedReply = await dbContext.Posts.FirstOrDefaultAsync(x => x.Id == command.Id); var @event = await dbContext.Events.FirstOrDefaultAsync(x => x.TargetId == command.Id); updateValidator.Verify(x => x.ValidateAsync(command, new CancellationToken())); Assert.AreEqual(command.Content, updatedReply.Content); Assert.NotNull(@event); } }
public async Task Delete_ReplyNotFound_DoesNotAttemptToDeleteReply() { A.CallTo(() => ReplyRepository.Read(1)).Returns(null as Reply); await ReplyService.Delete(1); A.CallTo(() => ReplyRepository.Delete(A <Reply> .Ignored)) .MustNotHaveHappened(); }
public DashboardController(ReviewService reviewService, CommentService commentService, ReplyService replyService, UserManager <IdentityUser> userManager, UserServices userService) { this.reviewService = reviewService; this.commentService = commentService; this.replyService = replyService; this.userManager = userManager; this.userService = userService; }
public async Task <IHttpActionResult> DeleteReply(int id) { ReplyService service = CreateReplyService(); if (!await service.DeleteReply(id)) { return(InternalServerError()); } return(Ok()); }
public async Task Read_EverythingOk_ReturnsReply() { var reply = new Reply(); A.CallTo(() => ReplyRepository.Read(1)).Returns(reply); var response = await ReplyService.Read(1); Assert.Equal(reply, response); }
public async Task Delete_EverythingOk_DeletesReply() { var reply = new Reply(); A.CallTo(() => ReplyRepository.Read(1)).Returns(reply); A.CallTo(() => User.Is(reply.UserId)).Returns(true); await ReplyService.Delete(1); A.CallTo(() => ReplyRepository.Delete(reply)) .MustHaveHappenedOnceExactly(); }
public async Task Delete_Unauthorized_DoesNotAttemptToDeleteReply() { var reply = new Reply(); A.CallTo(() => ReplyRepository.Read(1)).Returns(reply); A.CallTo(() => User.Is(reply.UserId)).Returns(false); await ReplyService.Delete(1); A.CallTo(() => ReplyRepository.Delete(A <Reply> .Ignored)) .MustNotHaveHappened(); }