예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,IdCertifikat,IdZaposlenik")] CertifikatZaposlenik certifikatZaposlenik)
        {
            if (id != certifikatZaposlenik.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(certifikatZaposlenik);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CertifikatZaposlenikExists(certifikatZaposlenik.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCertifikat"] = new SelectList(_context.Certifikat, "Id", "Naziv", certifikatZaposlenik.IdCertifikat);
            ViewData["IdZaposlenik"] = new SelectList(_context.Zaposlenik, "Id", "Ime", certifikatZaposlenik.IdZaposlenik);
            return(View(certifikatZaposlenik));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,IdCertifikat,IdZaposlenik")] CertifikatZaposlenik certifikatZaposlenik)
        {
            if (ModelState.IsValid)
            {
                _context.Add(certifikatZaposlenik);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["IdCertifikat"] = new SelectList(_context.Certifikat, "Id", "Naziv", certifikatZaposlenik.IdCertifikat);
            ViewData["IdZaposlenik"] = new SelectList(_context.Zaposlenik, "Id", "Ime", certifikatZaposlenik.IdZaposlenik);
            return(View(certifikatZaposlenik));
        }
예제 #3
0
 public IActionResult Create(CertifikatZaposlenik katzap)
 {
     if (ModelState.IsValid)
     {
         try{
             ctx.Add(katzap);
             ctx.SaveChanges();
             TempData[Constants.Message]       = $"CertifikatZaposlenik {katzap.Id} dodan.";
             TempData[Constants.ErrorOccurred] = false;
             return(RedirectToAction(nameof(Index)));
         }
         catch (Exception exc) {
             ModelState.AddModelError(string.Empty, exc.CompleteExceptionMessage());
             PrepareDropDownLists();
             return(View(katzap));
         }
     }
     else
     {
         return(View(katzap));
     }
 }