protected override void OnCreate(Bundle bundle)
 {
     base.OnCreate(bundle);
     SetContentView(Resource.Layout.Response);
     userDao = new UserDao();
     postService = new PostService();
     audioService = new SendAudioService();
     deliverPostService = new SendPostService();
     actionBar = SupportActionBar;
     actionBar.SetHomeButtonEnabled(false);
     actionBar.SetDisplayHomeAsUpEnabled(false);
     actionBar.SetDisplayUseLogoEnabled(false);
     actionBar.SetDisplayShowHomeEnabled(false);
     actionBar.Title = "Responder";
     chronometer = FindViewById<TextView>(Resource.Id.recording_lenght);
     previewRecord = FindViewById<ImageView>(Resource.Id.record_image);
     message = FindViewById<EditText>(Resource.Id.criar_topico_conteudo);
     submit = FindViewById<Button>(Resource.Id.criar_topico_submit);
     submit.Click += new System.EventHandler(submit_Click);
     record = FindViewById<ImageButton>(Resource.Id.btn_gravar);
     record.Click += new System.EventHandler(record_Click);
     ServiceLocator.Dispatcher = new DispatchAdapter(this);
     ServiceLocator.Recorder = new RecordAdapter();
     timer = new System.Timers.Timer(1000);
     timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
     timer.Enabled = true;
 }
 public DiscussionsViewModel() 
 {
     discussionDao = new DiscussionDao();
     userDao = new UserDao();
     postDao = new PostDao();
     postService = new PostService();
     discussions = discussionDao.getDiscussionsFromClass(ContextUtil.Instance.Class);
 }
示例#3
0
        public void AddPost_NullPost_FalseFlag()
        {
            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);
            bool flag = service.AddPost(null);
            Assert.IsFalse(flag);
        }
 public PostsViewModel(IAsyncPlayer player)
 {
     contextualSelection = false;
     postDao = new PostDao();
     userDao = new UserDao();
     postService = new PostService();
     discussionDao = new DiscussionDao();
     posts = new ObservableCollection<Post>(postDao.getPostsFromDiscussion(ContextUtil.Instance.Discussion));
     selectedDiscussion = discussionDao.getDiscussion(ContextUtil.Instance.Discussion);
     ContextUtil.Instance.postsBefore = selectedDiscussion.previousPosts;
     ContextUtil.Instance.postsAfter = selectedDiscussion.nextPosts;
     manager = new TTSManager(player);
 }
        public async Task Should_CreateNewPost(string test, Int64 actorId, string postsubject, string postBody)
        {
            using (SampleContext ctx = GetInputContext(test))
            {
                using (PostService svc = new PostService(ctx))
                {
                    svc.CreateNewPost(actorId, postsubject, postBody);

                    var result = await ctx.CompareTo(GetExpectedContext(test));

                    result.AreEqual.ShouldBe(true, result.ToString());
                }
            }
        }
        public async Task Should_DeletePost(string test, Int64 postId)
        {
            using (SampleContext ctx = GetInputContext(test))
            {
                using (PostService svc = new PostService(ctx))
                {
                    svc.DeletPostWithId(postId);

                    var result = await ctx.CompareTo(GetExpectedContext(test));

                    result.AreEqual.ShouldBe(true, result.ToString());
                }
            }
        }
示例#7
0
        public void AddPhoto_FailFileService_MediaNull()
        {
            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            fileService.Setup(o => o.SaveMedia(It.IsAny<string>(), It.IsAny<byte[]>())).Returns(false);

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);
            byte[] test = new byte[3];
            Media stored = service.AddPhoto(Guid.NewGuid(), "test", null);

            Assert.IsNull(stored);
        }
        public async Task Should_DeleteAnAuthor()
        {
            string test = "test32";

            using (SampleContext ctx = GetInputContext(test))
            {
                using (PostService svc = new PostService(ctx))
                {
                    svc.DeleteAuthor(3);

                    var result = await ctx.CompareTo(GetExpectedContext(test));

                    result.AreEqual.ShouldBe(true, result.ToString());
                }
            }
        }
