public async Task <IActionResult> InsertPromotion(IndexStudentPromotionsVM obj)
        {
            try
            {
                ViewBag.ddlClass = _classesServ.dropdown_Class();
                if (obj.StudentPromotions != null)
                {
                    var StudentPromotions = new InsertStudentPromotions_StudentPromotions()
                    {
                        StudentId    = obj.StudentPromotions.StudentId,
                        ClassId      = obj.StudentPromotions.ClassId,
                        RollNo       = obj.StudentPromotions.RollNo,
                        Year         = obj.StudentPromotions.Year,
                        IsActive     = obj.StudentPromotions.IsActive,
                        AddedBy      = 0,
                        AddedDate    = DateTime.Now,
                        ModifiedBy   = 0,
                        ModifiedDate = DateTime.Now,
                        DataType     = null
                    };

                    var model = new InsertStudentPromotions()
                    {
                        StudentPromotions = StudentPromotions
                    };

                    await Task.Run(() => _StudentPromotionsServ.InsertStudentPromotions(model));
                }
            }
            catch (Exception)
            {
                return(BadRequest());
            }
            return(RedirectToAction("StudentPromotionsList"));
        }
        public async Task <IActionResult> UpdatePromotion(IndexStudentPromotionsVM obj)
        {
            try
            {
                if (obj.StudentPromotions != null)
                {
                    var StudentPromotions = new UpdateStudentPromotion_StudentPromotions()
                    {
                        Id           = obj.StudentPromotions.Id,
                        StudentId    = obj.StudentPromotions.StudentId,
                        ClassId      = obj.StudentPromotions.ClassId,
                        RollNo       = obj.StudentPromotions.RollNo,
                        Year         = obj.StudentPromotions.Year,
                        IsActive     = obj.StudentPromotions.IsActive,
                        AddedBy      = 0,
                        AddedDate    = DateTime.Now,
                        ModifiedBy   = 0,
                        ModifiedDate = DateTime.Now,
                        DataType     = null
                    };

                    var model = new UpdateStudentPromotion()
                    {
                        StudentPromotions = StudentPromotions
                    };

                    await Task.Run(() => _StudentPromotionsServ.UpdateStudentPromotion(model));
                }
            }
            catch (Exception)
            {
                return(BadRequest());
            }
            return(RedirectToAction("StudentPromotionsList"));
        }
        public async Task <IActionResult> StudentPromotionsList(int pg = 1)
        {
            try
            {
                var StudentPromotionsList = Task.Run(() => _StudentPromotionsServ.getStudentPromotionsList());
                var result = await StudentPromotionsList;
                ViewBag.ddlClass = _classesServ.dropdown_Class();
                var list = new List <IndexStudentPromotionsVM_StudentPromotions>();
                foreach (var item in result._StudentPromotions.ToList())
                {
                    var temp = new IndexStudentPromotionsVM_StudentPromotions()
                    {
                        Id             = item.Id,
                        ClassId        = item.ClassId,
                        ClassName      = item.ClassName,
                        StudentId      = item.StudentId,
                        RegistrationNo = item.RegistrationNo,
                        RollNo         = item.RollNo,
                        ClassYear      = item.ClassYear,
                        IsActive       = item.IsActive,
                        AddedBy        = item.AddedBy,
                        AddedDate      = item.AddedDate,
                        ModifiedBy     = item.ModifiedBy,
                        ModifiedDate   = item.ModifiedDate,
                        DataType       = item.DataType
                    };
                    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 IndexStudentPromotionsVM()
                {
                    _StudentPromotions = data
                };
                #endregion "Paging"


                return(View("StudentPromotionsList", model));
            }
            catch (Exception)
            {
                return(BadRequest());
            }
        }