public async Task <IActionResult> PutCarsForSale(int id, CarsForSale carsForSale)
        {
            if (id != carsForSale.Id)
            {
                return(BadRequest());
            }

            _context.Entry(carsForSale).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarsForSaleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <ActionResult <CarsForSale> > PostCarsForSale(CarsForSale carsForSale)
        {
            _context.carsForSales.Add(carsForSale);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCarsForSale", new { id = carsForSale.Id }, carsForSale));
        }
Beispiel #3
0
 public void addCar(CarsForSale newCar)
 {
     using (used_carsContext dbcontext = new used_carsContext())
     {
         dbcontext.CarsForSale.Add(newCar);
         dbcontext.SaveChanges();
     }
 }
Beispiel #4
0
 public void Post([FromBody] CarsForSale newCar)
 {
     cars.addCar(newCar);
 }