public string showAllApprovedRequisitions(string accessToken)
 {
     OAuthController oAuth = new OAuthController();
     User user = oAuth.actionGetUserByToken(accessToken);
     RequisitionController requisitionController = new RequisitionController();
     List<RequisitionView> requisitionDepartmentWise = requisitionController.actionGetApprovedRequisitionViewsByDepartmentID(Convert.ToInt32(user.department));
     List<Requisition> requisitions = new List<Requisition>();
     foreach (RequisitionView rView in requisitionDepartmentWise)
     {
         Requisition requisition = new Requisition();
         requisition.EmployeeName = rView.firstname + " " + rView.lastname;
         requisition.Quantity = rView.quantity;
         requisition.RequisitionDate = rView.datetime_requested;
         requisition.ReqDate = rView.datetime_requested.ToString("MMMM dd, yyyy");
         requisition.StationaryName = rView.stationery_name;
         requisitions.Add(requisition);
     }
     return JsonConvert.SerializeObject(requisitions);
 }
        public static string LoadAllApprovedRequests()
        {
            User sUser = (User)HttpContext.Current.Session["user"];
            if (sUser == null)
            {
                return null;
            }

            UserController userController = new UserController();
            User dUser = userController.actionGetUserByID(sUser.id);

            RequisitionController requisitionController = new RequisitionController();
            JavaScriptSerializer js = new JavaScriptSerializer();
            List<RequisitionView> requisitionDepartmentWise = requisitionController.actionGetApprovedRequisitionViewsByDepartmentID(Convert.ToInt32(dUser.department));
            System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ requisitions by department wise:" + requisitionDepartmentWise.Count());
            List<UserRequisition> userRequisitionsList = new List<UserRequisition>();
            foreach (RequisitionView r in requisitionDepartmentWise)
            {
                if (userRequisitionsList.Count == 0)
                {
                    UserRequisition userRequisition = new UserRequisition();
                    //Since there are no requisitions made so no question of grouping based on user id
                    userRequisition.EmployeeName = r.firstname + " " + r.lastname;
                    userRequisition.UserId = r.user_obj;
                    Requisition requisition = new Requisition();
                    requisition.ReqId = r.requisition_id;
                    requisition.Quantity = r.quantity;
                    requisition.StationaryName = r.stationery_name;
                    // requisition.RequisitionDate = r.r
                    userRequisition.UserRequisitions.Add(requisition);
                    userRequisitionsList.Add(userRequisition);
                }
                else
                {
                    bool found = false;
                    //check if requisition from the same user is pending, if yes group the requisition based on that user id
                    foreach (UserRequisition uR in userRequisitionsList)
                    {
                        if (r.user_obj == uR.UserId)
                        {
                            found = true;
                            Requisition requisition = new Requisition();
                            requisition.ReqId = r.requisition_id;
                            requisition.Quantity = r.quantity;
                            requisition.StationaryName = r.stationery_name;
                            // requisition.RequisitionDate = r.r
                            uR.UserRequisitions.Add(requisition);
                            break;
                        }

                    }//foreach
                    //else simply add the userrequisition to the list, grouping not required
                    if (!found)
                    {
                        UserRequisition userRequisition = new UserRequisition();
                        userRequisition.EmployeeName = r.firstname + " " + r.lastname;
                        userRequisition.UserId = r.user_obj;

                        Requisition requisition = new Requisition();
                        requisition.ReqId = r.requisition_id;
                        requisition.Quantity = r.quantity;
                        requisition.StationaryName = r.stationery_name;
                        userRequisition.UserRequisitions.Add(requisition);
                        userRequisitionsList.Add(userRequisition);
                    }
                }
            }
            System.Diagnostics.Debug.WriteLine("check @@@@@@@@@@@@ loadAllPendingRequests:" + js.Serialize(userRequisitionsList));
            return js.Serialize(userRequisitionsList);
        }