コード例 #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public List<PendingVacationRequestViewItem> GetPendingRequests()
        {
            String currentUserId = User.Identity.GetUserId();
            List<String> statesListWithShiftPartner = new List<string> { DBQuery.AGREED, DBQuery.REJECTED_BY_DEPUTY };
            List<String> statesListWithoutShiftPartner = new List<string> { DBQuery.SUBMITTED };

            DBQuery dbq = new DBQuery();

            var DivisionVacationRequestList = new List<PendingVacationRequestViewItem>();
            var SortedDivisionVacationRequestList = new List<PendingVacationRequestViewItem>();
            var EmployeeList = new List<Employee>();

            EmployeeList.AddRange(dbq.SelectEmployeesOfDivision(currentUserId));
            if (EmployeeList.Count() > 0)
            {
                foreach (Employee e in EmployeeList)
                {
                    // look for all employees of division but Division Manager self
                    if (!e.getEmployeeID().Equals(currentUserId))
                    {
                        var vrList = new List<VacationManagement.VacationRequest>();
                        String requesterName = e.getFullName();
                        String deputyID = dbq.SelectShiftPartner(e.getEmployeeID());
                        int remainingVacationDays = dbq.SelectRemainingVacationDays(e.getEmployeeID());

                        // has shiftpartner
                        if (!deputyID.Equals("null"))
                        {
                            String deputyName = dbq.SelectEmployeeFullName(deputyID);

                            foreach (string s in statesListWithShiftPartner)
                            {
                                vrList.AddRange(dbq.SelectVacationRequestsInState(e.getEmployeeID(), s));
                            }
                            foreach (VacationManagement.VacationRequest vr in vrList)
                            {
                                DivisionVacationRequestList.Add(new PendingVacationRequestViewItem(vr, requesterName, deputyName, remainingVacationDays));
                            }
                        }
                        else
                        {
                            String deputyName = "-";
                            foreach (string s in statesListWithoutShiftPartner)
                            {
                                vrList.AddRange(dbq.SelectVacationRequestsInState(e.getEmployeeID(), s));
                            }
                            foreach (VacationManagement.VacationRequest vr in vrList)
                            {
                                DivisionVacationRequestList.Add(new PendingVacationRequestViewItem(vr, requesterName, deputyName, remainingVacationDays));
                            }
                        }
                    }
                }
                // Sort all Vacation Requests by Startdate, Ascending
               SortedDivisionVacationRequestList = DivisionVacationRequestList.OrderBy(c => c.getVacationStartDate()).ToList();
            }
            return SortedDivisionVacationRequestList;
        }
コード例 #2
0
        public ActionResult ShowVacationSummary()
        {
            
            String currentUserId = User.Identity.GetUserId();

            DBQuery dbq = new DBQuery();
            int remaining = dbq.SelectRemainingVacationDays(currentUserId);
            int total = dbq.SelectVacationDaysTotal(currentUserId);
            int prevYear = dbq.SelectVacationDaysPreviousYear(currentUserId);
            GUIManagement.VacationEntitlementViewItem summary = new GUIManagement.VacationEntitlementViewItem(currentUserId,remaining,total,prevYear);


            return View(summary);
        }
