Beispiel #1
0
        public ActionResult SearchPreviousDelegation()
        {
            string    token = GetToken();
            UserModel um    = GetUser();

            DelegationModel         reqms     = new DelegationModel();
            EditDelegationViewModel viewmodel = new EditDelegationViewModel();
            UserModel DelegatedUser           = new UserModel();

            try
            {
                reqms             = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out string error);
                ViewBag.Userid    = reqms.Userid;
                ViewBag.name      = reqms.Username;
                ViewBag.StartDate = reqms.Startdate;
                ViewBag.Enddate   = reqms.Enddate;
                ViewBag.Deleid    = reqms.Delid;
                if (reqms.Userid == 0 || reqms == null)
                {
                    ViewBag.name = "";
                }
                else
                {
                    DelegatedUser = APIUser.GetUserByUserID(reqms.Userid, token, out error);
                    if (DelegatedUser != null && DelegatedUser.Userid != 0)
                    {
                        ViewBag.name = DelegatedUser.Fullname;
                    }
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }

            return(View(viewmodel));
        }
Beispiel #2
0
        public ActionResult Index()
        {
            string    error = "";
            string    token = GetToken();
            UserModel um    = GetUser();

            List <RequisitionModel> reqs             = new List <RequisitionModel>();
            UserModel CurrentRep                     = new UserModel();
            DepartmentCollectionPointModel CurrentCP = new DepartmentCollectionPointModel();
            DelegationModel CurrentTemp              = new DelegationModel();
            UserModel       CurrentTempUser          = new UserModel();

            try
            {
                reqs                   = APIRequisition.GetRequisitionByStatus(ConRequisition.Status.PENDING, token, out error);
                ViewBag.ReqCount       = 0;
                ViewBag.ReqCount       = reqs.Where(x => x.Depid == um.Deptid).Count();
                ViewBag.DelegationType = "Temporary HOD";

                CurrentRep      = APIUser.GetUserByRoleAndDeptID(ConUser.Role.DEPARTMENTREP, um.Deptid, token, out error).FirstOrDefault();
                ViewBag.RepName = CurrentRep.Fullname;
                if (ViewBag.RepName == null)
                {
                    ViewBag.RepName = "None";
                }


                CurrentCP = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                ViewBag.CollectionPoint = CurrentCP.CpName;
                if (ViewBag.CollectionPoint == null)
                {
                    ViewBag.CollectionPoint = "None";
                }

                CurrentTemp = APIDelegation.GetPreviousDelegationByDepid(token, um.Deptid, out error);
                if (CurrentTemp.Delid != 0)
                {
                    CurrentTempUser  = APIUser.GetUserByUserID(CurrentTemp.Userid, token, out error);
                    ViewBag.TempHOD  = CurrentTempUser.Fullname;
                    ViewBag.TempDate = CurrentTemp.Startdate.Value.ToShortDateString() + " - " + CurrentTemp.Enddate.Value.ToShortDateString();
                    if (CurrentTemp.Startdate <= DateTime.Today && DateTime.Today <= CurrentTemp.Enddate)
                    {
                        ViewBag.DelegationType = "Current Temporary HOD";
                    }
                    else
                    {
                        ViewBag.DelegationType = "Upcoming Temporary HOD";
                    }
                }
                if (CurrentTemp.Delid == 0 || ViewBag.TempHOD == null)
                {
                    ViewBag.DelegationType = "Temporary HOD";
                    ViewBag.TempHOD        = "None";
                    ViewBag.TempDate       = "-";
                }
                return(View());
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
        }