Exemplo 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));
        }
Exemplo 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));
        }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "OrderId,Fecha,StateId,UserId")] Order order)
 {
     if (ModelState.IsValid)
     {
         db.Entry(order).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(order));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "StateId,Name")] State state)
 {
     if (ModelState.IsValid)
     {
         db.Entry(state).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(state));
 }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "CategoryId,Description")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "DepartmentId,Name")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "OrderDetailId,OrderId,ProductId,Cantidad,Subtotal")] OrderDetail orderDetail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderDetail).State = EntityState.Modified;
         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));
 }
Exemplo n.º 8
0
        public ActionResult Edit([Bind(Include = "CityId,Name,DepartmentId")] City city)
        {
            if (ModelState.IsValid)
            {
                db.Entry(city).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var Department = ComboxHelper.GetDepartment();

            ViewBag.DepartmentId = new SelectList(Department, "DepartmentId", "Name");
            return(View(city));
        }
Exemplo n.º 9
0
        public ActionResult Edit([Bind(Include = "UserId,UserName,Nombre,Apellido,Direccion,Telefono,Celular,CityId")] User user)
        {
            if (ModelState.IsValid)
            {
                var db2 = new VMarketContext();

                var currentUser = db2.Users.Find(user.UserId);
                if (currentUser.UserName != user.UserName)
                {
                    UsersHelper.UpdateUserName(currentUser.UserName, user.UserName);
                }
                db2.Dispose();

                db.Entry(user).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CityId = new SelectList(db.Cities, "CityId", "Name", user.CityId);
            return(View(user));
        }