protected override async Task <ICommandResult> Handle(EventScheduleCommand command)
 {
     try
     {
         var currentEvent       = _eventRepository.Get(command.EventScheduleModel.EventId);
         var currentEventDetail = _eventDetailRepository.GetByEventId(command.EventScheduleModel.EventId);
         var placeWeekOpen      = _placeWeekOpenDaysRepository.GetByEventId(command.EventScheduleModel.EventId);
         var dayTimeMappings    = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDays(placeWeekOpen.Select(s => s.Id).ToList());
         if (currentEventDetail != null && command.EventFrequencyType == Contracts.Enums.EventFrequencyType.Recurring)
         {
             return(new EventScheduleCommandResult
             {
                 Success = true,
                 EventScheduleModel = command.EventScheduleModel
             });
         }
         if (currentEventDetail != null && command.EventScheduleModel.EventDetailId == 0)
         {
             command.EventScheduleModel.EventDetailId = currentEventDetail.Id;
         }
         foreach (var currentDayTimeMapping in dayTimeMappings)
         {
             _dayTimeMappingsRepository.Delete(currentDayTimeMapping);
         }
         foreach (var currentPlaceWeekOpen in placeWeekOpen)
         {
             _placeWeekOpenDaysRepository.Delete(currentPlaceWeekOpen);
         }
         var eventDetail       = SaveEventDetail(command, currentEvent);
         var placeWeekOpenDays = SavePlaceWeekOpenDays(command, currentEvent);
         SaveDayTimeMappings(command, placeWeekOpenDays);
         SaveEventAttribute(command, eventDetail);
         UpdateLiveEventDetails(eventDetail);
         command.EventScheduleModel.EventDetailId = eventDetail.Id;
         var eventStepDetail = _stepProvider.SaveEventStepDetails(eventDetail.EventId, command.CurrentStep, true, command.ModifiedBy);
         return(new EventScheduleCommandResult
         {
             Success = true,
             CompletedStep = eventStepDetail.CompletedStep,
             CurrentStep = eventStepDetail.CurrentStep,
             EventScheduleModel = command.EventScheduleModel
         });
     }
     catch (Exception e)
     {
         _logger.Log(LogCategory.Error, e);
         return(new EventScheduleCommandResult {
         });
     }
 }
        public void deleteCalendar(Event place)
        {
            try
            {
                var placeWeekDays          = _placeWeekOpenDaysRepository.GetByEventId(place.Id).ToList();
                var DayTimeMappings        = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDays(placeWeekDays.Select(s => s.Id).ToList());
                var PlaceSeasonDetails     = _placeSeasonDetailsRepository.GetByEventId(place.Id);
                var placeSeasonDays        = _seasonDaysMappingsRepository.GetByPlaceSeasonDetailIds(PlaceSeasonDetails.Select(s => s.Id).ToList());
                var seasonDaysTimeMappings = _seasonDayTimeMappingsRepository.GetAllSeasonDaysMappings(placeSeasonDays.Select(s => s.Id).ToList());
                var specialDayTimeMappings = _placeSpecialDayTimeMappingsRepository.GetAllByEventId((place.Id));

                foreach (FIL.Contracts.DataModels.DayTimeMappings currentDay in DayTimeMappings)
                {
                    _dayTimeMappingsRepository.Delete(currentDay);
                }
                foreach (FIL.Contracts.DataModels.PlaceWeekOpenDays currentDay in placeWeekDays)
                {
                    _placeWeekOpenDaysRepository.Delete(currentDay);
                }
                foreach (FIL.Contracts.DataModels.SeasonDaysTimeMapping currentDay in seasonDaysTimeMappings)
                {
                    _seasonDayTimeMappingsRepository.Delete(currentDay);
                }
                foreach (FIL.Contracts.DataModels.SeasonDaysTimeMapping currentDay in seasonDaysTimeMappings)
                {
                    _seasonDayTimeMappingsRepository.Delete(currentDay);
                }
                foreach (FIL.Contracts.DataModels.SeasonDaysMapping currentDay in placeSeasonDays)
                {
                    _seasonDaysMappingsRepository.Delete(currentDay);
                }
                foreach (FIL.Contracts.DataModels.PlaceSeasonDetails currentDay in PlaceSeasonDetails)
                {
                    _placeSeasonDetailsRepository.Delete(currentDay);
                }
                foreach (FIL.Contracts.DataModels.PlaceSpecialDayTimeMappings currentDay in specialDayTimeMappings)
                {
                    _placeSpecialDayTimeMappingsRepository.Delete(currentDay);
                }
            }
            catch (Exception e)
            {
            }
        }
