예제 #1
0
        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);
        }
예제 #2
0
        public static AchievementSummary Create(ITLoanRepository tLoanRepository, DateTime month)
        {
            AchievementSummary summary = new AchievementSummary();

            summary.Month = month;

            //get collector
            IList listCol = tLoanRepository.GetMaxCollector(month);

            if (listCol != null)
            {
                if (listCol.Count > 0)
                {
                    object[] obj = (object[])listCol[0];
                    summary.CollectorName        = obj[0].ToString();
                    summary.CollectorTarget      = (decimal)obj[1];
                    summary.CollectorAchievement = (decimal)obj[2];
                }
            }

            //get tls
            IList listTLS = tLoanRepository.GetMaxTLS(month);

            if (listTLS != null)
            {
                if (listTLS.Count > 0)
                {
                    object[] obj = (object[])listTLS[0];
                    summary.LTSName        = obj[0].ToString();
                    summary.LTSAchievement = (decimal)obj[1];
                    summary.LTSTarget      = (decimal)obj[2];
                }
            }

            //get sales
            IList listSalesman = tLoanRepository.GetMaxSalesman(month);

            if (listSalesman != null)
            {
                if (listSalesman.Count > 0)
                {
                    object[] obj = (object[])listSalesman[0];
                    summary.SalesmanName        = obj[0].ToString();
                    summary.SalesmanAchievement = (decimal)obj[1];
                    summary.SalesmanTarget      = (decimal)obj[2];
                }
            }

            return(summary);
        }