示例#9
0
        public void AddPhoto_ValidPost_MediaStoredAndRetrived()
        {
            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            mediaService.Setup(o => o.StoreMedia(It.IsAny<Media>()));
            fileService.Setup(o => o.SaveMedia(It.IsAny<string>(), It.IsAny<byte[]>())).Returns(true);

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);
            byte[] test = new byte[3];
            Media stored = service.AddPhoto(Guid.NewGuid(), "test" ,test);

            StringAssert.StartsWith("test", stored.MediaData);
        }
        public void Should_Return_All_Posts()
        {
            using (SampleContext ctx = GetInputContext("test1"))
            {
               
                using (PostService svc = new PostService(ctx))
                {
                   
                    var allPosts = svc.GetAllPost();

                    allPosts.Count().ShouldBe(3);
                    
                }
               
            }
        }
        public async Task Should_CreateTwoPostAndDeleteOne()
        {
            string test = "test31";

            using (SampleContext ctx = GetInputContext(test))
            {
                using (PostService svc = new PostService(ctx))
                {
                    svc.CreateNewPost(3, "NewPost Created1", "NewPost Created1");
                    svc.DeletPostWithId(3);
                    svc.CreateNewPost(2, "NewPost Created2", "NewPost Created2");

                    var result = await ctx.CompareTo(GetExpectedContext(test));

                    result.AreEqual.ShouldBe(true, result.ToString());
                }
            }
        }
示例#12
0
        public async Task <ActionResult> Edit(PostCommand post, bool reserve = true)
        {
            post.Content = await ImagebedClient.ReplaceImgSrc(post.Content.Trim().ClearImgAttributes());

            if (!CategoryService.Any(c => c.Id == post.CategoryId && c.Status == Status.Available))
            {
                return(ResultData(null, false, "请选择一个分类"));
            }

            if (post.LimitMode > 0 && string.IsNullOrEmpty(post.Regions))
            {
                return(ResultData(null, false, "请输入投放的地区"));
            }

            if (string.IsNullOrEmpty(post.Label?.Trim()) || post.Label.Equals("null"))
            {
                post.Label = null;
            }
            else if (post.Label.Trim().Length > 50)
            {
                post.Label = post.Label.Replace(",", ",");
                post.Label = post.Label.Trim().Substring(0, 50);
            }
            else
            {
                post.Label = post.Label.Replace(",", ",");
            }

            if (string.IsNullOrEmpty(post.ProtectContent) || post.ProtectContent.Equals("null", StringComparison.InvariantCultureIgnoreCase))
            {
                post.ProtectContent = null;
            }

            Post p = await PostService.GetByIdAsync(post.Id);

            if (reserve && p.Status == Status.Published)
            {
                var history = p.Mapper <PostHistoryVersion>();
                p.PostHistoryVersion.Add(history);
                p.ModifyDate = DateTime.Now;
                var user = HttpContext.Session.Get <UserInfoDto>(SessionKey.UserInfo);
                p.Modifier      = user.NickName;
                p.ModifierEmail = user.Email;
            }

            p.IP = ClientIP;
            Mapper.Map(post, p);
            if (!string.IsNullOrEmpty(post.Seminars))
            {
                var tmp = post.Seminars.Split(',').Distinct();
                p.Seminar.Clear();
                foreach (var s in tmp)
                {
                    var seminar = await SeminarService.GetAsync(e => e.Title.Equals(s));

                    if (seminar != null)
                    {
                        p.Seminar.Add(new SeminarPost()
                        {
                            Post      = p,
                            Seminar   = seminar,
                            PostId    = p.Id,
                            SeminarId = seminar.Id
                        });
                    }
                }
            }

            bool b = await SearchEngine.SaveChangesAsync() > 0;

            if (!b)
            {
                return(ResultData(null, false, "文章修改失败!"));
            }

            return(ResultData(p.Mapper <PostDto>(), message: "文章修改成功!"));
        }
