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); }
public HomeController(IMEmployeeRepository mEmployeeRepository, IRefAddressRepository refAddressRepository, IRefPersonRepository refPersonRepository, IMDepartmentRepository mDepartmentRepository, ITNewsRepository tNewsRepository, ITLoanRepository tLoanRepository) { Check.Require(mEmployeeRepository != null, "mEmployeeRepository may not be null"); Check.Require(refAddressRepository != null, "refAddressRepository may not be null"); Check.Require(refPersonRepository != null, "refPersonRepository may not be null"); Check.Require(mDepartmentRepository != null, "mDepartmentRepository may not be null"); Check.Require(tNewsRepository != null, "tNewsRepository may not be null"); Check.Require(tLoanRepository != null, "tLoanRepository may not be null"); this._mEmployeeRepository = mEmployeeRepository; this._refAddressRepository = refAddressRepository; this._refPersonRepository = refPersonRepository; this._mDepartmentRepository = mDepartmentRepository; this._tNewsRepository = tNewsRepository; this._tLoanRepository = tLoanRepository; }