Exemple #3
0
        public SearchVenueQueryResult Handle(SearchVenueQuery query)
        {
            List <FIL.Contracts.DataModels.SearchVenue> VenueResult = new List <Contracts.DataModels.SearchVenue>();

            try
            {
                var citiesArray = query.CityName != null?query.CityName.Split(",") : null;

                var eventCategoriesRepositoryData = _eventCategoryRepository.GetAll().Where(s => s.IsFeel == true);
                var categories = query.Categories != null?query.Categories.Split(",") : null;

                List <long> categoryList = new List <long>();
                if (categories != null && categories.Count() > 0 && query.PlaceId == 0)
                {
                    foreach (var item in categories)
                    {
                        try
                        {
                            var categoryInfo = eventCategoriesRepositoryData.FirstOrDefault(x => x.DisplayName == item).Id;
                            categoryList.Add(categoryInfo);
                        }
                        catch (Exception ex)
                        {
                            _logger.Log(Logging.Enums.LogCategory.Error, ex);
                        }
                    }
                }
                else if (categories != null && categories.Count() == 0 && query.PlaceId == 0)
                {
                    var categoryInfo = eventCategoriesRepositoryData.FirstOrDefault(x => x.DisplayName == query.Categories).Id;
                    categoryList.Add(categoryInfo);
                }
                var cityLists = query.CityIds != null?_cityRepository.GetByCityIds(query.CityIds) : null;

                var itineraryPlaces = query.PlaceId == 0 ? _eventRepository.GetAllItineraryPlaces(cityLists.Select(s => s.Id).ToList(), categoryList).GroupBy(x => x.Id, (key, group) => group.First()) :
                                      _eventRepository.GetItinerarySearchPlaces(query.PlaceId).GroupBy(x => x.Id, (key, group) => group.First());
                var placeWeekOpenDayList              = _placeWeekOpenDaysRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList());
                var dayTimeMappingLists               = _dayTimeMappingsRepository.GetAllByPlaceWeekOpenDays(placeWeekOpenDayList.Select(s => (long)s.Id).Distinct().ToList());
                var placeHolidayDatesRepositoryLists  = _placeHolidayDatesRepository.GetAllByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList());
                var placeVisitDurationRepositoryLists = _PlaceVisitDurationRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList());
                var eventDetails          = _eventDetailRepository.GetByEventIds(itineraryPlaces.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true);
                var eventTicketDetails    = _eventTicketDetailRepository.GetByEventDetailIds(eventDetails.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true);
                var eventTicketAttributes = _eventTicketAttributeRepository.GetByEventTicketDetailIds(eventTicketDetails.Select(s => (long)s.Id).Distinct().ToList()).Where(s => s.IsEnabled == true);
                var ticketCategories      = _ticketCategoryRepository.GetByTicketCategoryIds(eventTicketDetails.Select(s => (long)s.TicketCategoryId).Distinct().ToList());
                var Days = _daysRepository.GetAll();
                foreach (var currentPlace in itineraryPlaces)
                {
                    var         PlaceVisitDuration = placeVisitDurationRepositoryLists.FirstOrDefault(x => x.EventId == currentPlace.Id);
                    var         placeWeekOpenDays  = placeWeekOpenDayList.Where(x => x.EventId == currentPlace.Id);
                    var         dayTimeMappings    = dayTimeMappingLists.Where(s => placeWeekOpenDays.Any(p => p.Id == s.PlaceWeekOpenDayId));
                    SearchVenue searchVenue        = new SearchVenue();
                    searchVenue.CategoryName          = currentPlace.Category;
                    searchVenue.EventId               = currentPlace.Id;
                    searchVenue.CityId                = currentPlace.CityId;
                    searchVenue.EventSource           = currentPlace.EventSource;
                    searchVenue.CityName              = currentPlace.CityName;
                    searchVenue.CountryName           = currentPlace.CountryName;
                    searchVenue.Currency              = currentPlace.Currency;
                    searchVenue.EventName             = currentPlace.Name;
                    searchVenue.EventAltId            = currentPlace.AltId;
                    searchVenue.EventSlug             = currentPlace.Slug;
                    searchVenue.Address               = (currentPlace.AddressLineOne == null ? string.Empty : currentPlace.AddressLineOne) + "," + (currentPlace.AddressLineTwo == null ? string.Empty : currentPlace.AddressLineTwo);
                    searchVenue.Id                    = currentPlace.Id;
                    searchVenue.PlaceWeekOpenDays     = placeWeekOpenDays.ToList();
                    searchVenue.DayTimeMappings       = dayTimeMappings.ToList();
                    searchVenue.PlaceHolidaysList     = placeHolidayDatesRepositoryLists.Where(x => x.EventId == currentPlace.Id).ToList();
                    searchVenue.EventDescription      = currentPlace.EventDescription;
                    searchVenue.EventDetails          = eventDetails.Where(x => x.EventId == currentPlace.Id).ToList();
                    searchVenue.EventTicketDetails    = eventTicketDetails.Where(x => searchVenue.EventDetails.Any(s => s.Id == x.EventDetailId)).ToList();
                    searchVenue.EventTicketAttributes = eventTicketAttributes.Where(x => searchVenue.EventTicketDetails.Any(s => s.Id == x.EventTicketDetailId)).ToList();
                    searchVenue.ticketCategories      = ticketCategories.Where(x => searchVenue.EventTicketDetails.Any(s => s.TicketCategoryId == x.Id)).ToList();

                    if (currentPlace.Latitude != null)
                    {
                        var latArr  = currentPlace.Latitude.Split("E");
                        var longArr = currentPlace.Longitude.Split("E");
                        searchVenue.Latitude  = latArr[0];
                        searchVenue.Longitude = longArr[0];
                    }
                    else
                    {
                        searchVenue.Latitude  = null;
                        searchVenue.Longitude = null;
                    }
                    VenueResult.Add(searchVenue);
                }
                return(new SearchVenueQueryResult()
                {
                    Venues = VenueResult.Distinct().ToList(), Days = Days.ToList()
                });
            }
            catch (Exception e)
            {
                return(new SearchVenueQueryResult()
                {
                    Venues = VenueResult.Distinct().ToList()
                });
            }
        }