public void AddNewScheduleCorrect() { var doctorId = 1; var workDay = new WorkDay { BeginOfDay = new TimeSpan(9, 0, 0), EndOfDay = new TimeSpan(18, 0, 0) }; var schedule = new ScheduleTransfer { DoctorId = doctorId, Monday = workDay, Tuesday = workDay, Wednesday = workDay, Thursday = workDay, Friday = workDay, Saturday = workDay, Sunday = workDay, IsApproved = false, }; _workDayRepository.Setup(rep => rep.GetOrAddNewWorkDay(workDay.BeginOfDay, workDay.EndOfDay)) .Returns(1); Assert.DoesNotThrow(() => _doctorServices.AddNewSchedule(schedule)); }
public void AddNewSchedule(ScheduleTransfer scheduleTransfer) { if (!IsCorrectScheduleTimesOfWorkDay(scheduleTransfer)) { throw new WarningException(ExceptionMessages.TimeOfWorkDayIsNonCorrect); } if (!IsCorrectScheduleTimes(scheduleTransfer)) { throw new WarningException(ExceptionMessages.WorkDayIsNotCorrect); } SetWorkDaysId(scheduleTransfer); _scheduleRepository.AddFirstSchedule(new Schedule { DoctorId = scheduleTransfer.DoctorId, MondayId = scheduleTransfer.Monday?.Id ?? 0, TuesdayId = scheduleTransfer.Tuesday?.Id ?? 0, WednesdayId = scheduleTransfer.Wednesday?.Id ?? 0, ThursdayId = scheduleTransfer.Thursday?.Id ?? 0, FridayId = scheduleTransfer.Friday?.Id ?? 0, SaturdayId = scheduleTransfer.Saturday?.Id ?? 0, SundayId = scheduleTransfer.Sunday?.Id ?? 0, IsApproved = false }); UpdateDoctorStatus(scheduleTransfer.DoctorId); }
private static bool IsCorrectScheduleTimesOfWorkDay(ScheduleTransfer scheduleTransfer) { return(IsCorrectTimeOfWorkDay(scheduleTransfer.Monday) && IsCorrectTimeOfWorkDay(scheduleTransfer.Tuesday) && IsCorrectTimeOfWorkDay(scheduleTransfer.Wednesday) && IsCorrectTimeOfWorkDay(scheduleTransfer.Thursday) && IsCorrectTimeOfWorkDay(scheduleTransfer.Friday) && IsCorrectTime(scheduleTransfer.Saturday) && IsCorrectTime(scheduleTransfer.Sunday)); }
private void SetWorkDaysId(ScheduleTransfer transfer) { if (transfer.Monday != null) { transfer.Monday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Monday.BeginOfDay, transfer.Monday.EndOfDay); } if (transfer.Tuesday != null) { transfer.Tuesday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Tuesday.BeginOfDay, transfer.Tuesday.EndOfDay); } if (transfer.Wednesday != null) { transfer.Wednesday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Wednesday.BeginOfDay, transfer.Wednesday.EndOfDay); } if (transfer.Thursday != null) { transfer.Thursday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Thursday.BeginOfDay, transfer.Thursday.EndOfDay); } if (transfer.Friday != null) { transfer.Friday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Friday.BeginOfDay, transfer.Friday.EndOfDay); } if (transfer.Saturday != null) { transfer.Saturday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Saturday.BeginOfDay, transfer.Saturday.EndOfDay); } if (transfer.Sunday != null) { transfer.Sunday.Id = _workDayRepository.GetOrAddNewWorkDay(transfer.Sunday.BeginOfDay, transfer.Sunday.EndOfDay); } }