コード例 #1
0
        public ActionResult Index(AgreementPage currentPage)
        {
            var supplier = UserManager.GetActiveCustomer(HttpContext);

            if (string.IsNullOrWhiteSpace(supplier?.CustomerNo))
            {
                return(View("Index", new AgreementPageViewModel(currentPage)
                {
                    ListAgreementsByYears = new Agreement[0].GroupBy(a => 0),
                    ListSeedAgreementsByYears = new SeedAssurance[0].GroupBy(a => 0),
                    ListFarmingAgreements = new Agreement[0].GroupBy(a => 0),
                    ListDryAgreements = new List <DryAgreement>()
                }));
            }

            var model = new AgreementPageViewModel(currentPage)
            {
                ListAgreementsByYears     = _agreementRepository.GetAgreementsListByYears(supplier.CustomerNo),
                ListSeedAgreementsByYears = _agreementRepository.GetSeedAgreementsByYears(supplier.CustomerNo),
                ListFarmingAgreements     = _agreementRepository.GetFarmingAgreementsByYears(supplier.CustomerNo),
                ListDryAgreements         = _agreementRepository.GetDryAgreements(supplier.CustomerNo)
            };

            return(View("Index", model));
        }