Ejemplo n.º 1
0
        // GET: VAT7
        public async Task <IActionResult> Index(int?year, string info)
        {
            VAT7 vat7 = new VAT7();

            vat7.Year         = DateTime.Now.Year;
            vat7.Month        = DateTime.Now.Month - 1;
            ViewData["VAT7"]  = vat7;
            ViewData["Month"] = new SelectList(Tools.getMonthsDictionary(), "Key", "Value", DateTime.Now.Month - 1);
            ViewData["Year"]  = new SelectList(Tools.getYearsList(), DateTime.Now.Year);

            var applicationDbContext = _context.VAT7;

            if (year != null)
            {
                var filteredResult = applicationDbContext.Where(p => p.Year == year);
                ViewData["Year"] = new SelectList(Tools.getYearsList(), year);
                return(View(await filteredResult.ToListAsync()));
            }

            if (!string.IsNullOrEmpty(info))
            {
                ViewBag.Info = info;
            }

            return(View(await applicationDbContext.ToListAsync()));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Year,Month,Paid,Value")] VAT7 vAT7)
        {
            if (id != vAT7.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(vAT7);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VAT7Exists(vAT7.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(vAT7));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,Year,Month")] VAT7 vAT7)
        {
            if (ModelState.IsValid)
            {
                vAT7.Paid  = false;
                vAT7.Value = vAT7.compute(_context);
                if (vAT7.Value != 0)
                {
                    _context.Add(vAT7);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(RedirectToAction(nameof(Index), new { info = "Brak danych dla wybranego okresu" }));
                }
            }

            return(View(vAT7));
        }