public async Task <ActionResult <Car> > CreateAsync([Bind("Make,Price")] CarBase carBase) { Car car = new Car { Make = carBase.Make, Price = carBase.Price }; _context.Add(car); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetById), new { id = car.ID }, car)); }
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,price")] Accessorie accessorie) { if (ModelState.IsValid) { _context.Add(accessorie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(accessorie)); }
public async Task <IActionResult> Create([Bind("ID,BrandID,name,price,Colours")] Serie serie) { if (ModelState.IsValid) { _context.Add(serie); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["BrandID"] = new SelectList(_context.Set <Brand>(), "ID", "ID", serie.BrandID); return(View(serie)); }
public void AddEntity(object car) { db.Add(car); }