コード例 #1
0
        public async Task UpdateAuthors(InviteAuthorViewModel model, CancellationToken cancellationToken)
        {
            var post = await _context.EpisodeEntry.Include(x => x.EpisodeEntryPlayer).FirstAsync(x => x.Id == model.Id, cancellationToken: cancellationToken);

            post.EpisodeEntryPlayer.Clear();
            foreach (var author in model.Authors.Where(x => x.IsSelected))
            {
                post.EpisodeEntryPlayer.Add(new EpisodeEntryPlayer()
                {
                    EpisodeEntryId = post.Id, PlayerId = author.Id
                });
            }

            await _context.SaveChangesAsync(cancellationToken);
        }
コード例 #2
0
        public async Task <IActionResult> Invite(int id, CancellationToken cancellationToken)
        {
            if (!await _authoringService.PostExists(id))
            {
                TempData["message"] = "Post does not exist";
                return(RedirectToAction("Writing", "My"));
            }

            var vm = new InviteAuthorViewModel();

            //var post = _authoringService.GetPost(id);
            vm.Authors = await _authoringService.GetAuthorsAsync(id, cancellationToken);

            return(View(vm));
        }
コード例 #3
0
        public async Task <IActionResult> ProcessInvite(InviteAuthorViewModel model, CancellationToken token)
        {
            if (ModelState.IsValid)
            {
                //TODO: Need to notify users of the JP. This is where we use mediatr

                await _authoringService.UpdateAuthors(model, token);

                if (model.nextaction.Equals("save"))
                {
                    return(RedirectToAction("Writing", "My"));
                }

                return(RedirectToAction("Post", new { id = model.Id }));
            }

            return(View("Invite", model));
        }