public ActionResult InternationalManagerFinalConfirm(string term = null)
        {
            //if (Session["UserCmsInfo"] == null)
            //{
            //    return RedirectToAction("LoginCMS", "Account", new { lang = "fa" });
            //}
            var selectedTerm  = string.IsNullOrEmpty(term) ? currentTerm : term;
            var convertedTerm = $"{selectedTerm.Substring(0, 2)}{selectedTerm.Substring(6, 1)}";

            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", selectedTerm);

            var newStudentsList = _newStudentService.FetchAll().Where(w => w.term == int.Parse(convertedTerm))//term is 3 degits
                                  .Select(s => new NewStudentViewModel
            {
                StudentCode   = s.stcode,
                RequestId     = s.RequestId?.ToString() ?? "",
                FirstName     = s.name,
                LastName      = s.family,
                FatherName    = s.namep,
                FeildIdSazman = s.idreshSazman,
                //FeildTitle = "---",
                GraduateLevel      = s.magh,
                GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(s.magh),
                BirthDate          = s.year_tav?.ToString() ?? "--"
            }).ToList();

            var model = (from ns in newStudentsList
                         join s in _sidaFieldService.FetchAll() on ns.FeildIdSazman equals s.CodeSazman into sidaFields
                         from sf in sidaFields.DefaultIfEmpty()
                         select new NewStudentViewModel()
            {
                StudentCode = ns.StudentCode,
                RequestId = ns.RequestId?.ToString() ?? "",
                FirstName = ns.FirstName,
                LastName = ns.LastName,
                FatherName = ns.FatherName,
                FeildIdSazman = ns.FeildIdSazman,
                FeildTitle = sf == null ? "---" : sf.SidaFieldName,
                GraduateLevel = ns.GraduateLevel,
                GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(ns.GraduateLevel),
                BirthDate = ns.BirthDate?.ToString() ?? "--"
            }).ToList();

            return(View(model));
        }
        public ActionResult GetNewStudetByParams(string term = null, string studentCode = null, string filter = null)
        {
            try
            {
                var selectedTerm  = string.IsNullOrEmpty(term) ? currentTerm : term;
                var convertedTerm = $"{selectedTerm.Substring(0, 2)}{selectedTerm.Substring(6, 1)}";
                var studentList   = _newStudentService.FetchAll().Where(w => w.term == int.Parse(convertedTerm));

                if (!string.IsNullOrEmpty(studentCode) && Helpers.IsNumeric(studentCode))
                {
                    var student = studentList.Where(w => w.stcode == studentCode).Select(s => new NewStudentViewModel
                    {
                        StudentCode   = s.stcode,
                        RequestId     = s.RequestId?.ToString() ?? "",
                        FirstName     = s.name,
                        LastName      = s.family,
                        FatherName    = s.namep,
                        FeildIdSazman = s.idreshSazman,
                        //FeildTitle = "---",
                        GraduateLevel      = s.magh,
                        GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(s.magh),
                        BirthDate          = s.year_tav?.ToString() ?? "--"
                    }).FirstOrDefault();

                    var sidaField = _sidaFieldService.FindOne(s => s.CodeSazman == student.FeildIdSazman);
                    var model     = new NewStudentViewModel
                    {
                        StudentCode        = student.StudentCode,
                        RequestId          = student.RequestId?.ToString() ?? "",
                        FirstName          = student.FirstName,
                        LastName           = student.LastName,
                        FatherName         = student.FatherName,
                        FeildIdSazman      = student.FeildIdSazman,
                        FeildTitle         = sidaField == null ? "---" : sidaField.SidaFieldName,
                        GraduateLevel      = student.GraduateLevel,
                        GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(student.GraduateLevel),
                        BirthDate          = student.BirthDate?.ToString() ?? "--",
                    };
                    return(PartialView("_NewStudentDetails", model));
                }
                else
                {
                    if (!string.IsNullOrEmpty(filter?.Trim()))
                    {
                        var trimedFilter = filter.Trim();
                        if (Helpers.IsNumeric(trimedFilter))//studentCode or requestId or codeSazman
                        {
                            var model = (from ns in studentList
                                         join s in _sidaFieldService.FetchAll() on ns.idreshSazman equals s.CodeSazman //into sidaFields
                                                                                                                       //from sf in sidaFields.DefaultIfEmpty()
                                         where (
                                             (!string.IsNullOrEmpty(ns.stcode?.Trim()) && ns.stcode.Trim() == trimedFilter) ||
                                             (!string.IsNullOrEmpty(ns.RequestId?.ToString().Trim()) && ns.RequestId.ToString().Trim() == trimedFilter) ||
                                             (!string.IsNullOrEmpty(ns.idreshSazman.Trim()) && ns.idreshSazman.Trim() == trimedFilter)
                                             )
                                         select new NewStudentViewModel()
                            {
                                StudentCode = ns.stcode,
                                RequestId = ns.RequestId?.ToString() ?? "",
                                FirstName = ns.name,
                                LastName = ns.family,
                                FatherName = ns.namep,
                                FeildIdSazman = ns.idreshSazman,
                                //FeildTitle = sf == null ? "---" : sf.SidaFieldName,
                                FeildTitle = s == null ? "---" : s.SidaFieldName,
                                GraduateLevel = ns.magh,
                                GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(ns.magh),
                                BirthDate = ns.date_tav?.ToString() ?? "--"
                            }).ToList();
                            return(PartialView("_NewStudentList", model));
                        }
                        else //name or family or field or fathername
                        {
                            var model = (from ns in studentList
                                         join s in _sidaFieldService.FetchAll() on ns.idreshSazman equals s.CodeSazman //into sidaFields
                                         where (
                                             (!string.IsNullOrEmpty(ns.name) && Helpers.ToPersianLetters(ns.name.ToLower()).Contains(Helpers.ToPersianLetters(trimedFilter.ToLower()))) ||
                                             (!string.IsNullOrEmpty(ns.family) && Helpers.ToPersianLetters(ns.family.ToLower()).Contains(Helpers.ToPersianLetters(trimedFilter.ToLower()))) ||
                                             (!string.IsNullOrEmpty(ns.namep) && Helpers.ToPersianLetters(ns.namep.ToLower()).Contains(Helpers.ToPersianLetters(trimedFilter.ToLower()))) ||
                                             (!string.IsNullOrEmpty(s.SidaFieldName) && Helpers.ToPersianLetters(s.SidaFieldName.ToLower()).Contains(Helpers.ToPersianLetters(trimedFilter.ToLower())))
                                             //|| (!string.IsNullOrEmpty(sf.SidaFieldName) && Helpers.ToPersianLetters(sf.SidaFieldName).Contains(Helpers.ToPersianLetters(trimedFilter)))
                                             )

                                         select new NewStudentViewModel()
                            {
                                StudentCode = ns.stcode,
                                RequestId = ns.RequestId?.ToString() ?? "",
                                FirstName = ns.name,
                                LastName = ns.family,
                                FatherName = ns.namep,
                                FeildIdSazman = ns.idreshSazman,
                                //FeildTitle = sf == null ? "---" : sf.SidaFieldName,
                                FeildTitle = s == null ? "---" : s.SidaFieldName,
                                GraduateLevel = ns.magh,
                                GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(ns.magh),
                                BirthDate = ns.date_tav?.ToString() ?? "--"
                            }).ToList();
                            return(PartialView("_NewStudentList", model));
                        }
                    }
                    else
                    {
                        var model = (from ns in studentList
                                     join s in _sidaFieldService.FetchAll() on ns.idreshSazman equals s.CodeSazman //into sidaFields
                                                                                                                   //from sf in sidaFields.DefaultIfEmpty()
                                     select new NewStudentViewModel()
                        {
                            StudentCode = ns.stcode,
                            RequestId = ns.RequestId?.ToString() ?? "",
                            FirstName = ns.name,
                            LastName = ns.family,
                            FatherName = ns.namep,
                            FeildIdSazman = ns.idreshSazman,
                            //FeildTitle = sf == null ? "---" : sf.SidaFieldName,
                            FeildTitle = s == null ? "---" : s.SidaFieldName,
                            GraduateLevel = ns.magh,
                            GraduateLevelTitle = EnumsPersianTitles.GetSidaLevelTitle(ns.magh),
                            BirthDate = ns.date_tav?.ToString() ?? "--"
                        }).ToList();
                        return(PartialView("_NewStudentList", model));
                    }
                }
            }
            catch (Exception x)
            {
                throw x;
            }
        }