Example #1
0
        public async Task <IActionResult> Create([Bind("MovieTitle,PitchText,AmountBudgeted,RatingFk,Summary,DateInTheaters")] Film film)
        {
            if (ModelState.IsValid)
            {
                _context.Add(film);
                await _context.SaveChangesAsync();

                TempData["message"] = $"{film.MovieTitle} added successfully";
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RatingFk"] = new SelectList(_context.FilmRating, "RatingPk", "Rating", film.RatingFk);
            return(View(film));
        }
Example #2
0
        public async Task <IActionResult> SignUp([Bind("UserLogin, UserPassword, FirstName, LastName")] Contact aContact)
        {
            if (ModelState.IsValid)
            {
                var aUser = await _context.Contact.FirstOrDefaultAsync(u => u.UserLogin == aContact.UserLogin);

                if (aUser is null)
                {
                    _context.Add(aContact);
                    await _context.SaveChangesAsync();

                    TempData["message"] = "Thanks for registering, please log in";
                    return(RedirectToAction("Login"));
                }
                else
                {
                    ViewData["duplicatemessage"] = "Please choose a different username";
                }
            }

            return(View(aContact));
        }
Example #3
0
        public async Task <IActionResult> Add(Merchandise merch)
        {
            if (ModelState.IsValid)
            {
                aRWContext.Add(merch);
                await aRWContext.SaveChangesAsync();

                return(RedirectToAction("TableView"));
            }
            else
            {
                ViewData["FilmFk"] = new SelectList(aRWContext.Film.OrderBy(f => f.MovieTitle), "FilmPk", "MovieTitle");

                return(View());
            }
        }