Exemple #1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Route route)
        {
            if (ModelState.IsValid)
            {
                _context.Add(route);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(route));
        }
        public async Task <IActionResult> Create([Bind("Id,RoleId,FirstName,LastName,UserName,Password,BusId")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BusId"]  = new SelectList(_context.Bus, "Id", "LicencePlate", user.BusId);
            ViewData["RoleId"] = new SelectList(_context.Role, "Id", "Name", user.RoleId);
            return(View(user));
        }
        public async Task <IActionResult> Create([Bind("Id,BusId,RouteId")] BusRoute busRoute)
        {
            if (ModelState.IsValid)
            {
                _context.Add(busRoute);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BusId"]   = new SelectList(_context.Bus, "Id", "LicencePlate", busRoute.BusId);
            ViewData["RouteId"] = new SelectList(_context.Route, "Id", "Name", busRoute.RouteId);
            return(View(busRoute));
        }
        public async Task <IActionResult> Create([Bind("Id,CheckPointId,BusId,UserId,RecorDate")] ControlRecord controlRecord)
        {
            if (ModelState.IsValid)
            {
                _context.Add(controlRecord);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BusId"]        = new SelectList(_context.Bus, "Id", "LicencePlate", controlRecord.BusId);
            ViewData["CheckPointId"] = new SelectList(_context.CheckPoint, "Id", "Name", controlRecord.CheckPointId);
            ViewData["UserId"]       = new SelectList(_context.User, "Id", "FirstName", controlRecord.UserId);
            return(View(controlRecord));
        }