Exemple #1
0
        public IHttpActionResult PostVadi(Vadi vadi)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Vadis.Add(vadi);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (VadiExists(vadi.Vadi_ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("BatmanApi-VadisController", new { id = vadi.Vadi_ID }, vadi));
        }
Exemple #2
0
        public IHttpActionResult PutVadi(int id, Vadi vadi)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != vadi.Vadi_ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public IHttpActionResult GetVadi(int id)
        {
            Vadi vadi = db.Vadis.Find(id);

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

            return(Ok(vadi));
        }
Exemple #4
0
        public IHttpActionResult DeleteVadi(int id)
        {
            Vadi vadi = db.Vadis.Find(id);

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

            db.Vadis.Remove(vadi);
            db.SaveChanges();

            return(Ok(vadi));
        }