public PartialViewResult ShowRequests(FilterRequestByParamDTO req)
        {
            var model = BindRequestViewModel(req);

            TempData["tdTerm"]   = req.Term;
            TempData["tdStatus"] = req.ReqStatus;
            return(PartialView("_RequestDetailsTable", model));
        }
        public ActionResult ReviewRequests()
        {
            //if (Session["UserCmsInfo"] == null)
            //{
            //    return RedirectToAction("LoginCMS", "Account", new { lang = "fa" });
            //}

            var enumList = new List <RequestStatusDTO>()
            {
                new RequestStatusDTO()
                {
                    ID = ((byte)RequestStatus.Ex_Accepted).ToString(), DispalyName = Resources.Resources.AcceptRequestByExpert
                },                                                                                                                                          //4
                new RequestStatusDTO()
                {
                    ID = ((byte)RequestStatus.M_Rejected).ToString(), DispalyName = Resources.Resources.M_Rejected
                },                                                                                                                                          //5
                new RequestStatusDTO()
                {
                    ID = ((byte)RequestStatus.M_First_Accepted).ToString(), DispalyName = Resources.Resources.FirstAcceptRequestByManager
                },                                                                                                                                          //6
                //new RequestStatusDTO(){ID=((byte)RequestStatus.M_Final_Accepted).ToString(),DispalyName=Resources.Resources.FinalAcceptRequestByManager} , //7
                new RequestStatusDTO()
                {
                    ID = ((byte)RequestStatus.M_Enrollment_Accepted).ToString(), DispalyName = Resources.Resources.M_Enrollment_Accepted
                },                                                                                                                                          //8
                new RequestStatusDTO()
                {
                    ID = ((byte)RequestStatus.M_Enrollment_Rejected).ToString(), DispalyName = Resources.Resources.M_Enrollment_Rejected
                }                                                                                                                                           //9
            };
            var reqStatus = !string.IsNullOrEmpty(TempData["tdStatus"]?.ToString()) ? byte.Parse(TempData["tdStatus"].ToString()) : (byte)RequestStatus.Ex_Accepted;
            var term      = !string.IsNullOrEmpty(TempData["tdTerm"]?.ToString()) ? TempData["tdTerm"].ToString() : currentTerm;

            ViewBag.StatusList = new SelectList(enumList, "ID", "DispalyName", reqStatus);

            var terms    = _requestService.FetchAll().Select(s => s.Term).Distinct().OrderByDescending(o => o).ToList();
            var allTerms = new List <RequestStatusDTO>();

            terms.ForEach(f => allTerms.Add(new RequestStatusDTO()
            {
                ID = f.ToString(), DispalyName = f.ToString()
            }));

            ViewBag.Terms = new SelectList(allTerms, "ID", "DispalyName", term);
            var reqDto = new FilterRequestByParamDTO
            {
                Term      = term,
                ReqStatus = reqStatus.ToString()
            };
            //string actionName = this.ControllerContext.RouteData.Values["action"].ToString();
            //string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
            var model = new List <RequestInfoViewModel>(); //BindRequestViewModel(reqDto);

            return(View(model));
        }
        private List <RequestInfoViewModel> BindRequestViewModel(FilterRequestByParamDTO req)
        {
            var tterm      = string.IsNullOrEmpty(req.Term) ? currentTerm : req.Term;
            var reqStatus2 = !string.IsNullOrEmpty(req.ReqStatus) ? Byte.Parse(req.ReqStatus) : (byte)RequestStatus.Ex_Accepted;
            var myModel    = new List <RequestInfoViewModel>();
            var model      = new List <RequestInfoViewModel>();

            myModel = _requestService.FetchMany(s => s.Term == req.Term && s.Status == reqStatus2).Select(s => new RequestInfoViewModel
            {
                RequestID     = s.Id.ToString(),
                FirstName     = s.Student.Person.FirstName,
                LastName      = s.Student.Person.LastName,
                FatherName    = s.Student.Person.FatherName,
                FieldID       = _condidateService.FetchAll().FirstOrDefault(x => x.StudentId == s.Student.Id)?.FieldId.ToString(),
                CountryId     = s.Student.Person.CitizenShips.FirstOrDefault(c => c.Person.Id == s.Student.Person.Id)?.CountryId.ToString(),
                Term          = tterm,
                ContollerName = "InternationalManager"
            }).ToList();

            myModel.ForEach(xx => model.Add(new RequestInfoViewModel
            {
                RequestID     = xx.RequestID,
                FirstName     = xx.FirstName,
                LastName      = xx.LastName,
                FatherName    = xx.FatherName,
                FieldID       = xx.FieldID,
                CountryId     = xx.CountryId,
                CountryTitle  = _countryService.FindOne(c => c.Id.ToString() == xx.CountryId)?.DisplayName ?? "-",
                FieldTitle    = _fieldForForeignService.FindOne(f => f.Id.ToString() == xx.FieldID)?.Field_Name ?? "-",
                Term          = xx.Term,
                ContollerName = xx.ContollerName
            }));

            if (!string.IsNullOrEmpty(req.Filter?.ToString().Trim()))
            {
                if (Helpers.IsNumeric(req.Filter.ToString().Trim()))
                {
                    model = model.Where(w => w.RequestID == req.Filter.ToString().Trim()).ToList();
                }
                else
                {
                    //myModel = myModel.Where(w => w.FirstName.Contains(req.Filter.ToString().Trim()) || w.LastName.Contains(req.Filter.ToString().Trim())).ToList();
                    model = model.Where(w => Helpers.ToPersianLetters(w.FirstName?.ToLower()).Contains(Helpers.ToPersianLetters(req.Filter.ToString().Trim().ToLower())) ||
                                        Helpers.ToPersianLetters(w.LastName?.ToLower()).Contains(Helpers.ToPersianLetters(req.Filter.ToString().Trim().ToLower())) ||
                                        Helpers.ToPersianLetters(w.FatherName?.ToLower()).Contains(Helpers.ToPersianLetters(req.Filter.ToString().Trim().ToLower())) ||
                                        Helpers.ToPersianLetters(w.CountryTitle?.ToLower()).Contains(Helpers.ToPersianLetters(req.Filter.ToString().Trim().ToLower()))
                                        ).ToList();
                }
            }

            return(model);
        }