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

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Name,Surname,EmailAdress")] Owner owner)
        {
            if (ModelState.IsValid)
            {
                _context.Add(owner);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(owner));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,ModelName,BrandId")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BrandId"] = new SelectList(_context.Brand, "Id", "Name", car.BrandId);
            return(View(car));
        }
        public async Task <IActionResult> Create([Bind("Id,HorsePower,Price,ProductionDate,FuelType,Description,CarId,OwnerId")] Announcement announcement)
        {
            if (ModelState.IsValid)
            {
                _context.Add(announcement);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"]   = new SelectList(_context.Set <Car>(), "Id", "ModelName", announcement.CarId);
            ViewData["OwnerId"] = new SelectList(_context.Set <Owner>(), "Id", "EmailAdress", announcement.OwnerId);
            return(View(announcement));
        }