public async Task <IActionResult> Edit(int id, [Bind("Id,Producent,KrajPochodzenia,Model,RokProdukcji,Waga,Wycofany,BagnetId,AparatKategoriaId")] AparatViewModel aparatViewModel)
        {
            if (id != aparatViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aparatViewModel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AparatViewModelExists(aparatViewModel.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BagnetId"]          = new SelectList(_context.Bagnety, "Id", "Typ", aparatViewModel.BagnetId);
            ViewData["AparatKategoriaId"] = new SelectList(_context.Kategorie, "Id", "Name", aparatViewModel.AparatKategoriaId);
            return(View(aparatViewModel));
        }
        public async Task <IActionResult> Create([Bind("Id,Producent,KrajPochodzenia,Model,RokProdukcji,Waga,Wycofany,BagnetId,AparatKategoriaId")] AparatViewModel aparatViewModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aparatViewModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BagnetId"]          = new SelectList(_context.Bagnety, "Id", "Typ", aparatViewModel.BagnetId);
            ViewData["AparatKategoriaId"] = new SelectList(_context.Kategorie, "Id", "Name", aparatViewModel.AparatKategoriaId);
            return(View(aparatViewModel));
        }