Esempio n. 1
0
        public async Task <IActionResult> Create([Bind("Did,Name,Gender")] Directors directors)
        {
            if (ModelState.IsValid)
            {
                _context.Add(directors);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(directors));
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Cid,Name,Dob,Email,Phone")] Customers customers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(customers));
        }
Esempio n. 3
0
        public async Task <IActionResult> Create([Bind("MovieId,Cid,DirectorId,Title,ReleaseYear")] Movies movies)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movies);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            //ViewData["Cid"] = new SelectList(_context.Customers, "Cid", "Name", movies.Cid);
            ViewData["DirectorId"] = new SelectList(_context.Directors, "Did", "Name", movies.DirectorId);
            return(View(movies));
        }
Esempio n. 4
0
        public async Task <IActionResult> Create([Bind("MovieId,CustomerId,LoanDate,ReturnDate")] Loan loan)
        {
            if (ModelState.IsValid)
            {
                if (await _context.Loan.SingleOrDefaultAsync(l => l.CustomerId == loan.CustomerId && l.MovieId == loan.MovieId) == null)
                {
                    _context.Add(loan);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }
            ViewBag.MovieId    = new SelectList(_context.Movie, "Id", "Name", loan.MovieId);
            ViewBag.CustomerId = new SelectList(_context.Customer, "Id", "PersonalId", loan.CustomerId);
            return(View(loan));
        }
Esempio n. 5
0
        public async Task <IActionResult> Create([Bind("MovieId,Name,ReleaseDate,Producer,GenreId,Price")] Movie movieToAdd)
        {
            if (ModelState.IsValid)
            {
                if (await _context.Movie.SingleOrDefaultAsync(l => l.MovieId == movieToAdd.MovieId) == null)
                {
                    _context.Add(movieToAdd);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }

            ViewBag.GenreId = new SelectList(_context.Genre, "GenreId", "Name", movieToAdd.GenreId);
            return(View(movieToAdd));
        }
        public async Task <IActionResult> Create([Bind("CustomerId,PersonalId,FirstName,FamilyName,Email,PhoneNumber,Address,Gender,Birthday")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                if (await _context.Customer.SingleOrDefaultAsync(x => x.PersonalId == customer.PersonalId) == null)
                {
                    _context.Add(customer);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                else
                {
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(customer));
        }