Esempio 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);
        }
Esempio n. 2
0
        public async Task SelectRequestsPostWithTwoParametersSetsSelectItineraryRequestsModelWithTheCorrectData()
        {
            var itineraryRequestsModel = new SelectItineraryRequestsViewModel {
                KeywordsFilter = "These are keywords"
            };
            var itinerary        = GetItineraryForSelectRequestHappyPathTests();
            var returnedRequests = GetRequestsForSelectRequestHappyPathTests();

            var mediator = new Mock <IMediator>();

            mediator.Setup(x => x.SendAsync(It.Is <ItineraryDetailQuery>(y => y.ItineraryId == itinerary.Id)))
            .ReturnsAsync(itinerary);
            mediator.Setup(x => x.SendAsync(It.Is <RequestListItemsQuery>(y =>
                                                                          y.Criteria.Keywords.Equals(itineraryRequestsModel.KeywordsFilter) &&
                                                                          y.Criteria.EventId == itinerary.EventId)))
            .ReturnsAsync(returnedRequests);

            var sut = new ItineraryController(mediator.Object, null);

            var view = await sut.SelectRequests(itinerary.Id, itineraryRequestsModel);

            RunSelectRequestsHappyPathTests(view, itinerary, returnedRequests);
        }
Esempio n. 3
0
        public async Task <IActionResult> SelectRequests(int id, SelectItineraryRequestsViewModel model)
        {
            var newModel = await BuildSelectItineraryRequestsModel(id, new RequestSearchCriteria { Status = RequestStatus.Unassigned, Keywords = model.KeywordsFilter });

            return(View("SelectRequests", newModel));
        }