protected FIL.Contracts.DataModels.PlaceWeekOpenDays SavePlaceWeekOpenDays(EventScheduleCommand command, Event currentEvent) { PlaceWeekOpenDays currentPlaceWeekOpenDay = new PlaceWeekOpenDays(); currentPlaceWeekOpenDay.AltId = Guid.NewGuid(); currentPlaceWeekOpenDay.DayId = command.EventScheduleModel.StartDateTime.DayOfWeek == System.DayOfWeek.Sunday ? 7 : (int)command.EventScheduleModel.StartDateTime.DayOfWeek; currentPlaceWeekOpenDay.EventId = currentEvent.Id; currentPlaceWeekOpenDay.IsSameTime = true; currentPlaceWeekOpenDay.IsEnabled = true; currentPlaceWeekOpenDay.CreatedUtc = DateTime.UtcNow; currentPlaceWeekOpenDay.UpdatedUtc = DateTime.UtcNow; currentPlaceWeekOpenDay.CreatedBy = command.ModifiedBy; currentPlaceWeekOpenDay.ModifiedBy = command.ModifiedBy; return(_placeWeekOpenDaysRepository.Save(currentPlaceWeekOpenDay)); }
protected FIL.Contracts.DataModels.DayTimeMappings SaveDayTimeMappings(EventScheduleCommand command, PlaceWeekOpenDays placeWeekOpenDays) { DayTimeMappings dayTimeMapping = new DayTimeMappings(); dayTimeMapping.AltId = Guid.NewGuid(); dayTimeMapping.StartTime = command.EventScheduleModel.LocalStartTime; dayTimeMapping.EndTime = command.EventScheduleModel.LocalEndTime; dayTimeMapping.PlaceWeekOpenDayId = placeWeekOpenDays.Id; dayTimeMapping.IsEnabled = true; dayTimeMapping.CreatedUtc = DateTime.UtcNow; dayTimeMapping.UpdatedUtc = DateTime.UtcNow; dayTimeMapping.CreatedBy = command.ModifiedBy; dayTimeMapping.UpdatedBy = command.ModifiedBy; dayTimeMapping.ModifiedBy = command.ModifiedBy; return(_dayTimeMappingsRepository.Save(dayTimeMapping)); }
public void addCalendar(PlaceCalendarCommand command, Event place) { try { /*------------------------- Regular Time ----------------------------*/ var currentIndex = 0; foreach (bool currentDay in command.RegularTimeModel.DaysOpen) { if (currentIndex > 0 && currentDay) { var placeWeekOpenDays = new PlaceWeekOpenDays(); placeWeekOpenDays.AltId = Guid.NewGuid(); placeWeekOpenDays.DayId = currentIndex; placeWeekOpenDays.EventId = place.Id; placeWeekOpenDays.IsSameTime = command.RegularTimeModel.IsSameTime; placeWeekOpenDays.IsEnabled = true; placeWeekOpenDays.CreatedUtc = DateTime.UtcNow; placeWeekOpenDays.UpdatedUtc = DateTime.UtcNow; placeWeekOpenDays.CreatedBy = Guid.NewGuid(); placeWeekOpenDays.UpdatedBy = Guid.NewGuid(); _placeWeekOpenDaysRepository.Save(placeWeekOpenDays); } currentIndex = currentIndex + 1; } if (command.RegularTimeModel.IsSameTime) { var placeWeekOpnday = _placeWeekOpenDaysRepository.GetByEventId(place.Id); foreach (FIL.Contracts.DataModels.PlaceWeekOpenDays currentDay in placeWeekOpnday) { foreach (FIL.Contracts.Commands.PlaceCalendar.TimeViewModel currentTime in command.RegularTimeModel.TimeModel) { var dayTimeMapping = new DayTimeMappings(); dayTimeMapping.AltId = Guid.NewGuid(); dayTimeMapping.StartTime = currentTime.From; dayTimeMapping.EndTime = currentTime.To; dayTimeMapping.PlaceWeekOpenDayId = currentDay.Id; dayTimeMapping.IsEnabled = true; dayTimeMapping.CreatedUtc = DateTime.UtcNow; dayTimeMapping.UpdatedUtc = DateTime.UtcNow; dayTimeMapping.CreatedBy = Guid.NewGuid(); dayTimeMapping.UpdatedBy = Guid.NewGuid(); _dayTimeMappingsRepository.Save(dayTimeMapping); } } } if (!command.RegularTimeModel.IsSameTime) { var placeWeekOpnday = _placeWeekOpenDaysRepository.GetByEventId(place.Id); foreach (FIL.Contracts.DataModels.PlaceWeekOpenDays currentDay in placeWeekOpnday) { foreach (FIL.Contracts.Commands.PlaceCalendar.CustomTimeModelData currentTime in command.RegularTimeModel.CustomTimeModel) { var currentDays = _daysRepository.GetByDayname(currentTime.Day); if (currentDays.Id == currentDay.DayId) { foreach (FIL.Contracts.Commands.PlaceCalendar.TimeViewModel time in currentTime.Time) { var dayTimeMapping = new DayTimeMappings(); dayTimeMapping.AltId = Guid.NewGuid(); dayTimeMapping.StartTime = time.From; dayTimeMapping.EndTime = time.To; dayTimeMapping.PlaceWeekOpenDayId = currentDay.Id; dayTimeMapping.IsEnabled = true; dayTimeMapping.CreatedUtc = DateTime.UtcNow; dayTimeMapping.UpdatedUtc = DateTime.UtcNow; dayTimeMapping.CreatedBy = Guid.NewGuid(); dayTimeMapping.UpdatedBy = Guid.NewGuid(); _dayTimeMappingsRepository.Save(dayTimeMapping); } } } } } /*------------------------- Season Time ----------------------------*/ foreach (FIL.Contracts.Commands.PlaceCalendar.SeasonViewModel currentSeason in command.SeasonTimeModel) { var currentDayIndex = 0; var placeSeasonDetail = new PlaceSeasonDetails(); placeSeasonDetail.Name = currentSeason.Name; placeSeasonDetail.StartDate = currentSeason.StartDate; placeSeasonDetail.EndDate = currentSeason.EndDate; placeSeasonDetail.AltId = Guid.NewGuid(); placeSeasonDetail.EventId = place.Id; placeSeasonDetail.IsSameTime = currentSeason.IsSameTime; placeSeasonDetail.IsEnabled = true; placeSeasonDetail.CreatedUtc = DateTime.UtcNow; placeSeasonDetail.UpdatedUtc = DateTime.UtcNow; placeSeasonDetail.CreatedBy = Guid.NewGuid(); placeSeasonDetail.UpdatedBy = Guid.NewGuid(); var currentSeasonModel = _placeSeasonDetailsRepository.Save(placeSeasonDetail); foreach (bool currentDay in currentSeason.DaysOpen) { if (currentDayIndex > 0 && currentDay) { var day = _daysRepository.Get(currentDayIndex); var seasonDayMappingModel = new SeasonDaysMapping(); seasonDayMappingModel.AltId = Guid.NewGuid(); seasonDayMappingModel.DayId = currentDayIndex; seasonDayMappingModel.PlaceSeasonDetailId = currentSeasonModel.Id; seasonDayMappingModel.IsEnabled = true; seasonDayMappingModel.CreatedUtc = DateTime.UtcNow; seasonDayMappingModel.UpdatedUtc = DateTime.UtcNow; seasonDayMappingModel.CreatedBy = Guid.NewGuid(); seasonDayMappingModel.UpdatedBy = Guid.NewGuid(); var seasonDay = _seasonDaysMappingsRepository.Save(seasonDayMappingModel); if (currentSeason.IsSameTime) { foreach (FIL.Contracts.Commands.PlaceCalendar.TimeViewModel currentTime in currentSeason.SameTime) { var seasonDayTimeMappings = new SeasonDaysTimeMapping(); seasonDayTimeMappings.SeasonDaysMappingId = seasonDay.Id; seasonDayTimeMappings.AltId = Guid.NewGuid(); seasonDayTimeMappings.StartTime = currentTime.From; seasonDayTimeMappings.EndTime = currentTime.To; seasonDayTimeMappings.IsEnabled = true; seasonDayTimeMappings.CreatedUtc = DateTime.UtcNow; seasonDayTimeMappings.UpdatedUtc = DateTime.UtcNow; seasonDayTimeMappings.CreatedBy = Guid.NewGuid(); seasonDayTimeMappings.UpdatedBy = Guid.NewGuid(); _seasonDayTimeMappingsRepository.Save(seasonDayTimeMappings); } } else if (!currentSeason.IsSameTime) { foreach (FIL.Contracts.Commands.PlaceCalendar.SpeecialDateSeasonTimeViewModel currentSpeecialDateSeasonTimeViewModel in currentSeason.Time) { if (currentSpeecialDateSeasonTimeViewModel.Day == day.Name) { foreach (FIL.Contracts.Commands.PlaceCalendar.TimeViewModel currentTime in currentSpeecialDateSeasonTimeViewModel.Time) { var seasonDayTimeMappings = new SeasonDaysTimeMapping(); seasonDayTimeMappings.SeasonDaysMappingId = seasonDay.Id; seasonDayTimeMappings.AltId = Guid.NewGuid(); seasonDayTimeMappings.StartTime = currentTime.From; seasonDayTimeMappings.EndTime = currentTime.To; seasonDayTimeMappings.IsEnabled = true; seasonDayTimeMappings.CreatedUtc = DateTime.UtcNow; seasonDayTimeMappings.UpdatedUtc = DateTime.UtcNow; seasonDayTimeMappings.CreatedBy = Guid.NewGuid(); seasonDayTimeMappings.UpdatedBy = Guid.NewGuid(); _seasonDayTimeMappingsRepository.Save(seasonDayTimeMappings); } } } } } currentDayIndex = currentDayIndex + 1; } } /*------------------------- Special Day/Holiday Time ----------------------------*/ foreach (FIL.Contracts.Commands.PlaceCalendar.SpecialDayViewModel currentSpecialDay in command.SpecialDayModel) { var specialDay = new PlaceSpecialDayTimeMappings(); specialDay.Name = currentSpecialDay.Name; specialDay.SpecialDate = currentSpecialDay.SpecialDate; specialDay.StartTime = currentSpecialDay.From; specialDay.EndTime = currentSpecialDay.To; specialDay.EventId = place.Id; specialDay.AltId = Guid.NewGuid(); specialDay.IsEnabled = true; specialDay.CreatedUtc = DateTime.UtcNow; specialDay.UpdatedUtc = DateTime.UtcNow; specialDay.CreatedBy = Guid.NewGuid(); specialDay.UpdatedBy = Guid.NewGuid(); _placeSpecialDayTimeMappingsRepository.Save(specialDay); } } catch (Exception e) { } }