Beispiel #1
0
        public ActionResult StudentFeeCollection(int id = 0)
        {
            var sfcmodel        = new StudentFeeCollectionModel();
            var feeScheduleList = new List <FeeScheduleModel>();

            sfcmodel.StudentID   = id;
            sfcmodel.StudentList = _Context.Students.Where(x => x.IsActive == true).Select(x => new SelectListItem
            {
                Value = x.PK_StudentId.ToString(),
                Text  = x.Name
            });

            var sfcDetails = _Context.Sp_GetStudentFeeCollectionByStudent(id);

            var groupByFeeStructure = sfcDetails.GroupBy(x => x.PK_FeeStructurId).ToList();

            foreach (var item in groupByFeeStructure)
            {
                var feeSchedule = new FeeScheduleModel();

                feeSchedule.FeeStructureId       = item.Select(x => x.PK_FeeStructurId).FirstOrDefault();
                feeSchedule.StructurName         = item.Select(x => x.StructurName).FirstOrDefault();
                feeSchedule.StudentFeeScheduleId = item.Select(x => x.PK_StudentFeeScheduleId).FirstOrDefault();
                feeSchedule.TotalFeeAmount       = Convert.ToDecimal(item.Select(x => x.TotalFeeAmount).FirstOrDefault());
                feeSchedule.TotalPayableAmount   = Convert.ToDecimal(item.Select(x => x.TotalPayableAmount).FirstOrDefault());

                feeScheduleList.Add(feeSchedule);
            }
            sfcmodel.FeeScheduleModelList = feeScheduleList;

            return(View(sfcmodel));
        }
Beispiel #2
0
        public ActionResult StudentFeeCollectionPartial(int id = 0, int feeStructureId = 0)
        {
            var sfcmodel        = new StudentFeeCollectionModel();
            var feeScheduleList = new List <FeeScheduleModel>();

            sfcmodel.StudentID = id;

            var sfcDetails = _Context.Sp_GetStudentFeeCollectionByFeeStructure(id, feeStructureId);

            var groupByFeeStructure = sfcDetails.GroupBy(x => x.PK_FeeStructurId).ToList();

            foreach (var item in groupByFeeStructure)
            {
                var feeSchedule      = new FeeScheduleModel();
                var feeHeadModelList = new List <FeeHeadModel>();

                feeSchedule.FeeStructureId       = item.Select(x => x.PK_FeeStructurId).FirstOrDefault();
                feeSchedule.StructurName         = item.Select(x => x.StructurName).FirstOrDefault();
                feeSchedule.StudentFeeScheduleId = item.Select(x => x.PK_StudentFeeScheduleId).FirstOrDefault();
                feeSchedule.TotalFeeAmount       = Convert.ToDecimal(item.Select(x => x.TotalFeeAmount).FirstOrDefault());
                feeSchedule.PaidAmount           = item.Select(x => x.PaidAmount).FirstOrDefault();
                feeSchedule.TotalPayableAmount   = Convert.ToDecimal(item.Select(x => x.TotalPayableAmount).FirstOrDefault());

                var groupByFeeHead = item.GroupBy(x => x.PK_FeeHeadId).ToList();
                foreach (var item1 in groupByFeeHead)
                {
                    var feeHeadModel = new FeeHeadModel();

                    feeHeadModel.FeeHeadId    = item1.Select(x => x.PK_FeeHeadId).FirstOrDefault();
                    feeHeadModel.IsOptional   = item1.Select(x => x.IsOptional).FirstOrDefault();
                    feeHeadModel.HeadName     = item1.Select(x => x.HeadName).FirstOrDefault();
                    feeHeadModel.AmountByHead = Convert.ToDecimal(item1.Select(x => x.AmountByHead).FirstOrDefault());

                    var     paidHeadAmounts     = item1.Select(x => x.PaidHeadAmount).ToList();
                    decimal totalPaidHeadAmount = 0;
                    foreach (var item2 in paidHeadAmounts)
                    {
                        totalPaidHeadAmount = totalPaidHeadAmount + Convert.ToDecimal(item2);
                    }
                    feeHeadModel.PaidHeadAmount = totalPaidHeadAmount;

                    feeHeadModelList.Add(feeHeadModel);
                }
                feeSchedule.feeHeadModelList = feeHeadModelList;
                feeScheduleList.Add(feeSchedule);
            }
            sfcmodel.FeeScheduleModelList = feeScheduleList;

            return(PartialView(sfcmodel));
        }