Example #1
0
        public async Task <IActionResult> UpdateStudentDiscount(IndexStudentDiscountsListVM obj)
        {
            try
            {
                if (obj.StudentDiscounts != null)
                {
                    var StudentDiscounts = new UpdateStudentDiscount_StudentDiscounts()
                    {
                        Id             = obj.StudentDiscounts.Id,
                        StudentId      = obj.StudentDiscounts.StudentId,
                        RegistrationNo = obj.StudentDiscounts.RegistrationNo,
                        FeeTypeId      = obj.StudentDiscounts.FeeTypeId,
                        DiscountAmout  = obj.StudentDiscounts.DiscountAmout
                    };

                    var model = new UpdateStudentDiscount()
                    {
                        StudentDiscounts = StudentDiscounts
                    };
                    await Task.Run(() => _StudentDiscountsServ.UpdateStudentDiscount(model));
                }
            }
            catch (Exception)
            {
                return(BadRequest());
            }
            return(RedirectToAction("StudentDiscountsList"));
        }
Example #2
0
        public async Task <IActionResult> StudentDiscountsList(int pg = 1)
        {
            try
            {
                var StudentDiscountsList = Task.Run(() => _StudentDiscountsServ.getStudentDiscountsList());
                var result = await StudentDiscountsList;
                ViewBag.ddlStudent = _studentsServ.dropdown_Students();
                ViewBag.ddlClass   = _classesServ.dropdown_Class();
                var list = new List <IndexStudentDiscountsListVM_StudentDiscounts>();
                foreach (var item in result._StudentDiscounts.ToList())
                {
                    var temp = new IndexStudentDiscountsListVM_StudentDiscounts()
                    {
                        Id             = item.Id,
                        StudentId      = item.StudentId,
                        ClassId        = item.ClassId,
                        ClassName      = item.ClassName,
                        RegistrationNo = item.RegistrationNo,
                        StudentName    = item.StudentName,
                        FeeTypeId      = item.FeeTypeId,
                        FeeType        = item.FeeType,
                        DiscountAmout  = item.DiscountAmout
                    };
                    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 IndexStudentDiscountsListVM()
                {
                    _StudentDiscounts = data
                };
                #endregion "Paging"

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