Beispiel #1
0
        public async Task <IActionResult> Create([Bind("CarId,BrandId,CarYear,BodyId,Vin,Model,ColorId")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BodyId"]  = new SelectList(_context.Bodies, "BodyId", "BodyName", car.BodyId);
            ViewData["BrandId"] = new SelectList(_context.Brands, "BrandId", "BrandName", car.BrandId);
            ViewData["ColorId"] = new SelectList(_context.Colors, "ColorId", "ColorName", car.ColorId);
            return(View(car));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("CountryId,CountryName")] Country country)
        {
            if (ModelState.IsValid)
            {
                _context.Add(country);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(country));
        }
        public async Task <IActionResult> Create([Bind("SellerId,SellerName,CityId")] Seller seller)
        {
            if (ModelState.IsValid)
            {
                _context.Add(seller);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CityId"] = new SelectList(_context.Cities, "CityId", "CityName", seller.CityId);
            return(View(seller));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("BrandId,BrandName,CountryId")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                _context.Add(brand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryName", brand.CountryId);
            return(View(brand));
        }
        public async Task <IActionResult> Create([Bind("CarSaleId,CustomerId,SellerId,CarId,Price")] CarSale carSale)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carSale);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"]      = new SelectList(_context.Cars, "CarId", "Model", carSale.CarId);
            ViewData["CustomerId"] = new SelectList(_context.Customers, "CustomerId", "CustomerName", carSale.CustomerId);
            ViewData["SellerId"]   = new SelectList(_context.Sellers, "SellerId", "SellerName", carSale.SellerId);
            return(View(carSale));
        }
Beispiel #6
0
        public async Task <IActionResult> Create(int countryId, [Bind("CityId,CountryId,CityName")] City city)
        {
            city.CountryId = countryId;
            if (ModelState.IsValid)
            {
                _context.Add(city);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Cities", new { id = countryId, name = _context.Countries.Where(c => c.CountryId == countryId).FirstOrDefault().CountryName }));
            }
            //ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryName", city.CountryId);
            //return View(city);
            return(RedirectToAction("Index", "Cities", new { id = countryId, name = _context.Countries.Where(c => c.CountryId == countryId).FirstOrDefault().CountryName }));
        }