Exemplo n.º 1
0
        public ActionResult AssignDepRep()
        {
            string           token = GetToken();
            UserModel        um    = GetUser();
            List <UserModel> newum = new List <UserModel>();

            AssignDepRepViewModel viewModel = new AssignDepRepViewModel();

            try
            {
                newum            = APIUser.GetAssignRepUserList(token, um.Deptid, out string error);
                ViewBag.userlist = newum;
                List <UserModel> um23 = APIUser.GetUserByRoleAndDeptID(6, um.Deptid, token, out string depreperror);
                foreach (UserModel um1 in um23)
                {
                    ViewBag.assignedrep = um1.Fullname;
                }
                if (error != "")
                {
                    return(RedirectToAction("Index", "Error", new { error }));
                }
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }

            return(View(viewModel));
        }
Exemplo n.º 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 }));
            }
        }