Example #1
0
        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));
      }
Example #3
0
      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));
      }
Example #4
0
      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));
      }
Example #5
0
 public void AddEntity(object car)
 {
     db.Add(car);
 }