Exemplo n.º 1
0
        public SchedulingTableModel CreateOrUpdate(SchedulingTableModel model)
        {
            Logger.Debug($"{model}");

            if (model == null)
            {
                throw new System.ArgumentNullException("model");
            }

            SchedulingTable schedule = null;

            if (model.Id == null || model.Id == System.Guid.Empty)
            {
                schedule = this.UnitOfWork.SchedulingTableRepository.CreateSchedule(model.SemesterId, model.Name, model.ShortName, model.HighlightColor, model.LogoUrl, model.IsActive);
            }
            else
            {
                schedule = this.UnitOfWork.SchedulingTableRepository.UpdateSchedule(model.Id, model.SemesterId, model.Name, model.ShortName, model.HighlightColor, model.LogoUrl, model.IsActive);
            }

            this.UnitOfWork.SaveChanges();

            SchedulingTableModel scheduleModel = Mapper.Map <Models.SchedulingTable, Models.SchedulingTableModel>(schedule);

            return(scheduleModel);
        }
Exemplo n.º 2
0
        public ScheduleStageInfo GetScheduleStageInfo(Guid id)
        {
            Logger.Debug($"{id}");

            if (id == null || id == System.Guid.Empty)
            {
                throw new System.ArgumentNullException("id");
            }

            SchedulingTable schedule = this.UnitOfWork.SchedulingTableRepository.GetById(id);

            ScheduleStageInfo scheduleStageInfo = Mapper.Map <Models.SchedulingTable, Models.ScheduleStageInfo>(schedule);

            return(scheduleStageInfo);
        }
Exemplo n.º 3
0
        public ScheduleStageInfo GetSemesterScheduleStageInfo(Guid semsterId)
        {
            Logger.Debug($"{semsterId}");

            if (semsterId == null || semsterId == System.Guid.Empty)
            {
                throw new System.ArgumentNullException("semsterId");
            }


            SchedulingTable schedule = this.UnitOfWork.SchedulingTableRepository.GetSemesterDefaultSchedule(semsterId);

            ScheduleStageInfo scheduleStageInfo = Mapper.Map <Models.SchedulingTable, Models.ScheduleStageInfo>(schedule);

            return(scheduleStageInfo);
        }
Exemplo n.º 4
0
        public Schedule.Models.ScheduleStageInfo ValidateScheduleBoard(Guid scheduleId)
        {
            Logger.Debug($"Start validating schedule board: {scheduleId}");

            if (scheduleId == null || scheduleId == Guid.Empty)
            {
                Logger.Error($"ScheduleId is empty.");
                throw new ArgumentNullException("scheduleId");
            }

            this.UnitOfWork.SchedulingTableRepository.ChangedValidated(scheduleId);
            this.UnitOfWork.SaveChanges();

            Logger.Debug($"Complete validating schedule board: {scheduleId}");

            SchedulingTable schedule = this.UnitOfWork.SchedulingTableRepository.GetById(scheduleId);

            ScheduleStageInfo scheduleStageInfo = Mapper.Map <Schedule.Models.SchedulingTable, Schedule.Models.ScheduleStageInfo>(schedule);

            return(scheduleStageInfo);
        }
Exemplo n.º 5
0
        public ScheduleStageInfo CalculateSemesterScheduleBoard(Guid semesterId)
        {
            Schedule.Models.SchedulingTable scheduleTable = this.UnitOfWork.SchedulingTableRepository.GetSemesterDefaultSchedule(semesterId);

            Guid scheduleId = Guid.Empty;

            if (scheduleTable == null)
            {
                scheduleTable = this.UnitOfWork.SchedulingTableRepository.CreateSchedule(semesterId);
                this.UnitOfWork.SaveChanges();
            }

            scheduleId = scheduleTable.Id;

            this.UnitOfWork.SchedulingTableRepository.ChangedValidated(scheduleId);
            Logger.Debug($"Changed status of schedule to VALIDATED: {scheduleId}");
            this.UnitOfWork.SaveChanges();

            this.UnitOfWork.SchedulingTableRepository.ChangeGeneratingStarted(scheduleId);
            Logger.Debug($"Changed status of schedule to GENERATING: {scheduleId}");
            this.UnitOfWork.SaveChanges();

            this.ClearScheduleBoard(scheduleId);
            Logger.Debug($"Cleared/Reset schedule-board: {scheduleId}");

            ScheduleBoard board = this.GenerateScheduleBoard(scheduleId);

            this.SaveScheduleBoard(board);

            this.UnitOfWork.SchedulingTableRepository.ChangeGeneratingCompleted(scheduleId);
            Logger.Debug($"Changed status of schedule to GENERATED: {scheduleId}");

            this.UnitOfWork.SaveChanges();

            SchedulingTable schedule = this.UnitOfWork.SchedulingTableRepository.GetById(scheduleId);

            ScheduleStageInfo scheduleStageInfo = Mapper.Map <Schedule.Models.SchedulingTable, Schedule.Models.ScheduleStageInfo>(schedule);

            return(scheduleStageInfo);
        }