示例#13
0
        public void GetPost_ExistingPost_ReturnsPost()
        {
            Post post = new Post();
            post.ID = Guid.NewGuid();
            post.PostData = "data";

            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            repository.SetupSequence(o => o.GetByID(post.ID)).Returns(post);

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);
            Post result = service.GetPost(post.ID);
            Assert.AreEqual(post, result);
        }
示例#14
0
        public void GetPost_NonExistingPost_ReturnsNull()
        {
            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            repository.SetupSequence(o => o.GetByID(It.IsAny<Guid>())).Returns(null);

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);
            Post result = service.GetPost(Guid.NewGuid());
            Assert.IsNull(result);
        }
示例#15
0
        public async Task <ActionResult> PushMerge(int id)
        {
            var post = await PostService.GetByIdAsync(id) ?? throw new NotFoundException("文章未找到");

            return(View(post));
        }
示例#16
0
        public IView GetView(string userName)
        {
            PostViewModel pvm = PostService.GetPostViewModel(this.PostId);

            return(new PostDetailsView(pvm, this.LoggedInUser));
        }
        private static async Task DoWork(SampleContext inputContext, SampleContext outputContext, Stopwatch doworkWatch)
        {
            doworkWatch.Start();
            using (inputContext)
            {
                using (outputContext)
                {
                    using (PostService svc = new PostService(inputContext))
                    {
                        svc.CreateNewPost(1, "sampleSubject", "sampleBody");
                        //svc.DeletPostWithId(2);
                        //svc.CreateNewPost(1, "sampleSubject", "sampleBody");

                        var allPosts = svc.GetAllPost().ToList();

                        allPosts.Count.ShouldBe(2);

                        var result = await inputContext.CompareTo(outputContext);

                        result.AreEqual.ShouldBe(true, result.ToString());
                    }
                }
            }
            doworkWatch.Stop();
        }
 public PostController(PostService postService)
 {
     this.postService = postService;
 }
示例#19
0
 public PostController()
 {
     _postService = new PostService();
 }
