Ejemplo n.º 1
0
        private void approveDenyDailyLeave(bool isApprove, Domain.User currentUser, TimeSheetManager timeSheetManager, DailyLeaveManager dlm, DailyLeave dailyLeave, string userDescription)
        {
            if (dailyLeave.WorkflowStage.Type == "Final")
            {
                throw new Exception("هم اکنون تایید نهایی می باشد");
            }
            var isManager = timeSheetManager.IsUserOrganisationMnager(dailyLeave.UserID, currentUser);

            if (dailyLeave.WorkflowStage.Type == "Manager" && !isManager)
            {
                throw new Exception("آیتم منتظر تایید مدیر ستادی است");
            }

            var data = new ApproveAndDenyJson()
            {
                id              = dailyLeave.ID.ToString(),
                date            = DateTime.Now,
                description     = userDescription,
                workflowStageID = dailyLeave.WorkflowStageID
            };

            if (isApprove)
            {
                dlm.Approve(dailyLeave);
                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);
            }
            else
            {
                dlm.Deny(dailyLeave);
                HistoryUtilities.RegisterApproveHistory(data, this._uow, currentUser);
            }
        }
        public ActionResult ApproveConfirmed(Guid id)
        {
            DailyLeaveManager dlm = new DailyLeaveManager(UOW);
            var result            = dlm.GetByID(id);

            dlm.Approve(result);
            UOW.SaveChanges();

            return(RedirectToAction("ApproveIndex", new { ac = "Approve" }));
        }
        public ActionResult ApproveAll()
        {
            DailyLeaveManager dlm = new DailyLeaveManager(UOW);
            var dailyLeaves       = dlm.GetByOrganisationID(this.CurrentUser.OrganizationUnitID).
                                    Where(x => x.WorkflowStage.Order == 3);

            foreach (var leave in dailyLeaves)
            {
                dlm.Approve(leave);
            }
            UOW.SaveChanges();
            return(RedirectToAction("ApproveIndex", new { ac = "ApproveAll" }));
        }