Ejemplo n.º 1
0
 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 {
         });
     }
 }
Ejemplo n.º 2
0
        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)
            {
            }
        }