示例#1
0
        public IHttpActionResult Put(int id, ECarriage eCarriage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != eCarriage.carriage_id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#2
0
        public IHttpActionResult Get(int id)
        {
            ECarriage eCarriage = db.ECarriages.Find(id);

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

            return(Ok(eCarriage));
        }
示例#3
0
        public IHttpActionResult Post(ECarriage eCarriage)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.ECarriages.Add(eCarriage);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = eCarriage.carriage_id }, eCarriage));
        }
示例#4
0
        public IHttpActionResult Delete(int id)
        {
            ECarriage eCarriage = db.ECarriages.Find(id);

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

            db.ECarriages.Remove(eCarriage);
            db.SaveChanges();

            return(Ok(eCarriage));
        }