public ActionResult CreateSell() { WantThis.Source.SellWrapper product = new WantThis.Source.SellWrapper(); return View(product); }
public ActionResult EditSell(int id, FormCollection formValues) { Models.Product product = productRepo.getProduct(id); if (!product.isOwnedBy(User.Identity.Name)) return View("InvalidOwner"); double price = Convert.ToDouble(formValues["price"]); double urgency = Convert.ToDouble(formValues["urgency"]); SellWrapper sw = new SellWrapper(); try { product.Name = Request.Form["product_wrapper.product.Name"]; product.Description = Request.Form["product_wrapper.product.Description"]; product.Features = Request.Form["product_wrapper.product.Features"]; product.Category = Request.Form["product_wrapper.product.Category"]; sw.product_wrapper = new ProductWrapper(product); sw.price = Convert.ToInt32(price); sw.urgency = Convert.ToInt32(urgency); productRepo.Save(); Sell s = productRepo.getSell(product.ProductID); if (price < 0 || price > 10000 || urgency < 0 || urgency > 10) throw new Exception(); s.Asking_Price = price; s.Urgency = Convert.ToInt32(urgency); productRepo.Save(); return RedirectToAction("UploadImage", new { id = product.ProductID }); } catch { foreach (var issue in sw.GetRuleViolations()) { ModelState.AddModelError(issue.PropertyName, issue.ErrorMessage); } } return View(new SellWrapper(new Source.ProductWrapper(product), Convert.ToInt32(price),Convert.ToInt32(urgency))); }