コード例 #1
0
        /// <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;
        }