示例#20
0
        public async Task <ActionResult> PushMerge(PostMergeRequestCommand dto)
        {
            if (await RedisHelper.GetAsync("code:" + dto.ModifierEmail) != dto.Code)
            {
                return(ResultData(null, false, "验证码错误!"));
            }

            var post = await PostService.GetByIdAsync(dto.PostId) ?? throw new NotFoundException("文章未找到");

            var diff = new HtmlDiff.HtmlDiff(post.Content.RemoveHtmlTag(), dto.Content.RemoveHtmlTag());

            if (post.Title.Equals(dto.Title) && !diff.Build().Contains(new[] { "diffmod", "diffdel", "diffins" }))
            {
                return(ResultData(null, false, "内容未被修改!"));
            }

            #region 合并验证

            if (PostMergeRequestService.Any(p => p.ModifierEmail == dto.ModifierEmail && p.MergeState == MergeStatus.Block))
            {
                return(ResultData(null, false, "由于您曾经多次恶意修改文章,已经被标记为黑名单,无法修改任何文章,如有疑问,请联系网站管理员进行处理。"));
            }

            if (post.PostMergeRequests.Any(p => p.ModifierEmail == dto.ModifierEmail && p.MergeState == MergeStatus.Pending))
            {
                return(ResultData(null, false, "您已经提交过一次修改请求正在待处理,暂不能继续提交修改请求!"));
            }

            #endregion

            #region 直接合并

            if (post.Email.Equals(dto.ModifierEmail))
            {
                var history = post.Mapper <PostHistoryVersion>();
                Mapper.Map(dto, post);
                post.PostHistoryVersion.Add(history);
                post.ModifyDate = DateTime.Now;
                return(await PostService.SaveChangesAsync() > 0 ? ResultData(null, true, "你是文章原作者,无需审核,文章已自动更新并在首页展示!") : ResultData(null, false, "操作失败!"));
            }

            #endregion

            var merge = post.PostMergeRequests.FirstOrDefault(r => r.Id == dto.Id && r.MergeState != MergeStatus.Merged);
            if (merge != null)
            {
                Mapper.Map(dto, merge);
                merge.SubmitTime = DateTime.Now;
                merge.MergeState = MergeStatus.Pending;
            }
            else
            {
                merge = Mapper.Map <PostMergeRequest>(dto);
                post.PostMergeRequests.Add(merge);
            }

            var b = await PostService.SaveChangesAsync() > 0;

            if (!b)
            {
                return(ResultData(null, false, "操作失败!"));
            }

            await RedisHelper.ExpireAsync("code:" + dto.ModifierEmail, 1);

            await MessageService.AddEntitySavedAsync(new InternalMessage()
            {
                Title   = $"来自【{dto.Modifier}】的文章修改合并请求",
                Content = dto.Title,
                Link    = "#/merge/compare?id=" + merge.Id
            });

            var content = new Template(await System.IO.File.ReadAllTextAsync(HostEnvironment.WebRootPath + "/template/merge-request.html")).Set("title", post.Title).Set("link", Url.Action("Index", "Dashboard", new { }, Request.Scheme) + "#/merge/compare?id=" + merge.Id).Render();
            BackgroundJob.Enqueue(() => CommonHelper.SendMail("博客文章修改请求:", content, CommonHelper.SystemSettings["ReceiveEmail"], ClientIP));
            return(ResultData(null, true, "您的修改请求已提交,已进入审核状态,感谢您的参与!"));
        }
示例#21
0
        public async Task <ActionResult> Write(PostCommand post, DateTime?timespan, bool schedule = false)
        {
            post.Content = await ImagebedClient.ReplaceImgSrc(post.Content.Trim().ClearImgAttributes());

            if (!CategoryService.Any(c => c.Id == post.CategoryId && c.Status == Status.Available))
            {
                return(ResultData(null, message: "请选择一个分类"));
            }

            if (string.IsNullOrEmpty(post.Label?.Trim()) || post.Label.Equals("null"))
            {
                post.Label = null;
            }
            else if (post.Label.Trim().Length > 50)
            {
                post.Label = post.Label.Replace(",", ",");
                post.Label = post.Label.Trim().Substring(0, 50);
            }
            else
            {
                post.Label = post.Label.Replace(",", ",");
            }

            if (string.IsNullOrEmpty(post.ProtectContent) || post.ProtectContent.Equals("null", StringComparison.InvariantCultureIgnoreCase))
            {
                post.ProtectContent = null;
            }

            post.Status = Status.Published;
            Post p = post.Mapper <Post>();

            p.Modifier      = p.Author;
            p.ModifierEmail = p.Email;
            p.IP            = ClientIP;
            if (!string.IsNullOrEmpty(post.Seminars))
            {
                var tmp = post.Seminars.Split(',').Distinct();
                foreach (var s in tmp)
                {
                    var     id      = s.ToInt32();
                    Seminar seminar = await SeminarService.GetByIdAsync(id);

                    p.Seminar.Add(new SeminarPost()
                    {
                        Post      = p,
                        PostId    = p.Id,
                        Seminar   = seminar,
                        SeminarId = seminar.Id
                    });
                }
            }

            if (schedule)
            {
                if (!timespan.HasValue || timespan.Value <= DateTime.Now)
                {
                    return(ResultData(null, false, "如果要定时发布,请选择正确的一个将来时间点!"));
                }

                p.Status     = Status.Schedule;
                p.PostDate   = timespan.Value.ToUniversalTime();
                p.ModifyDate = timespan.Value.ToUniversalTime();
                HangfireHelper.CreateJob(typeof(IHangfireBackJob), nameof(HangfireBackJob.PublishPost), args: p);
                return(ResultData(p.Mapper <PostDto>(), message: $"文章于{timespan.Value:yyyy-MM-dd HH:mm:ss}将会自动发表!"));
            }

            PostService.AddEntity(p);
            bool b = await SearchEngine.SaveChangesAsync() > 0;

            if (!b)
            {
                return(ResultData(null, false, "文章发表失败!"));
            }

            return(ResultData(null, true, "文章发表成功!"));
        }
        //post请求
        private void Post(SSORequest ssoRequest)
        {
            PostService ps = new PostService();

            ps.Url = ConfigurationManager.AppSettings["SSOUrl"];

            ps.Add("IsLogin", "1");
            ps.Add("UserAccount", ssoRequest.UserAccount);
            ps.Add("AppCode", ssoRequest.AppCode);
            ps.Add("TimeStamp", ssoRequest.TimeStamp);
            ps.Add("AppUrl", ssoRequest.AppUrl);
            ps.Add("Authenticator", ssoRequest.Authenticator);

            ps.Post();
        }
