public List <FIL.Contracts.DataModels.ScheduleDetail> GetScheduleDetails(FIL.Contracts.Commands.CreateEventV1.EventRecurranceCommand eventRecurranceCommand) { List <FIL.Contracts.DataModels.ScheduleDetail> eventSchedules = new List <Contracts.DataModels.ScheduleDetail>(); if (eventRecurranceCommand.ActionType == Contracts.Commands.CreateEventV1.ActionType.BulkDelete) { var alleventSchedules = _eventScheduleRepository.GetAllByEventId(eventRecurranceCommand.EventId); var eventDetails = _eventDetailRepository.GetByEventId(eventRecurranceCommand.EventId); var eventAttributes = _eventAttributeRepository.GetByEventDetailId(eventDetails.Id); var StartDate = eventRecurranceCommand.StartDateTime; // new DateTime(eventRecurranceCommand.StartDateTime.Year, eventRecurranceCommand.StartDateTime.Month, eventRecurranceCommand.StartDateTime.Day).ToUniversalTime(); var EndDate = eventRecurranceCommand.EndDateTime; // new DateTime(eventRecurranceCommand.EndDateTime.Year, eventRecurranceCommand.EndDateTime.Month, eventRecurranceCommand.EndDateTime.Day).ToUniversalTime(); var scheduleDetails = _scheduleDetailRepository.GetAllByEventScheduleIds(alleventSchedules.Select(s => s.Id).ToList()).Where(s => s.StartDateTime.Date >= StartDate.Date && s.EndDateTime.Date <= EndDate.Date).OrderBy(s => s.StartDateTime).ToList(); foreach (var scheduleDetail in scheduleDetails) { var startDate = _localTimeZoneConvertProvider.ConvertToLocal(scheduleDetail.StartDateTime, eventAttributes.TimeZone); var endDate = _localTimeZoneConvertProvider.ConvertToLocal(scheduleDetail.EndDateTime, eventAttributes.TimeZone); if (startDate.ToString(@"HH:mm", new CultureInfo("en-US")) == eventRecurranceCommand.LocalStartTime && endDate.ToString(@"HH:mm", new CultureInfo("en-US")) == eventRecurranceCommand.LocalEndTime) { eventSchedules.Add(scheduleDetail); } } return(eventSchedules); // return scheduleDetails.Where(s => s.StartDateTime.ToString(@"HH:mm", new CultureInfo("en-US")) == eventRecurranceCommand.StartDateTime.ToString(@"HH:mm", new CultureInfo("en-US")) && s.EndDateTime.ToString(@"HH:mm", new CultureInfo("en-US")) == eventRecurranceCommand.EndDateTime.ToString(@"HH:mm", new CultureInfo("en-US"))).ToList(); } else { var scheduleDetail = _scheduleDetailRepository.Get(eventRecurranceCommand.ScheduleDetailId); eventSchedules.Add(scheduleDetail); return(eventSchedules); } }
public void SaveTransactionScheduleDetail(long TransactionDetailId, long ScheduleDetailId) { try { var scheduleDetail = _scheduleDetailRepository.Get(ScheduleDetailId); var transactionScheduleDetail = new TransactionScheduleDetail { TransactionDetailId = TransactionDetailId, ScheduleDetailId = ScheduleDetailId, StartDateTime = scheduleDetail.StartDateTime, EndDateTime = scheduleDetail.EndDateTime, IsEnabled = true, CreatedBy = Guid.NewGuid(), CreatedUtc = DateTime.UtcNow }; _transactionScheduleDetail.Save(transactionScheduleDetail); } catch (Exception e) { _logger.Log(Logging.Enums.LogCategory.Error, e); } }
public List <FIL.Contracts.DataModels.ScheduleDetail> GetScheduleDetails(FIL.Contracts.Commands.CreateEventV1.EventRecurranceCommand eventRecurranceCommand) { List <FIL.Contracts.DataModels.ScheduleDetail> eventSchedules = new List <Contracts.DataModels.ScheduleDetail>(); List <FIL.Contracts.DataModels.ScheduleDetail> eventSchedules1 = new List <Contracts.DataModels.ScheduleDetail>(); var startDateTime = _commonUtilityProvider.GetUtcDate(eventRecurranceCommand.StartDateTime, eventRecurranceCommand.LocalStartTime, eventRecurranceCommand.TimeZoneOffSet); var endDateTime = _commonUtilityProvider.GetUtcDate(eventRecurranceCommand.EndDateTime, eventRecurranceCommand.LocalEndTime, eventRecurranceCommand.TimeZoneOffSet); if (eventRecurranceCommand.ActionType == Contracts.Commands.CreateEventV1.ActionType.BulkReschedule) { SaveEventSchedule(eventRecurranceCommand); eventSchedules = _scheduleDetailRepository.GetAllByEventScheduleId(eventRecurranceCommand.EventScheduleId).ToList(); } else { var scheduleDetail = _scheduleDetailRepository.Get(eventRecurranceCommand.ScheduleDetailId); scheduleDetail.StartDateTime = startDateTime; scheduleDetail.EndDateTime = endDateTime; scheduleDetail.UpdatedBy = eventRecurranceCommand.ModifiedBy; scheduleDetail.ModifiedBy = eventRecurranceCommand.ModifiedBy; scheduleDetail.UpdatedUtc = DateTime.UtcNow; eventSchedules.Add(scheduleDetail); return(eventSchedules); } foreach (var scheduleDetail in eventSchedules) { if (scheduleDetail.StartDateTime.Date >= startDateTime.Date && scheduleDetail.EndDateTime.Date <= endDateTime.Date) { scheduleDetail.StartDateTime = _commonUtilityProvider.GetUtcDate(scheduleDetail.StartDateTime, eventRecurranceCommand.LocalStartTime, eventRecurranceCommand.TimeZoneOffSet); scheduleDetail.EndDateTime = _commonUtilityProvider.GetUtcDate(scheduleDetail.EndDateTime, eventRecurranceCommand.LocalEndTime, eventRecurranceCommand.TimeZoneOffSet); scheduleDetail.UpdatedBy = eventRecurranceCommand.ModifiedBy; scheduleDetail.ModifiedBy = eventRecurranceCommand.ModifiedBy; scheduleDetail.UpdatedUtc = DateTime.UtcNow; eventSchedules1.Add(scheduleDetail); } } return(eventSchedules); }