public CurrencyQueryResult Handle(CurrencyQuery query) { List <FIL.Contracts.Models.CurrencyType> currencies = new List <FIL.Contracts.Models.CurrencyType>(); try { var currency = _currencyRepository.GetAll(null); foreach (var item in currency) { currencies.Add(new FIL.Contracts.Models.CurrencyType { Id = item.Id, Name = item.Name }); } return(new CurrencyQueryResult { Currencies = currencies }); } catch (Exception ex) { _logger.Log(Logging.Enums.LogCategory.Error, ex); return(new CurrencyQueryResult { Currencies = null }); } }
public CurrencyTypesQueryResult Handle(CurrencyTypesQuery query) { var currencyTypes = _currencyTypeRepository.GetAll(); var currencyType = AutoMapper.Mapper.Map <List <Contracts.Models.CurrencyType> >(currencyTypes).ToList(); return(new CurrencyTypesQueryResult { currencyTypes = currencyType }); }
public MasterBudgetRangeQueryResult Handle(MasterBudgetRangeQuery query) { var budgetRanges = _masterBudgetRangeRepository.GetAll().OrderBy(s => s.SortOrder); var currencyTypes = _currencyTypeRepository.GetAll(); return(new MasterBudgetRangeQueryResult { MasterBudgetRanges = budgetRanges.ToList(), CurrencyTypes = currencyTypes.ToList() }); }
public CategoryEventQueryResult Handle(CategoryEventQuery query) { var categoryEventsForSite = _eventRepository.GetByCategoryId(query.EventCategoryId).Where(e => e.IsEnabled).ToList(); var eventMapping = categoryEventsForSite.ToDictionary(e => e.Id); var eventIds = eventMapping.Keys; var allEventDetails = _eventDetailRepository.GetByEventIds(eventIds).Where(ed => ed.IsEnabled).ToList(); var venueMapping = _venueRepository.GetByVenueIds(allEventDetails.Select(ed => ed.VenueId).Distinct()) .ToDictionary(v => v.Id); var eventDetailsMapping = allEventDetails.GroupBy(ed => ed.EventId) .ToDictionary(g => g.Key, g => g.ToList()); var cityIds = venueMapping.Values.Select(s => s.CityId).Distinct(); var cityMapping = _cityRepository.GetByCityIds(cityIds) .ToDictionary(c => c.Id); var stateId = cityMapping.Values.Select(c => c.StateId).Distinct(); var stateMapping = _stateRepository.GetByStateIds(stateId) .ToDictionary(s => s.Id); var countryIdList = stateMapping.Values.Select(s => s.CountryId).Distinct(); var countryMapping = _countryRepository.GetByCountryIds(countryIdList) .ToDictionary(c => c.Id); var currencyTypeList = _currencyTypeRepository.GetAll(); var CategoryEventData = categoryEventsForSite.Select(ce => { var eventObj = eventMapping[ce.Id]; if (eventDetailsMapping.ContainsKey(ce.Id)) { var eventDetails = eventDetailsMapping[ce.Id]; var eventDetailIdList = eventDetails.Select(s => s.Id).Distinct(); var venues = eventDetails.Select(s => s.VenueId).Distinct().Select(v => venueMapping[v]); var cities = venues.Select(s => s.CityId).Distinct().Select(c => cityMapping[c]); var states = cities.Select(s => s.StateId).Distinct().Select(s => stateMapping[s]); var countries = states.Select(s => s.CountryId).Distinct().Select(c => countryMapping[c]); if (!eventDetailIdList.Any()) { return(new CategoryEventContainer { }); } var eventTicketAttributeMapping = new List <Contracts.DataModels.EventTicketAttribute> { _eventTicketAttributeRepository.GetMaxPriceByEventDetailId(eventDetailIdList), _eventTicketAttributeRepository.GetMinPriceByEventDetailId(eventDetailIdList) }; if (eventTicketAttributeMapping.Any()) { var currencyMapping = currencyTypeList.Where(s => s.Id == eventTicketAttributeMapping.FirstOrDefault().CurrencyId).FirstOrDefault(); return(new CategoryEventContainer { CategoryEvent = Mapper.Map <Contracts.Models.CategoryEvent>(ce), EventType = eventObj.EventTypeId.ToString(), City = Mapper.Map <IEnumerable <City> >(cities), State = Mapper.Map <IEnumerable <State> >(states), Country = Mapper.Map <IEnumerable <Country> >(countries), Event = Mapper.Map <Event>(eventObj), EventDetail = Mapper.Map <IEnumerable <EventDetail> >(eventDetails), CurrencyType = Mapper.Map <CurrencyType>(currencyMapping), Venue = Mapper.Map <IEnumerable <Venue> >(venues), EventTicketAttribute = Mapper.Map <IEnumerable <EventTicketAttribute> >(eventTicketAttributeMapping), }); } else { return(new CategoryEventContainer { }); } } else { return(new CategoryEventContainer { }); } }); if (CategoryEventData.ToList() != null) { return(new CategoryEventQueryResult { CategoryEvents = CategoryEventData.Where(s => s.Event != null).ToList() }); } else { return(new CategoryEventQueryResult { }); } }
public IEnumerable <CurrencyTypeResult> Handle(GetAllQuery query) { return(_repository.GetAll().Select(x => new CurrencyTypeResult())); }