Пример #1
0
        public IHttpActionResult PostAnteloD(AnteloD anteloD)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AnteloDs.Add(anteloD);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (AnteloDExists(anteloD.Name))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = anteloD.Name }, anteloD));
        }
Пример #2
0
        public IHttpActionResult PutAnteloD(string id, AnteloD anteloD)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != anteloD.Name)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Пример #3
0
        public IHttpActionResult GetAnteloD(string id)
        {
            AnteloD anteloD = db.AnteloDs.Find(id);

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

            return(Ok(anteloD));
        }
Пример #4
0
        public IHttpActionResult DeleteAnteloD(string id)
        {
            AnteloD anteloD = db.AnteloDs.Find(id);

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

            db.AnteloDs.Remove(anteloD);
            db.SaveChanges();

            return(Ok(anteloD));
        }