コード例 #3
0
        /// <summary>
        /// (1) checks if remaining vacation days of employee suffice, 
        /// (2) sets lock period flag if appropriate,
        /// (3) sets vacation period overlap flag if appropriate
        /// </summary>
        /// <param name="VacationRequest"> a vacation request, passed by reference</param>
        /// <returns></returns>
        public Boolean Validate(VacationRequest VacationRequest)
        {
            Boolean result = false;

            ///<remarks> this value must be numeric</remarks>
            //checks remaining vacation days
            DBQuery dbq = new DBQuery();
            int remainingVacationDays = dbq.SelectRemainingVacationDays(VacationRequest.getEmployeeID());

            // determine working days in vacation request
            int vacationWorkingDays = VacationRequest.DetermineWorkingDaysInVacationRequest(VacationRequest);

            // only proceed if time period of vacation request contains working days
            if (vacationWorkingDays > 0)
            {
                VacationRequest.setNetVacationDays(vacationWorkingDays);

                // Check  VacationRequest overlap with others already existing VacationRequests of Requester without state "canceled"
                var VRList = dbq.SelectUncanceledEmployeeVacationRequestInTimePeriod(VacationRequest, VacationRequest.getEmployeeID());

                Boolean overlap = false;
                Boolean insufficientRemainingVacationDays = false;

                if (VRList.Count > 0)
                {
                    overlap = true;
                    ErrorState.ErrorStateInstance.setError(ErrorState.OVERLAP_WITH_OWN_VACATION_REQUEST);
                }
                if (remainingVacationDays < vacationWorkingDays)
                {
                    insufficientRemainingVacationDays = true;
                    ErrorState.ErrorStateInstance.setError(ErrorState.INSUFFICIENT_REMAINING_VACATION_DAYS);
                }
                // if requester has enough remaining Vacation Days AND no submitted vacation request(s) in this time period, go ahead
                if (!insufficientRemainingVacationDays && !overlap)
                {
                    TimePeriodOverlapCheck check = new TimePeriodOverlapCheck(VacationRequest);

                    //check lock period
                    if (!check.Validate(TimePeriodOverlapCheck.CHECK_CATEGORY_LOCK_PERIOD))
                    {
                        //overlap existing
                        VacationRequest.setVacationLockPeriodNote(true);
                    }

                    //check overlap period with Deputy
                    if (!check.Validate(TimePeriodOverlapCheck.CHECK_CATEGORY_VACATION_OVERLAP_PERIOD))
                    {
                        //overlap existing
                        VacationRequest.setVacationPeriodOverlapNote(true);
                    }

                    if (VacationRequest.getVacationStartDate() < DateTime.Now)
                    {
                        //if VacationRequestEndDate is in past the new Processingstatus is: agreed, so the decision of the DivisionManager is the next step
                        VacationRequest.setVacationRequestProcessingState(VacationRequestProcessingState.agreed);
                    }
                    result = true;
                }
            }
            else
            {
                ErrorState.ErrorStateInstance.setError(ErrorState.ZERO_NET_VACATION_DAYS_IN_VACATION_REQUEST);
            }
            return result;
        }
コード例 #4
0
 private Boolean RestoreVacationDaysInEmployeeVacationEntitlement(VacationRequest vacationRequest)
 {
     Boolean result = false;
     DBQuery dbq = new DBQuery();
     int netWorkingDays = vacationRequest.getNetVacationDays();
     int remainingVacationDays = dbq.SelectRemainingVacationDays(vacationRequest.getEmployeeID());
     result = dbq.UpdateRemainingVacationDays(vacationRequest.getEmployeeID(), netWorkingDays + remainingVacationDays);
     return result;
 }
コード例 #5
0
        public ActionResult Delete(ulong id)
        {
            DBQuery dbq = new DBQuery();

            VacationRequest vr = dbq.SelectVacationRequest(id);
            int netWorkingDays = vr.getNetVacationDays();
            int remainingVacationDays = dbq.SelectRemainingVacationDays(vr.getEmployeeID());
            Boolean update = dbq.UpdateRemainingVacationDays(vr.getEmployeeID(), netWorkingDays + remainingVacationDays);
            if (update)
            {
                Boolean result = dbq.DeleteVacationRequest(id);
                if (result)
                {
                    ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
                    TempData["success"] = "Der Urlaubsantrag wurde erfolgreich gelöscht";
                }
                else
                {
                    ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
                    //TempData["error"] = "Die Änderung konnte nicht in die Datenbank übernommen werden!";
                }
            }
            else
            {
                ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
                //TempData["error"] = "Die Änderung konnte nicht in die Datenbank übernommen werden!";
            }

            int lastError = ErrorState.ErrorStateInstance.getLastError();
            if (lastError != ErrorState.OK)
            {
                TempData["error"] = "Der Urlaubsantrag konnte nicht gelöscht werden. Grund: " + ErrorState.ErrorStateInstance.getErrorMessage(lastError);
            }

            return RedirectToAction("All");
        }
コード例 #6
0
ファイル: VacationRequest.cs プロジェクト: timnicolaisen/eule
        /// <summary>
        /// 1. writes an information email
        /// 2. writes vacation request in the database
        /// </summary>
        /// <returns>Boolean status if the insert into database was successful</returns>
        private Boolean SendDataToDB()
        {
            Boolean result = false;
            DBQuery dbq = new DBQuery();
            result = dbq.InsertNewVacationRequest(this);

            if (result)
            {
                int remainingVacationDays = dbq.SelectRemainingVacationDays(_employeeID) - this._netVacationDays;
                result = dbq.UpdateRemainingVacationDays(_employeeID, remainingVacationDays);
            }
            if (!result)
            {
                ErrorState.ErrorStateInstance.setError(ErrorState.DATABASE_ERROR);
            }
            return result;
        }