Ejemplo n.º 1
0
        public IHttpActionResult PostPizzaSauce(PizzaSauce pizzaSauce)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PizzaSauces.Add(pizzaSauce);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (PizzaSauceExists(pizzaSauce.SauceName))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = pizzaSauce.SauceName }, pizzaSauce));
        }
Ejemplo n.º 2
0
        public IHttpActionResult PutPizzaSauce(string id, PizzaSauce pizzaSauce)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != pizzaSauce.SauceName)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
 public Pizza(int pizzaID, string name, PizzaSize size, PizzaDough dough, PizzaSauce sauce)
 {
     PizzaID = pizzaID;
     Name    = name;
     Size    = size;
     Dough   = dough;
     Sauce   = sauce;
 }
Ejemplo n.º 4
0
 public Pizza(int pizzaID, string name, PizzaSize size, PizzaDough dough, PizzaSauce sauce)
 {
     this.PizzaID = pizzaID;
     this.Name    = name;
     this.Size    = size;
     this.Dough   = dough;
     this.Sauce   = sauce;
 }
Ejemplo n.º 5
0
 public Pizza(int pizzaID, string name, PizzaSize size, PizzaDough dough, PizzaSauce sauce, ObservableCollection <Topping> toppings)
 {
     this.PizzaID  = pizzaID;
     this.Name     = name;
     this.Size     = size;
     this.Dough    = dough;
     this.Sauce    = sauce;
     this.Toppings = toppings;
 }
Ejemplo n.º 6
0
        public IHttpActionResult GetPizzaSauce(string id)
        {
            PizzaSauce pizzaSauce = db.PizzaSauces.Find(id);

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

            return(Ok(pizzaSauce));
        }
Ejemplo n.º 7
0
        public IHttpActionResult DeletePizzaSauce(string id)
        {
            PizzaSauce pizzaSauce = db.PizzaSauces.Find(id);

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

            db.PizzaSauces.Remove(pizzaSauce);
            db.SaveChanges();

            return(Ok(pizzaSauce));
        }