public ActionResult DeleteConfirmed(Guid id) { OwnerProduct ownerProduct = db.OwnerProducts.Find(id); db.OwnerProducts.Remove(ownerProduct); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,UserId,Name,Price,Quantity,Description")] OwnerProduct ownerProduct) { if (ModelState.IsValid) { db.Entry(ownerProduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = User.Identity.GetUserId(); return(View(ownerProduct)); }
public ActionResult Create([Bind(Include = "Id,UserId,Name,Price,Quantity,Description")] OwnerProduct ownerProduct) { if (ModelState.IsValid) { ownerProduct.Id = Guid.NewGuid(); db.OwnerProducts.Add(ownerProduct); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = User.Identity.GetUserId(); return(View(ownerProduct)); }
// GET: OwnerProducts/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OwnerProduct ownerProduct = db.OwnerProducts.Find(id); if (ownerProduct == null) { return(HttpNotFound()); } return(View(ownerProduct)); }
public ActionResult _ProductImagesDetail(Guid id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OwnerProduct ownerProduct = db.OwnerProducts.Find(id); if (ownerProduct == null) { return(HttpNotFound()); } return(PartialView(ownerProduct)); }
// GET: OwnerProducts/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } OwnerProduct ownerProduct = db.OwnerProducts.Find(id); if (ownerProduct == null) { return(HttpNotFound()); } ViewBag.UserId = User.Identity.GetUserId(); return(View(ownerProduct)); }
public OwnerProductViewModel(OwnerProduct dbModel) { this.Id = dbModel.Id; this.UserId = dbModel.UserId; this.Name = dbModel.Name; this.Price = dbModel.Price; this.Quantity = dbModel.Quantity; this.Margin = dbModel.Margin; this.Description = dbModel.Description; this.UserName = dbModel.User.UserName; if (dbModel.OwnerProductImages != null && dbModel.OwnerProductImages.Count > 0) { this.ProfileImagePath = dbModel.OwnerProductImages.FirstOrDefault().Path; } else { this.ProfileImagePath = "/Imgs/diaochan.jpg"; } }
public DetailOwnerProductViewModel(OwnerProduct product) { this.OwnerProductImages = new List <OwnerProductImage>(); this.Id = product.Id; this.UserId = product.UserId; this.Name = product.Name; this.Price = product.Price; this.Quantity = product.Quantity; this.Description = product.Description; this.User = product.User; if (product.OwnerProductImages != null && product.OwnerProductImages.Count > 0) { foreach (var productImage in product.OwnerProductImages) { this.OwnerProductImages.Add(productImage); } } }