public ActionResult CancelDelegation(int Id)
        {
            deptId = GetDeptId();
            DelegationDAO delegationDAO = new DelegationDAO();

            //status = "completed";
            //departmentDAO.UpdateDepartmentDelegation(deptId, delegationDAO.GetDelegationById(Id).EmployeeId, status);
            //delegationDAO.CancelDelegation(Id);
            if (!departmentDAO.CancelDelegation(deptId, Id))
            {
                SetFlash(Enums.FlashMessageType.Error, "Something went wrong!");

                return(RedirectToAction("Delegation", "DepartmentHead"));
            }
            ///// start Email /////
            Delegation delegation = delegationDAO.GetDelegationById(Id);
            EmailDAO   emailDAO   = new EmailDAO();
            Employee   employee   = emailDAO.EmailDelegation(delegation.EmployeeId);
            Email      email      = new Email();

            email.SendEmail(employee.Email, "Delegation", "Dear " + delegation.EmployeeName + ",Please Check delegation status");
            ///////////////////////
            SetFlash(Enums.FlashMessageType.Success, "You've cancelled Authority Delegation!");

            return(RedirectToAction("Delegation", "DepartmentHead"));
        }
示例#2
0
        public MResponseList <Delegation> getDelegates(string deptId)
        {
            DelegationDAO delegationDAO        = new DelegationDAO();
            MResponseList <Delegation> respone = new MResponseList <Delegation>()
            {
                ResList = delegationDAO.GetDelegations(deptId),
            };

            return(respone);
        }
示例#3
0
 //EmployeeDAO _employeeDAO;
 //RequisitionDAO _requisitionDAO;
 //RequisitionItemDAO _requisitionItemDAO;
 //ItemDAO _itemDAO;
 //DepartmentDAO _deparmentDAO;
 //CollectionPointDAO _collectionPointDAO;
 public DepartmentHeadController()
 {
     _employeeDAO            = new EmployeeDAO();
     _requisitionDAO         = new RequisitionDAO();
     _requisitionItemDAO     = new RequisitionItemDAO();
     _itemDAO                = new ItemDAO();
     _departmentDAO          = new DepartmentDAO();
     _notificationChannelDAO = new NotificationChannelDAO();
     _collectionPointDAO     = new CollectionPointDAO();
     _delegationDAO          = new DelegationDAO();
 }
示例#4
0
 public HomeController()
 {
     _employeeDAO            = new EmployeeDAO();
     _collectionPointDAO     = new CollectionPointDAO();
     _notificationChannelDAO = new NotificationChannelDAO();
     _requisitionDAO         = new RequisitionDAO();
     _delegationDAO          = new DelegationDAO();
     _departmentDAO          = new DepartmentDAO();
     _disbursementDAO        = new DisbursementDAO();
     _disbursementItemDAO    = new DisbursementItemDAO();
 }
示例#5
0
        public MResponse CancelDelegate(int headId, string deptId, Delegation delegation)
        {
            bool success = new DelegationDAO().CancelDelegation(deptId, delegation.Id);

            if (success)
            {
                Email    email = new Email();
                Employee e     = new EmployeeDAO().GetEmployeeById(headId);
                email.SendEmail(delegation.Email, "Authority Delegation Cancel", email.CancelMsgBody(delegation, e.Name));
            }
            MResponse response = new MResponse(success);

            return(response);
        }
示例#6
0
        public MResponse PostDelegate(Delegation delegation, int headId, string deptId)
        {
            bool success = new DelegationDAO().InsertDelegation(delegation, deptId);

            if (success)
            {
                Email    email = new Email();
                Employee e     = new EmployeeDAO().GetEmployeeById(headId);
                email.SendEmail(delegation.Email, "Authority Delegation", email.CreateMsgBody(delegation, e.Name));
            }
            MResponse response = new MResponse(success);

            return(response);
        }
        public ActionResult ViewDelegationStatus()
        {
            EmployeeDAO employeeDAO = new EmployeeDAO();
            Employee    emp         = new Employee();

            emp = employeeDAO.GetEmployeeByUsername(Session["username"].ToString());
            int empId = emp.Id;
            //int empId = 11237;
            // String today = DateTime.Now.ToString("yyyy/MM/dd");
            DateTime      today = DateTime.Today;
            DelegationDAO dele  = new DelegationDAO();

            ViewData["delegation"] = dele.GetDelegationStatus(empId);
            ViewData["today"]      = today;
            return(View());
        }
示例#8
0
        public override void OnActionExecuting(ActionExecutingContext aec)
        {
            DelegationDAO delegationDAO = new DelegationDAO();
            EmployeeDAO   employeeDAO   = new EmployeeDAO();

            Debug.WriteLine("OnActionExecuting", aec.RouteData);
            int    IdEmployee     = (int)aec.HttpContext.Session["IdEmployee"];
            string controllerName = aec.ActionDescriptor.ControllerDescriptor.ControllerName;

            if (controllerName.Contains("Employee"))
            {
                if (delegationDAO.CheckIfInDelegationPeriod(IdEmployee))
                {
                    Debug.WriteLine("OnActionExecuting should be acting head");
                    employeeDAO.UpdateRoleToActingHead(IdEmployee);
                    HttpContext.Current.Session.Clear();
                    aec.Result = new RedirectToRouteResult(
                        new RouteValueDictionary
                    {
                        { "controller", "DepartmentActingHead" },
                        { "action", "Notification" }
                    });
                }
            }

            if (controllerName.Contains("ActingHead"))
            {
                if (!delegationDAO.CheckIfInDelegationPeriod(IdEmployee))
                {
                    Debug.WriteLine("OnActionExecuting should be Employee");
                    employeeDAO.UpdateRoleToEmployee(IdEmployee);
                    HttpContext.Current.Session.Clear();
                    aec.Result = new RedirectToRouteResult(
                        new RouteValueDictionary
                    {
                        { "controller", "Employee" },
                        { "action", "Index" }
                    });
                }
            }
        }