/// <summary> /// Dependent on the checktype, method checks either for overlaps between the new submitted vacation request and DB-stored lock periods, /// or between overlaps with a vacation request by the deputy /// </summary> /// <param name="CheckType"> an int value that choose the test type</param> /// <returns> true if no lock or overlap is present, else false</returns> public Boolean Validate(int CheckType) { Boolean result = true; // assumes that no locks or overlaps exist switch (CheckType) { case CHECK_CATEGORY_LOCK_PERIOD: DBQuery dbqLock = new DBQuery(); // the DB Query checks whether on ore more lock period(s) lie(s) in vacation request time period var lockList = dbqLock.SelectLockPeriods(_vacationRequest); if (lockList.Count() > 0) { result = false; } break; case CHECK_CATEGORY_VACATION_OVERLAP_PERIOD: DBQuery dbqDeputy = new DBQuery(); String deputyID = dbqDeputy.SelectDeputy(_vacationRequest); if ( !deputyID.Equals("null") && deputyID != String.Empty) { var overlapList = dbqDeputy.SelectUncanceledEmployeeVacationRequestInTimePeriod(_vacationRequest, deputyID); if (overlapList.Count() > 0) { foreach (var i in overlapList) { //change OverlapNote of existing VacationRequest of Deputy DBQuery dbq = new DBQuery(); dbq.UpdateVacationRequestPeriodOverlapNote(i.Item1, true); } result = false; } } break; default: break; } return result; }
/// <summary> /// Removes the TRUE-flag in all vacation requests of the shift partner, if the given vacation request is cancelled by its requester. /// Use requester ID of vacation request to identity the shiftpartner and startdate and enddate to retrieve vacation requests of the deputy /// </summary> /// <param name="vacationRequest">use requesterID to find deputy, use time period to specify overlap time period </param> /// <returns>TRUE if successful, else FALSE</returns> private Boolean RemoveVacationPeriodOverlapNote(VacationRequest vacationRequest) { Boolean result = true; DBQuery dbq = new DBQuery(); String deputyID = dbq.SelectDeputy(vacationRequest); if (!deputyID.Equals("null") && deputyID != String.Empty) { var overlapList = dbq.SelectUncanceledEmployeeVacationRequestInTimePeriod(vacationRequest, deputyID); if (overlapList.Count > 0) { foreach (var i in overlapList) { //change OverlapNote of existing VacationRequest of Deputy result = dbq.UpdateVacationRequestPeriodOverlapNote(i.Item1, false); if (!result) break; } } } return result; }