Example #1
0
        public IHttpActionResult PutTyer(int id, Tyer tyer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tyer.TyerId)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #2
0
        public IHttpActionResult GetTyer(int id)
        {
            Tyer tyer = db.Tyers.Find(id);

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

            return(Ok(tyer));
        }
Example #3
0
        public IHttpActionResult PostTyer(Tyer tyer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Tyers.Add(tyer);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tyer.TyerId }, tyer));
        }
Example #4
0
        public IHttpActionResult DeleteTyer(int id)
        {
            Tyer tyer = db.Tyers.Find(id);

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

            db.Tyers.Remove(tyer);
            db.SaveChanges();

            return(Ok(tyer));
        }