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