Beispiel #1
0
        public async Task <IActionResult> Create([Bind("ID,Gym,RecRoom,Computer")] Game game)
        {
            if (ModelState.IsValid)
            {
                game.ID = Guid.NewGuid();
                _context.Add(game);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(game));
        }
        public async Task <IActionResult> Create([Bind("ID,LastName,FirstMidName,Email,Phone,EnrollmentDate")] Camper camper)
        {
            if (ModelState.IsValid)
            {
                camper.ID = Guid.NewGuid();
                _context.Add(camper);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(camper));
        }
        public async Task <IActionResult> Create([Bind("ID,CamperID,MealID,GameID,Grade")] Enrollment enrollment)
        {
            if (ModelState.IsValid)
            {
                enrollment.ID = Guid.NewGuid();
                _context.Add(enrollment);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CamperID"] = new SelectList(_context.Campers, "ID", "FirstMidName", enrollment.CamperID);
            ViewData["GameID"]   = new SelectList(_context.Games, "ID", "ID", enrollment.GameID);
            ViewData["MealID"]   = new SelectList(_context.Meals, "ID", "ID", enrollment.MealID);
            return(View(enrollment));
        }