public static LoanSummary Create(ITLoanRepository tLoanRepository, DateTime month) { LoanSummary summary = new LoanSummary(); summary.Month = month; //calculate loan total IList list = tLoanRepository.GetTotalByMonth(month); if (list != null) { if (list.Count > 0) { object[] obj = (object[])list[0]; summary.TotalHD = (decimal)obj[0]; summary.TotalHT = (decimal)obj[1]; summary.TotalInstallment = (decimal)obj[2]; } } //calculate loan count summary.TotalLoanApprove = tLoanRepository.GetCountByLoanStatus(month, EnumLoanStatus.Approve); summary.TotalLoanReject = tLoanRepository.GetCountByLoanStatus(month, EnumLoanStatus.Reject); summary.TotalLoanPostpone = tLoanRepository.GetCountByLoanStatus(month, EnumLoanStatus.Postpone); summary.TotalLoanCancel = tLoanRepository.GetCountByLoanStatus(month, EnumLoanStatus.Cancel); summary.TotalLoan = summary.TotalLoanApprove + summary.TotalLoanReject + summary.TotalLoanPostpone + summary.TotalLoanCancel; //calculate installment summary.TotalMustPaidInstallment = tLoanRepository.GetTotalInstallmentByStatus(month, "%"); summary.TotalPaidInstallment = tLoanRepository.GetTotalInstallmentByStatus(month, EnumInstallmentStatus.Paid.ToString()); return(summary); }
public static HomeViewModel Create(ITNewsRepository tNewsRepository, ITLoanRepository tLoanRepository) { var viewModel = new HomeViewModel(); TNews news = tNewsRepository.GetByType(EnumNewsType.Promo); if (news == null) { news = new TNews(); } viewModel.PromoNews = news; news = tNewsRepository.GetByType(EnumNewsType.Announcement); if (news == null) { news = new TNews(); } viewModel.AnnouncementNews = news; DateTime currentMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); viewModel.CurrentLoanSummary = LoanSummary.Create(tLoanRepository, currentMonth); viewModel.OneMonthAgoLoanSummary = LoanSummary.Create(tLoanRepository, currentMonth.AddMonths(-1)); viewModel.OneMonthAgoAchievement = AchievementSummary.Create(tLoanRepository, currentMonth.AddMonths(-1)); return(viewModel); }