예제 #1
0
 public ScheduleSlot ToScheduleSlot(ScheduleSlotDto scheduleSlotDto)
 {
     return(new ScheduleSlot()
     {
         Id = scheduleSlotDto.Id,
         Start = scheduleSlotDto.Start.ToLocalTime(),
         End = scheduleSlotDto.End.ToLocalTime(),
         MovieId = scheduleSlotDto.MovieId,
         Reservations = ReservationsListToString(scheduleSlotDto.Reservations),
         ScheduleId = scheduleSlotDto.ScheduleId
     });
 }
예제 #2
0
        private List <ScheduleSlotDto> MovieScheduleToList(string scheduleSlotString)
        {
            List <ScheduleSlotDto> scheduleSlots = new List <ScheduleSlotDto>();

            string[] scheduleSlotIds = scheduleSlotString.Split(';', StringSplitOptions.RemoveEmptyEntries);

            foreach (string id in scheduleSlotIds)
            {
                ScheduleSlotDto scheduleSlot = ToScheduleSlotDto(scheduleRepository.GetScheduleSlotById(int.Parse(id)));
                if (scheduleSlot != null)
                {
                    scheduleSlots.Add(scheduleSlot);
                }
            }

            return(scheduleSlots);
        }
예제 #3
0
        public Result CopySchedule(ScheduleCopyTargetDto scheduleCopyTarget)
        {
            if (scheduleCopyTarget.ScheduleSlotIds == null)
            {
                return(new Result());
            }
            int lastCopyTargetId = scheduleCopyTarget.ScheduleSlotIds.Last();

            for (int i = 0; i < scheduleCopyTarget.ScheduleSlotIds.Count; i++)
            {
                ScheduleSlotDto original     = GetScheduleSlotById(scheduleCopyTarget.ScheduleSlotIds.ElementAt(i));
                ScheduleSlotDto scheduleSlot = new ScheduleSlotDto()
                {
                    MovieId      = original.MovieId,
                    ScheduleId   = original.ScheduleId,
                    Reservations = new List <ReservationDto>()
                };

                TimeSpan diff = scheduleCopyTarget.TargetDate.ToLocalTime().Date.Subtract(original.Start);

                scheduleSlot.Start = original.Start.Add(diff).ToLocalTime();
                scheduleSlot.End   = original.End.Add(diff).ToLocalTime();

                Result result = scheduleRepository.ScheduleMovie(scheduleCopyTarget.RoomIds.ElementAt(i), parser.ToScheduleSlot(scheduleSlot));
                if (!result.Success)
                {
                    if (result.Exception == null)
                    {
                        Log.Warning("Couldn't copy schedule slot with id {0}!", scheduleSlot.Id);
                    }
                    else
                    {
                        Log.Error(result.Exception, "Exception thrown while trying to copy schedule slot with id {0}!", scheduleSlot.Id);
                    }
                }
            }

            return(new Result());
        }
예제 #4
0
 public Result ScheduleMovie(int roomId, ScheduleSlotDto scheduleSlot)
 {
     return(scheduleRepository.ScheduleMovie(roomId, parser.ToScheduleSlot(scheduleSlot)));
 }