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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }
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)); }