示例#23
0
 public ProfileModel(UserManager <User> userManager, [FromServices] PostService postService)
 {
     _userManager = userManager;
     Post         = postService.GetPosts();
 }
示例#24
0
 public DefaultViewModel(PostService postService)
 {
     _postService = postService;
 }
示例#25
0
        public async Task GetAllShouldTakeFive()
        {
            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 <Post>(context);
            var service    = new PostService(repository);
            var models     = new List <CreatePostInputModel>()
            {
                new CreatePostInputModel()
                {
                    Title    = "new",
                    Category = "Action",
                    Content  = "test",
                    ImageUrl = "google",
                },
                new CreatePostInputModel()
                {
                    Title    = "new2",
                    Category = "Action",
                    Content  = "test2",
                    ImageUrl = "google2",
                },
                new CreatePostInputModel()
                {
                    Title    = "new3",
                    Category = "Action",
                    Content  = "test3",
                    ImageUrl = "google3",
                },
                new CreatePostInputModel()
                {
                    Title    = "ne4",
                    Category = "Action",
                    Content  = "test4",
                    ImageUrl = "google4",
                },
                new CreatePostInputModel()
                {
                    Title    = "new5",
                    Category = "Action",
                    Content  = "test5",
                    ImageUrl = "google5",
                },
                new CreatePostInputModel()
                {
                    Title    = "new6",
                    Category = "Action",
                    Content  = "test6",
                    ImageUrl = "google6",
                },
            };

            foreach (var model in models)
            {
                await service.CreateAsync(model, "1");
            }

            var actual = await service.GetAllAsync <PostViewModel>(5, 0);

            Assert.Equal(5, actual.Count());
        }
示例#26
0
        public void AddPost_ValidPost_TrueFlag()
        {
            Post post = new Post();
            post.ID = Guid.NewGuid();
            post.PostData = "data";

            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            repository.Setup(o => o.Insert(post));

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);
            bool flag = service.AddPost(post);

            Assert.IsTrue(flag);
        }
示例#27
0
        public ActionResult GetTag()
        {
            var list = PostService.GetQuery(p => !string.IsNullOrEmpty(p.Label)).Select(p => p.Label).Distinct().ToList().SelectMany(s => s.Split(',', ',')).OrderBy(s => s).ToHashSet();

            return(ResultData(list));
        }
