public IHttpActionResult GetPizzaByPizzaId(PizzaDetail pizzaId)
        {
            PizzaService pizzaService = CreatePizzaService();
            var          pizza        = pizzaService.GetPizzaByPizzaId(pizzaId.PizzaId);

            return(Ok(pizza));
        }
        public IHttpActionResult Delete(PizzaDetail id)
        {
            var service = CreatePizzaService();

            if (!service.DeletePizza(id.PizzaId))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
示例#3
0
        protected void UpdateFields(object sender, EventArgs e)
        {
            PizzaDBEntity db         = new PizzaDBEntity();
            var           name       = PizzaNameDropDown.SelectedValue;
            PizzaDetail   PizzaObj   = new PizzaDetail();
            var           CurrentObj = db.PizzaDetails.Where(p => p.PizzaName == name).FirstOrDefault();

            if (CurrentObj != null)
            {
                desc.Text  = CurrentObj.Description;
                price.Text = CurrentObj.Amount.ToString();
            }
        }
示例#4
0
 public ActionResult AddPizzas(PizzaDetail pizzadetails)
 {
     try
     {
         int id = db.PizzaDetails.Max(x => x.PizzaId);
         pizzadetails.PizzaId = id + 1;
         db.PizzaDetails.Add(pizzadetails);
         db.SaveChanges();
         ViewBag.addmessage = "Pizza Added Successfully!";
     }
     catch (Exception e)
     {
         ViewBag.message = e.Message;
     }
     return(View());
 }
示例#5
0
        public static void SubmitComment(PizzaDetail form, Pizza Pizza)
        {
            int estrellas = form.puntuacion.SelectedIndex;

            if (estrellas == -1)
            {
                MessageBox.Show("Elige la puntuacion de la pizza");
            }
            else
            {
                Comentario c = new Comentario()
                {
                    Id = Guid.NewGuid(), Fecha = DateTime.Now, Pizza = Pizza.Id, Usuario = GetCurrentUser.Id, Puntuacion = estrellas, Texto = form.comentarioText.Text
                };
                GenericDaoEntityFramework gdao = new GenericDaoEntityFramework();
                gdao.InsertSQL(Generic.ToGeneric(c));
                form.lastComment.Text = c.Texto;
            }
        }
示例#6
0
        public bool AddNewOrder(ref CustomerModel customer, ref List <PizzaDetailModel> carts)
        {
            Customer cust = new Customer()
            {
                Name    = customer.Name,
                Address = customer.Address,
                Phone   = customer.Phone
            };

            db.Customers.Create(cust);
            if (Save() == false)
            {
                return(false);
            }
            customer.ID = new CustomerModel(db.Customers.GetLastRecord()).ID;

            Order order = new Order();

            foreach (var item in carts)
            {
                PizzaDetail pd = new PizzaDetail()
                {
                    Detail_ID = item.Detail_ID,
                    Pizza_ID  = item.Pizza_ID,
                };
                db.PizzaDetails.Create(pd);
                if (Save() == false)
                {
                    return(false);
                }
                item.ID = new PizzaDetailModel(db.PizzaDetails.GetLastRecord()).ID;
                order.PizzaDetail_ID  = item.ID;
                order.Customer_ID     = customer.ID;
                order.TotalPriceOrder = item.TotalPrice;
                order.Status_ID       = 1;
                db.Orders.Create(order);
                if (!Save())
                {
                    return(false);
                }
            }
            return(true);
        }
示例#7
0
        public static void LoadValues(PizzaDetail form, Pizza Pizza)
        {
            //TODO Reformar metodo para que no llame 3 veces a a getlastpizzacomment.getcomment
            form.nombrePizza.Content = Pizza.Nombre;
            try
            {
                BitmapImage bp = new BitmapImage();
                bp.UriSource      = new Uri(Pizza.Foto);
                form.image.Source = bp;
            }
            catch (Exception)
            {
                MessageBox.Show("Imagen no encontrada");
            }
            form.precioPizza.Content         = Pizza.Precio.ToString();
            form.ingredientsText.ItemsSource = Pizza.Ingredientes;

            form.lastComment.Text = GetLastPizzaComent.GetComment(Pizza.Id).Texto;
            form.fechaText.Text   = GetLastPizzaComent.GetComment(Pizza.Id).Fecha.ToString();
            form.nombreUser.Text  = GetLastPizzaComent.GetComment(Pizza.Id).Usuario.ToString();
        }
        public ActionResult Edit(PizzaDetail pizzadetails)
        {
            try
            {
                var updatedata = db.PizzaDetails.Single(x => x.PizzaName == pizzadetails.PizzaName);
                var pizzalist  = db.PizzaDetails.ToList();
                ViewBag.pizzanames   = new SelectList(pizzalist, "PizzaName", "PizzaName");
                updatedata.PizzaName = pizzadetails.PizzaName;

                updatedata.Quantity        = pizzadetails.Quantity;
                updatedata.TotalPrice      = updatedata.PizzaPrice * updatedata.Quantity;
                TempData["PizzaName"]      = updatedata.PizzaName;
                TempData["OrderedPizzaId"] = updatedata.PizzaId;
                TempData["TotalAmount"]    = updatedata.TotalPrice;
                db.SaveChanges();
                ViewBag.Updatemessage = "Quantity updated Succesfully!";
            }
            catch (Exception e)
            {
                ViewBag.Message = e.Message;
            }

            return(View());
        }