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)); }
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)); }
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)); }
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()); }
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()); }
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()); }