Exemple #1
0
        public ActionResult Add(HttpPostedFileBase file, string Nombre, String Precio)
        {
            decimal precio;

            if (Nombre == null || Nombre == "")
            {
                throw new Exception("Nombre vacio o nulo");
            }

            if (Precio == null || Precio == "")
            {
                throw new Exception("Precio vacio o nulo");
            }

            if (decimal.TryParse(Precio, out precio) == false)
            {
                throw new Exception("Precio no valido");
            }

            if (file == null)
            {
                throw new Exception("Fichero nulo");
            }

            String ruta = UploadFile.Upload(file, this.Server);
            Pizza  p    = new Pizza()
            {
                Id = Guid.NewGuid(), Nombre = Nombre, Precio = precio, Foto = ruta
            };
            GenericDaoEntityFramework gdao = new GenericDaoEntityFramework();

            gdao.InsertSQL(Generic.ToGeneric(p));
            return(View());
        }
Exemple #2
0
        private static void GeneratePizza(AddPizza form, String Ingredient)
        {
            Pizza p = new Pizza()
            {
                Id = Guid.NewGuid(), Nombre = form.nombreText.Text, Foto = form.openFileDialog1.FileName, Precio = form.baseprice, Ingredientes = Ingredient
            };
            GenericDaoEntityFramework gdao = new GenericDaoEntityFramework();

            gdao.InsertSQL(Generic.ToGeneric(p));
            MessageBox.Show("Su pizza ha sido añadida");
            ClearValues(form);
        }
Exemple #3
0
        public ActionResult PizzaDetail(Guid Id)
        {
            if (Id == null)
            {
                throw new Exception("Excepcion Lanzada");
            }

            GenericDaoEntityFramework gdao = new GenericDaoEntityFramework();
            var pizza = gdao.GetSQL(Id, new Pizza().GetType());

            return(View(pizza.Obj));
        }
Exemple #4
0
        public ActionResult Registro(Usuario u)
        {
            if (u == null)
            {
                throw new Exception("Usuario Nulo");
            }

            u.Id = Guid.NewGuid();
            gdao = new GenericDaoEntityFramework();
            gdao.InsertSQL(Generic.ToGeneric(u));
            return(RedirectToAction("Index", "Pizzas"));
        }
Exemple #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;
            }
        }
Exemple #6
0
 public ActionResult Index()
 {
     gdao = new GenericDaoEntityFramework();
     return(View());
 }