Exemplo n.º 1
0
        // GET: Party
        public ActionResult Index(int id)
        {
            Party party = partyService.GetPartyByID(id);

            PartyParticipantsViewModel partyParticipantsViewModel = new PartyParticipantsViewModel();

            partyParticipantsViewModel.PartyID           = id;
            partyParticipantsViewModel.PartyTitle        = party.Title;
            partyParticipantsViewModel.PartyParticipants = partyService.ListAttendent().Where(_ => _.PartyId == id).Select(_ => new PartyParticipants {
                Id = _.Id, Name = _.Name, ArrivalDate = _.ArrivalDate
            }).ToList();

            return(View(partyParticipantsViewModel));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Index(int id, int page = 1)
        {
            Party party = _partyService.GetPartyWithOwnerByID(id);

            if (party == null)
            {
                return(new NotFoundResult());
            }

            var authorizationResult = await _authorizationService.AuthorizeAsync(User, party, "ReadPartyOver18");

            if (authorizationResult.Succeeded)
            {
                int pageSize = 3;

                IQueryable <Participant> source = _partyService.ListAttendent().Where(x => x.PartyId == id);
                var count = source.Count();
                var items = source.Skip((page - 1) * pageSize).Take(pageSize).ProjectTo <PartyParticipants>(_mapper.ConfigurationProvider).ToList();

                PageViewModel pageViewModel = new PageViewModel(count, page, pageSize);

                _httpContextAccessor.HttpContext.Session.AddParty(id);

                PartyParticipantsViewModel partyParticipantsViewModel = new PartyParticipantsViewModel();
                partyParticipantsViewModel.PartyID           = id;
                partyParticipantsViewModel.PartyTitle        = party.Title;
                partyParticipantsViewModel.PartyParticipants = items;
                partyParticipantsViewModel.PageViewModel     = pageViewModel;

                return(View(partyParticipantsViewModel));
            }
            else
            {
                return(new ForbidResult());
            }
        }