コード例 #1
0
ファイル: PartyController.cs プロジェクト: razorbohan/PVT
        public ActionResult Vote(VoteViewModel model, IFormFile photo)
        {
            if (ModelState.IsValid)
            {
                if (!string.IsNullOrEmpty(model.Name) && model.IsAttend)
                {
                    string filename = null;
                    if (photo != null)
                    {
                        var ext = Path.GetExtension(photo.FileName);
                        filename = $@"{Guid.NewGuid()}{ext}";
                        var path = Path.Combine(_env.WebRootPath, "images", filename);
                        using (var fileStream = new FileStream(path, FileMode.Create))
                        {
                            photo.CopyTo(fileStream);
                        }
                    }

                    PartyService.Vote(model.PartyId, model.Name, model.IsAttend, filename);

                    Logger.Info($"{model.Name} -> {PartyService.GetParty(model.PartyId).Name} : {model.IsAttend}");
                }

                return(RedirectToAction("Index", new { id = model.PartyId }));
            }

            var party      = PartyService.GetParty(model.PartyId);
            var attendants = PartyService.ListAttendants(party.Id).Select(x => (x.Name, x.Avatar)).ToList();
            var partyModel = new PartyDetailsViewModel {
                PartyId = party.Id, Date = party.Date, Title = party.Name, Location = party.Location, Attendants = attendants
            };

            return(View("Index", partyModel));
        }
コード例 #2
0
ファイル: PartyController.cs プロジェクト: razorbohan/PVT
        public ActionResult Index(int id)
        {
            var party      = PartyService.GetParty(id);
            var attendants = PartyService.ListAttendants(party.Id).Select(x => x.Name).ToList();
            var model      = new PartyDetailsViewModel {
                PartyId = party.Id, Date = party.Date, Title = party.Title, Location = party.Location, Attendants = attendants
            };

            return(View(model));
        }
コード例 #3
0
ファイル: PartyController.cs プロジェクト: razorbohan/PVT
        public ActionResult Index(int id)
        {
            var tt         = HttpContext.Session.Id;
            var party      = PartyService.GetParty(id);
            var attendants = PartyService.ListAttendants(party.Id).Select(x => (x.Name, x.Avatar)).ToList();
            var model      = new PartyDetailsViewModel {
                PartyId = party.Id, Date = party.Date, Title = party.Name, Location = party.Location, Attendants = attendants
            };

            MemoriseParty(party);

            return(View(model));
        }
コード例 #4
0
ファイル: PartyController.cs プロジェクト: razorbohan/PVT
        public ActionResult Index(int id)
        {
            var party = PartyService.GetParty(id);

            if (party.IsPlus18 && !HttpContext.User.Claims.Any(c => c.Type == "Plus18"))
            {
                return(Forbid());
            }

            var attendants = PartyService.ListAttendants(party.Id).Select(x => (x.Name, x.Avatar)).ToList();
            var model      = new PartyDetailsViewModel {
                PartyId = party.Id, Date = party.Date, Title = party.Name, Location = party.Location, Attendants = attendants
            };

            MemoriseParty(party);

            return(View(model));
        }
コード例 #5
0
        public async Task <ActionResult> Details(string id)
        {
            var user = await _userManager.FindByIdAsync(id);

            var userId      = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value;
            var currentUser = await _userManager.FindByIdAsync(userId);

            List <SquirrelUser>   userSquirrels = _db.SquirrelUser.Where(join => join.UserId == id).Include(join => join.Squirrel).ToList();
            List <PartyMessage>   partyMessages = _db.PartyMessages.Where(message => message.UserId == id).Include(message => message.User).Include(message => message.UserFrom).ToList();
            PartyDetailsViewModel viewModel     = new PartyDetailsViewModel();

            viewModel.User          = user;
            viewModel.CurrentUser   = currentUser;
            viewModel.SquirrelCount = userSquirrels.Count();
            viewModel.PartyMessages = partyMessages;
            int currentColumn = 1;

            foreach (SquirrelUser join in userSquirrels)
            {
                if (currentColumn == 1)
                {
                    viewModel.Column1.Add(join);
                }
                if (currentColumn == 2)
                {
                    viewModel.Column2.Add(join);
                }
                if (currentColumn == 3)
                {
                    viewModel.Column3.Add(join);
                }
                if (currentColumn < 3)
                {
                    currentColumn++;
                }
                else
                {
                    currentColumn = 1;
                }
            }
            return(View(viewModel));
        }
コード例 #6
0
        // GET: Parties/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            var partyVm = new PartyDetailsViewModel
            {
                Party = await _context.Parties
                        .SingleOrDefaultAsync(m => m.PartyId == id),
                Accountabilities = GetAccountabilities(id)
            };


            if (partyVm.Party == null)
            {
                return(NotFound());
            }

            return(View(partyVm));
        }