Beispiel #1
0
        public async Task <IActionResult> StudentsaddDetails(string SearchStudentClassId)
        {
            try
            {
                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 <Vm_Students>();
                foreach (var item in SearchStudentsByClass._Students.ToList())
                {
                    var temp = new Vm_Students()
                    {
                        Id      = item.Id,
                        ClassId = item.ClassId,

                        ClassName        = item.ClassName,
                        GenderId         = item.GenderId,
                        GenderName       = item.GenderName,
                        RegistrationNo   = item.RegistrationNo,
                        RollNO           = item.RollNO,
                        CurrentClassId   = item.CurrentClassId,
                        CurrentClassName = item.CurrentClassName,
                        CurrentYear      = DateTime.Now,
                        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 IndexStudentsListVM()
                {
                    ClassName            = SearchStudentsByClass.SearchStudentClassName,
                    _Students            = list,
                    SearchStudentClassId = SearchStudentClassId
                };
                return(View("StudentsaddDetails", model));
            }

            catch
            {
                return(BadRequest());
            }
        }
Beispiel #2
0
        public async Task <IActionResult> SearchByClass(string SearchStudentClassId, int pg = 1)
        {
            try
            {
                if (String.IsNullOrEmpty(SearchStudentClassId))
                {
                    ViewBag.ddlClasses    = _classesServ.dropdown_Class();
                    ViewBag.searchRequest = false;
                    var model = new IndexStudentsListVM()
                    {
                        _Students            = null,
                        SearchStudentClassId = null
                    };
                    return(View("StudentsList", model));
                }
                else if (SearchStudentClassId == "All class")
                {
                    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 <Vm_Students>();
                    foreach (var item in SearchStudentsByClass._Students.ToList())
                    {
                        var temp = new Vm_Students()
                        {
                            Id               = item.Id,
                            ClassId          = item.ClassId,
                            ClassName        = item.ClassName,
                            GenderId         = item.GenderId,
                            GenderName       = item.GenderName,
                            RegistrationNo   = item.RegistrationNo,
                            RollNO           = item.RollNO,
                            CurrentClassId   = item.CurrentClassId,
                            CurrentClassName = item.CurrentClassName,
                            CurrentYear      = DateTime.Now,
                            FirstName        = item.FirstName,
                            LastName         = item.LastName,
                            StudentName      = item.StudentName,
                            FatherName       = item.FirstName,
                            MotherName       = item.LastName,
                            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);
                    }
                    ;

                    #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 IndexStudentsListVM()
                    {
                        ClassName            = SearchStudentsByClass.SearchStudentClassName,
                        _Students            = data,
                        SearchStudentClassId = SearchStudentClassId
                    };
                    #endregion "Paging"

                    return(View("StudentsList", 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 <Vm_Students>();
                    foreach (var item in SearchStudentsByClass._Students.ToList())
                    {
                        var temp = new Vm_Students()
                        {
                            Id               = item.Id,
                            ClassId          = item.ClassId,
                            ClassName        = item.ClassName,
                            GenderId         = item.GenderId,
                            GenderName       = item.GenderName,
                            RegistrationNo   = item.RegistrationNo,
                            RollNO           = item.RollNO,
                            CurrentClassId   = item.CurrentClassId,
                            CurrentClassName = item.CurrentClassName,
                            CurrentYear      = DateTime.Now,
                            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 IndexStudentsListVM()
                    {
                        ClassName            = SearchStudentsByClass.SearchStudentClassName,
                        _Students            = list,
                        SearchStudentClassId = SearchStudentClassId
                    };
                    return(View("StudentsList", model));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }