示例#1
0
        public IHttpActionResult PutCarStock(int id, CarStock carStock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carStock.Id)
            {
                return(BadRequest());
            }

            db.Entry(carStock).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarStockExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult GetCarStock(int id)
        {
            CarStock carStock = db.CarStock.Find(id);

            if (carStock == null)
            {
                return(NotFound());
            }

            return(Ok(carStock));
        }
示例#3
0
        public IHttpActionResult PostCarStock(CarStock carStock)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.CarStock.Add(carStock);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = carStock.Id }, carStock));
        }
示例#4
0
        public IHttpActionResult DeleteCarStock(int id)
        {
            CarStock carStock = db.CarStock.Find(id);

            if (carStock == null)
            {
                return(NotFound());
            }

            db.CarStock.Remove(carStock);
            db.SaveChanges();

            return(Ok(carStock));
        }
 private void detach_CarStocks(CarStock entity)
 {
     this.SendPropertyChanging();
     entity.CarModel = null;
 }
 private void attach_CarStocks(CarStock entity)
 {
     this.SendPropertyChanging();
     entity.CarModel = this;
 }
 partial void DeleteCarStock(CarStock instance);
 partial void UpdateCarStock(CarStock instance);
 partial void InsertCarStock(CarStock instance);