Ejemplo n.º 1
0
        public IHttpActionResult PostDeleveryMethod(DeleveryMethod deleveryMethod)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DeleveryMethods.Add(deleveryMethod);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (DeleveryMethodExists(deleveryMethod.ID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = deleveryMethod.ID }, deleveryMethod));
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutDeleveryMethod(int id, DeleveryMethod deleveryMethod)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != deleveryMethod.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetDeleveryMethod(int id)
        {
            DeleveryMethod deleveryMethod = db.DeleveryMethods.Find(id);

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

            return(Ok(deleveryMethod));
        }
Ejemplo n.º 4
0
        public IHttpActionResult DeleteDeleveryMethod(int id)
        {
            DeleveryMethod deleveryMethod = db.DeleveryMethods.Find(id);

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

            db.DeleveryMethods.Remove(deleveryMethod);
            db.SaveChanges();

            return(Ok(deleveryMethod));
        }