Example #1
0
        public async Task <ActionResult <CarOil> > PostCarOil(CarOil carOil)
        {
            this.db.CarOils.Add(carOil);
            await this.db.SaveChangesAsync();

            return(CreatedAtAction("GetCarOil", new { id = carOil.Id }, carOil));
        }
Example #2
0
        public async Task <IActionResult> PutCarOil(int id, CarOil carOil)
        {
            if (id != carOil.Id)
            {
                return(BadRequest());
            }

            this.db.Entry(carOil).State = EntityState.Modified;

            try
            {
                await this.db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarOilExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }