Example #1
0
        public async Task <IActionResult> Create([Bind("Id,Nazwa")] Kategoria kategoria)
        {
            if (ModelState.IsValid)
            {
                _context.Add(kategoria);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(kategoria));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("Id,Imie,Nazwisko")] Aktor aktor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(aktor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(aktor));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Id,Cenaa")] Cena Cenaa)

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

            if (ModelState.IsValid)
            {
                _context.Add(Cenaa);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(Cenaa));
        }
Example #4
0
        public async Task <IActionResult> Create([Bind("Id,Tytul,RokProdukcji,KategoriaId,RezyserId,Nowy")] Film film)
        {
            if (ModelState.IsValid)
            {
                var lista = HttpContext.Request.Form["selectedCourses"];
                _context.Add(film);
                await _context.SaveChangesAsync();

                foreach (var l in lista)
                {
                    var cg = new FilmAktor();
                    cg.AktorId = int.Parse(l);
                    cg.FilmId  = film.Id;
                    _context.Add(cg);
                    await _context.SaveChangesAsync();
                }
                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));
        }