public void CopyRange(DoctorScheduleCopyRangeSP p) { BusinessRuleErrorList errors = new BusinessRuleErrorList(); if (p.DestinationUnixEpoch > p.SourceUnixEpoch) { if (p.DestinationUnixEpoch < p.SourceUnixEpoch + (p.NumberOfDays * 86400)) { throw new BRException(BusinessErrorStrings.DoctorSchedule.CopyOverlapInCopy); } } if (p.SourceUnixEpoch > p.DestinationUnixEpoch) { if (p.SourceUnixEpoch < p.DestinationUnixEpoch + (p.NumberOfDays * 86400)) { throw new BRException(BusinessErrorStrings.DoctorSchedule.CopyOverlapInCopy); } } }
/// <summary> /// Copies available times of a day to another day (by period) /// </summary> /// <param name="p"></param> public void CopyRange(DoctorScheduleCopyRangeSP p) { ((DoctorScheduleBR)this.BusinessLogicObject).CopyRange(p); var list = GetByRange(new DoctorScheduleGetByRangeSP() { DoctorID = p.DoctorID, StartUnixEpoch = p.SourceUnixEpoch, EndUnixEpoch = p.SourceUnixEpoch + (p.NumberOfDays * 86400) }); foreach (var item in list) { int newSlotUnixEpoch = p.DestinationUnixEpoch + (item.SlotUnixEpoch - p.SourceUnixEpoch); if (IsTimeAvailable(new DoctorScheduleIsTimeAvailableSP() { DoctorID = p.DoctorID, SelectedDateTimeUnixEpoch = newSlotUnixEpoch }) == false) { DoctorSchedule obj = new DoctorSchedule(); obj.DoctorID = item.DoctorID; obj.DoctorScheduleVisitPlaceID = item.DoctorScheduleVisitPlaceID; obj.NumberOfAllowedPatients = item.NumberOfAllowedPatients; obj.NumberOfRegisteredPatients = 0; obj.IsWalkingQueue = false; obj.IsDisabled = false; obj.SlotUnixEpoch = newSlotUnixEpoch; try { Insert(obj); } catch (BRException) { // do nothing for business exceptions } } } }