Example #1
0
        public async Task <StudentsPaymentListViewModel> GetAllStudentsByBranchIdAsync(int branchId, PaymentSortingEnum sortState)
        {
            var students = await _unitOfWork.Student.GetAllStudentsByBranchIdAsync(branchId);

            List <StudentPaymentViewModel> studentPaymentViewModels = new List <StudentPaymentViewModel>();

            foreach (var student in students)
            {
                var model = Mapper.Map <StudentPaymentViewModel>(student);
                model.MustTotal = await _unitOfWork.StudentPaymentAndPeriods.GetMustTotalByStudentIdAsync(student.Id);

                model.AllMustTotal = await GetAllMustTotalByStudentIdAsync(student.Id);

                model.AllTotal = await GetAllTotalByStudentId(student.Id);

                model.Balance     = model.AllMustTotal - model.AllTotal;
                model.PeriodCount = await GetCountPeriodsByStudentIdAsync(student.Id);

                model.LastPayment = await GetLastPaymentByStudentIdAsync(student.Id);

                model.LastCommit = await GetLastCommitByStudentIdAsync(student.Id);

                studentPaymentViewModels.Add(model);
            }

            return(PaymentStudentsSort.Sort(studentPaymentViewModels, sortState));
        }
Example #2
0
        public async Task <StudentsPaymentListViewModel> StudentSearchAsync(string term, PaymentSortingEnum sortState)
        {
            var students = await _unitOfWork.Student.GetAllStudentsByPayment();

            students = students.Where(x => (x.Name?.ToUpper() ?? string.Empty).Contains(term.ToUpper()) ||
                                      (x.PhoneNumber?.ToUpper() ?? string.Empty).Contains(term.ToUpper()) ||
                                      (x.LastName?.ToUpper() ?? string.Empty).Contains(term.ToUpper()) ||
                                      (x.ParentLastName?.ToUpper() ?? string.Empty).Contains(term.ToUpper())).ToList();
            List <StudentPaymentViewModel> studentPaymentViewModels = new List <StudentPaymentViewModel>();

            foreach (var student in students)
            {
                var model = Mapper.Map <StudentPaymentViewModel>(student);
                model.MustTotal = await _unitOfWork.StudentPaymentAndPeriods.GetMustTotalByStudentIdAsync(student.Id);

                model.AllMustTotal = await GetAllMustTotalByStudentIdAsync(student.Id);

                model.AllTotal = await GetAllTotalByStudentId(student.Id);

                model.Balance     = model.AllMustTotal - model.AllTotal;
                model.PeriodCount = await GetCountPeriodsByStudentIdAsync(student.Id);

                model.LastPayment = await GetLastPaymentByStudentIdAsync(student.Id);

                model.LastCommit = await GetLastCommitByStudentIdAsync(student.Id);

                studentPaymentViewModels.Add(model);
            }

            return(PaymentStudentsSort.Sort(studentPaymentViewModels, sortState));
        }