コード例 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nazwa")] Kategoria kategoria)
        {
            if (id != kategoria.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(kategoria);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!KategoriaExists(kategoria.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(kategoria));
        }
コード例 #2
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Imie,Nazwisko")] Aktor aktor)
        {
            if (id != aktor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aktor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AktorExists(aktor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aktor));
        }
コード例 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Cenaa")] Cena Cenaa)
        {
            if (id != Cenaa.Id)
            {
                return(NotFound());
            }

            if (Cenaa is null)
            {
                throw new ArgumentNullException(nameof(Cenaa));
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(Cenaa);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CenaExists(Cenaa.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(Cenaa));
        }
コード例 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Tytul,RokProdukcji,KategoriaId,RezyserId,Nowy")] Film film)
        {
            if (id != film.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (var cgold in _context.FilmAktors.Where(cg => cg.FilmId == film.Id))
                    {
                        _context.Remove(cgold);
                    }
                    var lista = HttpContext.Request.Form["selectedCourses"];
                    foreach (var l in lista)
                    {
                        var cg = new FilmAktor();
                        cg.AktorId = int.Parse(l);
                        cg.FilmId  = film.Id;
                        _context.Add(cg);
                        await _context.SaveChangesAsync();
                    }
                    _context.Update(film);

                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FilmExists(film.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["KategoriaId"] = new SelectList(_context.Kategorias, "Id", "Nazwa", film.KategoriaId);
            ViewData["RezyserId"]   = new SelectList(_context.Rezysers, "Id", "ImieNazwisko", film.RezyserId);
            return(View(film));
        }