Exemplo n.º 1
0
        public ActionResult Index(int contractID)
        {
            var contract = contractRepository.GetById(contractID);

            IndexContractViewModel vm = new IndexContractViewModel(contract);

            return(View(vm));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index(bool showInactive = false)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            ViewBag.showInactive = showInactive;

            IEnumerable <Contract> contracts = await _db.Contracts.ToListAsync();

            var shares = await _db.SharedInfo.ToListAsync();

            var companies = await _db.Company.ToListAsync();

            var currencies = await _db.Currency.ToListAsync();

            var contacts = await _db.Contact.ToListAsync();

            // IEnumerable<Contract> contracts = await _db.Contracts
            //     .Include(x => x.SharedInfo)
            //         .ThenInclude(info => info.Company)
            //     .Include(x => x.SharedInfo)
            //         .ThenInclude(info => info.Currency)
            //     .Include(x => x.SharedInfo)
            //         .ThenInclude(info => info.Contact)
            //     .ToListAsync();

            IndexContractViewModel vm = new IndexContractViewModel()
            {
                Contracts = contracts
            };

            TimeSpan ts      = stopwatch.Elapsed;
            string   message = string.Format("Stránka načtena za: {0:D1}.{1:D3}s", ts.Seconds, ts.Milliseconds);

            if (_env.IsDevelopment())
            {
                TempData["Info"] = message;
            }

            // Filtr - Pouze aktivní
            if (showInactive is false)
            {
                vm.Contracts = vm.Contracts.Where(x => x.Active == true);
            }

            List <Contract> allContracts = await _db.Contracts.ToListAsync();

            ViewBag.AllContractsCount = allContracts.Count();

            return(View(vm));
        }