Exemple #1
0
        async Task <OneOf <Success, Banned> > IPostService.AddThread(Guid postId, Guid threadId, Guid boardId, string subject, TripCodedName name, string comment, bool isSage, IIpHash ipAddress, Option <File> file, CancellationToken cancellationToken)
        {
            if (await this.bannedIpRepository.IsBanned(ipAddress, cancellationToken))
            {
                return(new Banned());
            }

            var thread = new Thread(threadId, boardId, subject);
            await threadRepository.Add(thread).ConfigureAwait(false);

            var post = new Domain.Post(postId, threadId, DateTime.UtcNow, name.Val, comment, isSage, ipAddress.Val);

            await this.postRepository.Add(post).ConfigureAwait(false);

            await file.MapToTask(some => this.fileRepository.Add(some));

            return(new Success());
        }
Exemple #2
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            if (Thread.Id != Guid.Parse("00000000-0000-0000-0000-000000000000"))
            {
                threadRepository.Update(Thread);
            }
            else
            {
                threadRepository.Add(Thread);
            }

            threadRepository.Commit();
            TempData["Notice"] = "Thread saved";
            return(RedirectToPage("./Detail", new { threadId = Thread.Id }));
        }
Exemple #3
0
        public IActionResult CreateThread(CreateThreadViewModel model)
        {
            if (ModelState.IsValid)
            {
                Thread newThread = new Thread
                {
                    Title   = model.Title,
                    BoardId = model.BoardId
                };
                _threadRepository.Add(newThread);

                Post newPost = new Post
                {
                    Content  = model.Content,
                    ThreadId = newThread.Id,
                    User     = User.Identity.Name
                };
                _postRepository.Add(newPost);

                return(RedirectToAction("index", new { boardId = model.BoardId }));
            }
            return(View(model));
        }