示例#28
0
文件: CrmTest1.cs 项目: ssjylsg/crm
        public void PostTest()
        {
            IPostService postService = new PostService();

            string[] postNames = new string[] { ".Net 开发工程师", "Java ", "C++", "C", "go" };

            for (int i = 0; i < postNames.Length; i++)
            {
                Post post = new Post();
                post.PostCode = "00" + i;
                post.Company = DependencyResolver.Resolver<ICompanyService>().FindById(1);
                post.Dept = this._departmentService.FindById(1);

                post.PostName = postNames[i];

                postService.Save(post);

                Assert.IsNotNull(postService.FindById(post.Id));
            }
        }
示例#29
0
        public void GetPosts_PostNonExist_ReturnsNull()
        {
            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            repository.SetupSequence(o => o.GetAll()).Returns(null);

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);

            IList<Post> result = service.GetPosts();
            Assert.IsNull(result);
        }
 public TagController(TagService tagService, PostService postService)
 {
     this.tagService = tagService;
     this.postService = postService;
 }
示例#31
0
        public void GetPosts_PostsExist_ReturnsList()
        {
            IList<Post> posts = new List<Post>();

            for (int i = 0; i < 2; i++)
            {
                Post post = new Post();
                post.ID = Guid.NewGuid();
                post.PostData = "data";
                post.PostDate = DateTime.Now;
                posts.Add(post);
            }

            Mock<IRepository<Post>> repository = new Mock<IRepository<Post>>();
            Mock<ILoggerService> loggerService = new Mock<ILoggerService>();
            Mock<IMediaService> mediaService = new Mock<IMediaService>();
            Mock<IFileService> fileService = new Mock<IFileService>();

            repository.Setup(o => o.GetAll()).Returns(posts);

            PostService service = new PostService(repository.Object, loggerService.Object, mediaService.Object, fileService.Object);

            IList<Post> result = service.GetPosts();
            Assert.AreEqual(posts.Count, result.Count);
        }
示例#32
0
 public void Setup()
 {
     _postRepository = new Mock<IPostRepository>();
     _postService = new PostService(_postRepository.Object);
 }
示例#33
0
        public IHttpActionResult PostCommentary(CreateCommentaryModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var commentaryService = new CommentaryService();
                    var postService       = new PostService();
                    var userService       = new UserService();
                    var currentUserId     = userService.GetUserByAccountId(new GetUserByAccountIdRequest()
                    {
                        AccountId = User.Identity.GetUserId()
                    }).User.Id;

                    // Controla que exista la publicación asociada.
                    var post = postService.GetPostById(new GetPostByIdRequest()
                    {
                        Id = model.IdPost
                    }).Post;
                    if (post == null)
                    {
                        return(BadRequest("Invalid post"));
                    }
                    if (post.NullDate.HasValue)
                    {
                        return(BadRequest("Invalid post"));
                    }

                    if (model.IdUpperComment.HasValue)
                    {
                        // Controla que exista el comentario padre.
                        var upperCommentary = commentaryService.GetCommentaryById(new GetCommentaryByIdRequest()
                        {
                            Id = model.IdUpperComment.Value
                        }).Commentary;
                        if (upperCommentary == null)
                        {
                            return(BadRequest("Invalid upper commentary"));
                        }
                        if (upperCommentary.NullDate.HasValue)
                        {
                            return(BadRequest("Invalid upper commentary"));
                        }

                        if (upperCommentary.IdUpperComment.HasValue)
                        {
                            return(BadRequest("You can't respond an answer"));
                        }
                    }

                    var request = new CreateCommentaryRequest()
                    {
                        CommentaryText = model.TextComment,
                        IdPost         = model.IdPost,
                        IdUpperComment = model.IdUpperComment,
                        IdUser         = currentUserId
                    };

                    var result = commentaryService.CreateCommentary(request);

                    return(Ok());
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest(ModelState));
        }
 public HomeController(WebLogService webLogService, PostService postService)
 {
     this.webLogService = webLogService;
     this.postService = postService;
 }
示例#35
0
        public IView GetView(string userName)
        {
            var postViewModel = PostService.GetPostViewModel(PostId);

            return(new PostDetailsView(postViewModel));
        }