public async Task <IActionResult> Create([Bind("Id,Tm,V,VN,Cf,VT,Img,FImg")] CarsModel carsModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(carsModel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(carsModel));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,Name,ModelYear,Type,ManufacturerId")] Car car)
        {
            if (ModelState.IsValid)
            {
                _context.Add(car);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ManufacturerId"] = new SelectList(_context.Set <Manufacturer>(), "Id", "Name", car.ManufacturerId);
            return(View(car));
        }
Пример #3
0
        public async Task <IActionResult> Create([Bind("Id,CarId,DriverId,EngineType,EngineSize,FuelConsumption,Description")] Review review)
        {
            if (ModelState.IsValid)
            {
                _context.Add(review);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CarId"]    = new SelectList(_context.Car, "Id", "Name", review.CarId);
            ViewData["DriverId"] = new SelectList(_context.Driver, "Id", "FirstName", review.DriverId);
            return(View(review));
        }
Пример #4
0
        public async Task <IActionResult> Create(DriverViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(model);

                Driver driver = new Driver
                {
                    FirstName     = model.FirstName,
                    LastName      = model.LastName,
                    LicenceSince  = model.LicenceSince,
                    DriverPicture = uniqueFileName
                };


                _context.Add(driver);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Пример #5
0
        public async Task <IActionResult> CreateReview(/*int driverId, */ ReviewCreateViewModel entry)
        {
            if (ModelState.IsValid)
            {
                Review review = new Review
                {
                    Id              = entry.Review.Id,
                    DriverId        = entry.Review.DriverId,
                    CarId           = entry.Review.CarId,
                    EngineSize      = entry.Review.EngineSize,
                    EngineType      = entry.Review.EngineType,
                    FuelConsumption = entry.Review.FuelConsumption,
                    Description     = entry.Review.Description
                };

                _context.Add(review);
                await _context.SaveChangesAsync();

                return(RedirectToAction("ReviewDetails", new { Id = review.Id }));
            }
            return(View());
        }
Пример #6
0
        public async Task <IActionResult> Create(ManufacturerViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = UploadedFile(model);

                Manufacturer manufacturer = new Manufacturer
                {
                    Name                = model.Name,
                    Country             = model.Country,
                    Headquarters        = model.Headquarters,
                    Founded             = model.Founded,
                    ManufacturerPicture = uniqueFileName,
                };

                _context.Add(manufacturer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }