Exemplo n.º 1
0
        public ActionResult CollectionPoint()
        {
            string    token = GetToken();
            UserModel um    = GetUser();
            DepartmentCollectionPointModel dcpm = new DepartmentCollectionPointModel();

            ViewBag.PendingCPR = false;
            List <CodeValue>                      CollectionPointsList = new List <CodeValue>();
            List <CollectionPointModel>           cpms  = new List <CollectionPointModel>();
            List <DepartmentCollectionPointModel> dcpms = new List <DepartmentCollectionPointModel>();

            try
            {
                // to show active collection point
                dcpms = APICollectionPoint.GetDepartmentCollectionPointByStatus(token, ConDepartmentCollectionPoint.Status.PENDING, out string error);

                dcpm = APICollectionPoint.GetActiveDepartmentCollectionPointByDeptID(token, um.Deptid, out error);
                ViewBag.ActiveCollectionPoint = dcpm.CpName;

                CollectionPointModel current =
                    APICollectionPoint.GetCollectionPointBycpid(token, dcpm.CpID, out error);

                ViewBag.Latitude  = current.Latitude;
                ViewBag.Longitude = current.Longitude;

                // to show pending list if exists
                dcpms = dcpms.Where(p => p.DeptID == um.Deptid).ToList();
                ViewBag.PendingCollectionPoints = dcpms;
                if (dcpms.Count > 0)
                {
                    ViewBag.PendingCPR = true;
                }


                // for radio button
                cpms = APICollectionPoint.GetAllCollectionPoints(token, out error);

                ViewBag.CollectionPointsList = cpms;
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }


            return(View(cpms));
        }
Exemplo n.º 2
0
        public ActionResult CollectionPoint(int id)
        {
            string                         token = GetToken();
            UserModel                      um    = GetUser();
            CollectionPointModel           cpm   = new CollectionPointModel();
            DepartmentCollectionPointModel dcpm  = new DepartmentCollectionPointModel();

            try
            {
                cpm         = APICollectionPoint.GetCollectionPointBycpid(token, id, out string error);
                dcpm.CpID   = cpm.Cpid;
                dcpm.DeptID = um.Deptid;
                dcpm        = APICollectionPoint.CreateDepartmentCollectionPoint(token, dcpm, out error);
            }
            catch (Exception ex)
            {
                return(RedirectToAction("Index", "Error", new { error = ex.Message }));
            }
            return(RedirectToAction("CollectionPoint"));
        }