Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("SessionTimeId,SessionTime1,SessionTime2")] SessionTime sessionTime)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sessionTime);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(sessionTime));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("CompanyId,CompanyName,CompanyCeo,CompanyAge")] Company company)
        {
            if (ModelState.IsValid)
            {
                _context.Add(company);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(company));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("CustomerName,Title,CompanyId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                _context.Add(customer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CompanyId"] = new SelectList(_context.Company, "CompanyId", "CompanyId", customer.CompanyId);
            ViewData["Title"]     = new SelectList(_context.Games, "Title", "Title", customer.Title);
            return(View(customer));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("HikeId,MountainName,MountainId,DateHiked,TimeToSummit")] HikeLog hikeLog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(hikeLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["MountainId"]   = new SelectList(_context.Mountain, "MountainId", "MountainName", hikeLog.MountainId);
            ViewData["MountainName"] = new SelectList(_context.Mountain, "MountainName", "MountainName", hikeLog.MountainName);
            return(View(hikeLog));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("CineplexId,MovieId,SessionId")] CineplexMovie cineplexMovie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cineplexMovie);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewData["CineplexId"] = new SelectList(_context.Cineplex, "CineplexId", "Location", cineplexMovie.CineplexId);
            ViewData["MovieId"]    = new SelectList(_context.Movie, "MovieId", "LongDescription", cineplexMovie.MovieId);
            ViewData["SessionId"]  = new SelectList(_context.SessionTime, "SessionTimeId", "SessionTimeId", cineplexMovie.SessionId);
            return(View(cineplexMovie));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("ID,FirstName,LastName,Address,City,Province,PostalCode,Age,Password," +
                                                       "ConfirmPassword,Email,AlternativeEmail,Phone")] Member member, bool AnotherMember = false)
        // Above, we added AnotherMember as a Create's parameter (false is a default value)
        {
            if (ModelState.IsValid)
            {
                _context.Add(member);
                await _context.SaveChangesAsync();

                // If AnotherMember is true, which means we checked the checkbox...
                if (AnotherMember)
                {
                    // ...redirect to Create (after add a new member, stay in the same page to add another member)
                    return(RedirectToAction(nameof(Create)));
                }
                // Thanks Harry for share the following code to display a message after successfully add new member! \o/
                TempData["notice"] = "Thanks for registering with our website, your record was created successfully.";
                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }