Ejemplo n.º 1
0
        public ActionResult Create(Product product)

        {
            if (ModelState.IsValid)
            {
                db.Products.Add(product);
                db.SaveChanges();
                if (product.ImagenFile != null)
                {
                    var pic    = string.Empty;
                    var folder = "../Content/Imagenes";

                    var response = FileHelper.UploadPhoto(product.ImagenFile, folder, String.Format("Imagen{0}.jpg", product.ProductId));

                    if (response)
                    {
                        pic                     = string.Format("{0}/{1}", folder, String.Format("Imagen{0}.jpg", product.ProductId));
                        product.Imagen          = pic;
                        db.Entry(product).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Description", product.CategoryId);
            return(View(product));
        }
Ejemplo n.º 2
0
        public ActionResult Create(Company company)
        {
            if (ModelState.IsValid)
            {
                db.Companies.Add(company);
                db.SaveChanges();
                if (company.ImagenFile != null)
                {
                    var pic    = string.Empty;
                    var folder = "~/Content/Imagenes";

                    var response = FileHelper.UploadPhoto(company.ImagenFile, folder, String.Format("Logo{0}.jpg", company.CompanyId));

                    if (response)
                    {
                        pic                     = string.Format("{0}/{1}", folder, String.Format("Logo{0}.jpg", company.CompanyId));
                        company.Imagen          = pic;
                        db.Entry(company).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }


                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", company.CityId);
            return(View(company));
        }
Ejemplo n.º 3
0
        public ActionResult Create([Bind(Include = "OrderId,Fecha,StateId,UserId")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(order));
        }
Ejemplo n.º 4
0
        public ActionResult Create([Bind(Include = "StateId,Name")] State state)
        {
            if (ModelState.IsValid)
            {
                db.States.Add(state);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(state));
        }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "CategoryId,Description")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
Ejemplo n.º 6
0
        public ActionResult Create([Bind(Include = "DepartmentId,Name")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
Ejemplo n.º 7
0
        public ActionResult Create([Bind(Include = "OrderDetailId,OrderId,ProductId,Cantidad,Subtotal")] OrderDetail orderDetail)
        {
            if (ModelState.IsValid)
            {
                db.OrderDetails.Add(orderDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.OrderId   = new SelectList(db.Orders, "OrderId", "OrderId", orderDetail.OrderId);
            ViewBag.ProductId = new SelectList(db.Products, "ProductId", "Nombre", orderDetail.ProductId);
            return(View(orderDetail));
        }
Ejemplo n.º 8
0
        public ActionResult Create([Bind(Include = "UserId,UserName,Nombre,Apellido,Direccion,Telefono,Celular,CityId")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                UsersHelper.CreateUserASP(user.UserName, "User");

                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", user.CityId);
            return(View(user));
        }
Ejemplo n.º 9
0
        public ActionResult Create([Bind(Include = "CityId,Name,DepartmentId")] City city)
        {
            if (ModelState.IsValid)
            {
                db.Cities.Add(city);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            var Department = ComboxHelper.GetDepartment();

            ViewBag.DepartmentId = new SelectList(Department, "DepartmentId", "Name");
            return(View(city));
        }