public async Task <IActionResult> SearchPaymentDetailById2()
        {
            try
            {
                var p = _oeUsersServ.GetUserByID(Convert.ToInt64(HttpContext.Session.GetString("session_CurrentActiveUserId")), he.WebRootPath);

                if (p != null)
                {
                    var result = new SearchPaymentDetailById()
                    {
                        //StudentId = StudentId,
                        RegistrationId = p.Users.RegistrationNo
                    };
                    var searchPaymentById = await Task.Run(() => _StudentPaymentsServ.SearchPaymentDetailById2(result));

                    var list = new List <IndexPaymentDetailByIdVM_StudentPayments>();
                    ViewBag.ddlClasses = _classesServ.dropdown_Class();
                    ViewBag.ddlGenders = _GendersServ.Dropdown_Genders();
                    if (searchPaymentById._StudentPayments == null)
                    {
                        ViewBag.Message = "Need to insert all pre required items- Such as: Fee Types, Fee Structure";
                        var model = new IndexPaymentDetailByIdVM()
                        {
                            ClassId           = searchPaymentById.ClassId,
                            _StudentPayments  = null,
                            StudentId         = 0,
                            RegistrationId    = p.Users.RegistrationNo,
                            StudentSearchName = searchPaymentById.StudentSearchName
                        };
                        return(View("SearchPaymentDetailById", model));
                    }
                    else
                    {
                        foreach (var item in searchPaymentById._StudentPayments.ToList())
                        {
                            var temp = new IndexPaymentDetailByIdVM_StudentPayments()
                            {
                                Id          = item.Id,
                                ClassId     = item.ClassId,
                                FeeYearDate = item.FeeYearDate,
                                ClassName   = item.ClassName,
                                PaymentDate = item.PaymentDate,
                                StudentId   = item.StudentId,
                                StudentName = item.StudentName,
                                FeeTypeId   = item.FeeTypeId,
                                TermNo      = item.TermNo,
                                TermName    = item.TermName,
                                FeeType     = item.FeeType,
                                Amount      = item.FeeAmount,
                                Discount    = item.Discount,
                                Fine        = item.Fine,
                                PaidAmount  = item.PaidAmount,
                                Remarks     = item.Remarks
                            };
                            list.Add(temp);
                        }
                        ;
                        var model = new IndexPaymentDetailByIdVM()
                        {
                            TotalFine        = searchPaymentById.TotalFine,
                            TotalPaid        = searchPaymentById.TotalPaid,
                            TotalHavetoPay   = searchPaymentById.TotalHavetoPay,
                            ClassId          = searchPaymentById.ClassId,
                            _StudentPayments = list,
                            //StudentId = StudentId,
                            RegistrationId    = p.Users.RegistrationNo,
                            StudentSearchName = searchPaymentById.StudentSearchName
                        };
                        return(View("SearchPaymentDetailById2", model));
                    }
                }
                else
                {
                    var model = new IndexPaymentDetailByIdVM()
                    {
                        TotalFine        = 0,
                        TotalPaid        = 0,
                        TotalHavetoPay   = 0,
                        ClassId          = 0,
                        _StudentPayments = null,
                        //StudentId = StudentId,
                        RegistrationId    = "",
                        StudentSearchName = ""
                    };
                    return(View("SearchPaymentDetailById2", model));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }
        public async Task <IActionResult> SearchPaymentDetailById(Int64 StudentId, string RegistrationId)
        {
            try
            {
                var result = new SearchPaymentDetailById()
                {
                    StudentId      = StudentId,
                    RegistrationId = RegistrationId
                };
                var searchPaymentById = await Task.Run(() => _StudentPaymentsServ.SearchPaymentDetailById(result));

                var list = new List <IndexPaymentDetailByIdVM_StudentPayments>();
                ViewBag.ddlClasses = _classesServ.dropdown_Class();
                ViewBag.ddlGenders = _GendersServ.Dropdown_Genders();
                if (searchPaymentById._StudentPayments == null)
                {
                    ViewBag.Message = "Need to insert all pre required items- Such as: Fee Types, Fee Structure";
                    var model = new IndexPaymentDetailByIdVM()
                    {
                        ClassId           = searchPaymentById.ClassId,
                        _StudentPayments  = null,
                        StudentId         = StudentId,
                        RegistrationId    = RegistrationId,
                        StudentSearchName = searchPaymentById.StudentSearchName
                    };
                    return(View("SearchPaymentDetailById", model));
                }
                else
                {
                    foreach (var item in searchPaymentById._StudentPayments.ToList())
                    {
                        var temp = new IndexPaymentDetailByIdVM_StudentPayments()
                        {
                            Id          = item.Id,
                            ClassId     = item.ClassId,
                            FeeYearDate = item.FeeYearDate,
                            ClassName   = item.ClassName,
                            PaymentDate = item.PaymentDate,
                            StudentId   = item.StudentId,
                            StudentName = item.StudentName,
                            FeeTypeId   = item.FeeTypeId,
                            TermNo      = item.TermNo,
                            TermName    = item.TermName,
                            FeeType     = item.FeeType,
                            Amount      = item.FeeAmount,
                            Discount    = item.Discount,
                            Fine        = item.Fine,
                            PaidAmount  = item.PaidAmount,
                            Remarks     = item.Remarks
                        };
                        list.Add(temp);
                    }
                    ;
                    var model = new IndexPaymentDetailByIdVM()
                    {
                        TotalFine         = searchPaymentById.TotalFine,
                        TotalPaid         = searchPaymentById.TotalPaid,
                        TotalHavetoPay    = searchPaymentById.TotalHavetoPay,
                        ClassId           = searchPaymentById.ClassId,
                        _StudentPayments  = list,
                        StudentId         = StudentId,
                        RegistrationId    = RegistrationId,
                        StudentSearchName = searchPaymentById.StudentSearchName
                    };
                    return(View("SearchPaymentDetailById", model));
                }
            }
            catch
            {
                return(BadRequest());
            }
        }