public async Task <IActionResult> Create([Bind("Id,Name")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,ModelId,Color,RentTermin")] Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                _context.Add(vehicle);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ModelId"] = new SelectList(_context.Models, "Id", "Name", vehicle.ModelId);
            return(View(vehicle));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,CategoryId,ManufacturerId")] Model model)
        {
            if (ModelState.IsValid)
            {
                _context.Add(model);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"]     = new SelectList(_context.Categories, "Id", "Name", model.CategoryId);
            ViewData["ManufacturerId"] = new SelectList(_context.Manufacturers, "Id", "Name", model.ManufacturerId);
            return(View(model));
        }