public async Task <IActionResult> StudentsByAccountant(string SearchStudentClassId, int pg = 1) { try { if (String.IsNullOrEmpty(SearchStudentClassId)) { ViewBag.ddlClasses = _classesServ.dropdown_Class(); ViewBag.searchRequest = false; var model = new StudentsByAccountantVM() { _Students = null, SearchStudentClassId = null }; return(View("StudentsByAccountant", model)); } else { var result = new SearchStudentsByClass() { WebRootPath = _he.WebRootPath, SearchStudentClassId = SearchStudentClassId }; var SearchStudentsByClass = await Task.Run(() => _studentsServ.SearchStudentsByClass(result)); ViewBag.ddlClasses = _classesServ.dropdown_Class(); ViewBag.ddlGenders = _GendersServ.Dropdown_Genders(); var list = new List <StudentsByAccountantVM_Students>(); foreach (var item in SearchStudentsByClass._Students.ToList()) { var temp = new StudentsByAccountantVM_Students() { Id = item.Id, ClassId = item.ClassId, ClassName = item.ClassName, GenderId = item.GenderId, GenderName = item.GenderName, RegistrationNo = item.RegistrationNo, FirstName = item.FirstName, LastName = item.LastName, StudentName = item.StudentName, FatherName = item.FatherName, MotherName = item.MotherName, ParentsName = item.ParentsName, CurrentClassName = item.CurrentClassName, CurrentYear = item.CurrentYear, IP300X200 = item.IP300X200, AdmittedYear = item.AdmittedYear, PresentAddress = item.PresentAddress, PermanentAddress = item.PermanentAddress, DOB = item.DOB, IsActive = item.IsActive, AddedBy = item.AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; list.Add(temp); } ; #region "Paging" const int pageSize = 5; if (pg < 1) { pg = 1; } int recsCount = list.Count(); var pager = new Pager(recsCount, pg, pageSize); int recSkip = (pg - 1) * pageSize; var data = list.Skip(recSkip).Take(pager.PageSize).ToList(); this.ViewBag.Pager = pager; var model = new StudentsByAccountantVM() { ClassName = SearchStudentsByClass.SearchStudentClassName, _Students = data, SearchStudentClassId = SearchStudentClassId }; #endregion "Paging" return(View("StudentsByAccountant", model)); } } catch { return(BadRequest()); } }
public async Task <IActionResult> SearchStudentsClassByAccountant(string SearchStudentClassId) { try { if (String.IsNullOrEmpty(SearchStudentClassId)) { var model = new StudentsByAccountantVM() { _Students = null, SearchStudentClassId = null }; return(View("StudentsByAccountant", model)); } else { var result = new SearchStudentsByClass() { SearchStudentClassId = SearchStudentClassId }; var SearchStudentsByClass = await Task.Run(() => _studentsServ.SearchStudentsByClass(result)); ViewBag.ddlClasses = _classesServ.dropdown_Class(); ViewBag.ddlGenders = _GendersServ.Dropdown_Genders(); var list = new List <StudentsByAccountantVM_Students>(); foreach (var item in SearchStudentsByClass._Students.ToList()) { var temp = new StudentsByAccountantVM_Students() { Id = item.Id, ClassId = item.ClassId, ClassName = item.ClassName, GenderId = item.GenderId, GenderName = item.GenderName, RegistrationNo = item.RegistrationNo, FirstName = item.FirstName, LastName = item.LastName, StudentName = item.StudentName, FatherName = item.FatherName, MotherName = item.MotherName, ParentsName = item.ParentsName, IP300X200 = item.IP300X200, AdmittedYear = item.AdmittedYear, PresentAddress = item.PresentAddress, PermanentAddress = item.PermanentAddress, DOB = item.DOB, IsActive = item.IsActive, AddedBy = item.AddedBy = 0, AddedDate = DateTime.Now, ModifiedBy = 0, ModifiedDate = DateTime.Now, DataType = null }; list.Add(temp); } ; var model = new StudentsByAccountantVM() { _Students = list, SearchStudentClassId = SearchStudentClassId }; return(View("StudentsByAccountant", model)); } } catch { return(BadRequest()); } }