Exemplo n.º 1
0
        private async Task<SelectItineraryRequestsViewModel> BuildSelectItineraryRequestsModel(int itineraryId, RequestSearchCriteria criteria)
        {
            var model = new SelectItineraryRequestsViewModel();

            var itinerary = await _mediator.SendAsync(new ItineraryDetailQuery { ItineraryId = itineraryId });

            model.CampaignId = itinerary.CampaignId;
            model.CampaignName = itinerary.CampaignName;
            model.EventId = itinerary.EventId;
            model.EventName = itinerary.EventName;
            model.ItineraryName = itinerary.Name;

            criteria.EventId = itinerary.EventId;

            var requests = await _mediator.SendAsync(new RequestListItemsQuery { Criteria = criteria });

            foreach (var request in requests)
            {
                var selectItem = new RequestSelectViewModel
                {
                    Id = request.Id,
                    Name = request.Name,
                    DateAdded = request.DateAdded,
                    City = request.City,
                    Address = request.Address,
                    Latitude = request.Latitude,
                    Longitude = request.Longitude,
                    Postcode = request.Postcode
                };

                model.Requests.Add(selectItem);
            }

            return model;
        }
Exemplo n.º 2
0
        public async Task<IActionResult> Requests(int id, string status)
        {
            var organizationId = await _mediator.SendAsync(new OrganizationIdByEventIdQuery { EventId = id });
            if (!User.IsOrganizationAdmin(organizationId))
            {
                return Unauthorized();
            }

            var criteria = new RequestSearchCriteria { EventId = id };
            var pageTitle = "All Requests";
            var currentPage = "All";

            if (!string.IsNullOrEmpty(status))
            { 
                RequestStatus requestStatus;
                if (Enum.TryParse(status, out requestStatus))
                {
                    criteria.Status = requestStatus;
                    pageTitle = $"{status} Requests";
                    currentPage = status;
                }
                else
                {
                    return RedirectToAction(nameof(Requests), new {id});
                }
            }

            var viewModel = await _mediator.SendAsync(new EventRequestsQuery { EventId = id });
            viewModel.PageTitle = pageTitle;
            viewModel.CurrentPage = currentPage;

            viewModel.Requests = await _mediator.SendAsync(new RequestListItemsQuery { Criteria = criteria });
 
            return View(viewModel);
        }
Exemplo n.º 3
0
        public async Task<IActionResult> Requests(int id, string status)
        {
            var campaignEvent = GetEventBy(id);
            if (campaignEvent == null)
            {
                return NotFound();
            }

            if (!User.IsOrganizationAdmin(campaignEvent.Campaign.ManagingOrganizationId))
            {
                return Unauthorized();
            }

            var criteria = new RequestSearchCriteria { EventId = id };

            var pageTitle = "All Requests";

            if (!string.IsNullOrEmpty(status))
            { 
                RequestStatus requestStatus;
                if (Enum.TryParse(status, out requestStatus))
                {
                    criteria.Status = requestStatus;
                    pageTitle = $"{status} Requests";
                }
                else
                {
                    return RedirectToAction(nameof(Requests), new {id});
                }
            }

            var model = await _mediator.SendAsync(new EventRequestsQuery { EventId = id });

            model.PageTitle = pageTitle;

            model.Requests = await _mediator.SendAsync(new RequestListItemsQuery {Criteria = criteria});
 
            return View(model);
        }