public ActionResult Edit(string id, string productData) { try { Product Product = new Product(); List <StaticProperty> StaticPropertyList = StaticPropertyDAO.LoadAll(); //edit an existing product if (!string.IsNullOrWhiteSpace(id)) { Product = ProductDAO.LoadByBsonId(id); } //add a new product else if (string.IsNullOrWhiteSpace(productData)) { //add 4 empty additional images Product.AdditionalImages.Add(new ProductImage()); Product.AdditionalImages.Add(new ProductImage()); Product.AdditionalImages.Add(new ProductImage()); Product.AdditionalImages.Add(new ProductImage()); StaticProperty ShippingMethods = StaticPropertyList.Where(e => e.KeyName.Equals(StaticProperty.SHIPPING_METHOD_PROPERTY_KEY)).FirstOrDefault(); if (ShippingMethods != null && ShippingMethods.PropertyNameValues != null && ShippingMethods.PropertyNameValues.Count > 0) { foreach (var ShippingMethodName in ShippingMethods.PropertyNameValues) { Product.PurchaseSettings.ShippingMethodList.Add(new ShippingMethodProperty(ShippingMethodName, 0)); } } } //redirected here after attempting to save a product that failed validation else { Product = JsonConvert.DeserializeObject <Product>(productData); } ViewBag.AllStaticProperties = StaticPropertyList; ViewBag.Product = Product; ViewBag.ImageList = Chimera.DataAccess.ImageDAO.LoadAll(); return(View()); } catch (Exception e) { CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.ProductController.Edit()" + e.Message); } AddWebUserMessageToSession(Request, String.Format("Unable to add/update products at this time."), FAILED_MESSAGE_TYPE); return(RedirectToAction("Index", "Dashboard")); }
public ActionResult ViewAll() { try { ViewBag.StaticPropertyList = StaticPropertyDAO.LoadAll(); } catch (Exception e) { CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.PropertiesController.ViewAll() " + e.Message); } return(View()); }