Esempio n. 1
0
        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");
        }
 /// <summary>
 /// Default Constructor.
 /// </summary>
 public ShoppingCartProduct(Product.Product product)
 {
     Id = product.Id;
     Name = product.Name;
     MainImagePath = product.MainImage.ImagePath;
     Quantity = 1;
     PurchaseSettings = product.PurchaseSettings;
     SelectedCheckoutProperties = new List<CheckoutPropertySettingKey>();
     CheckoutPropertySetting = new CheckoutPropertySetting();
     PrivateCartUniqueId = string.Empty;
 }
Esempio n. 3
0
        /// <summary>
        /// Called whenever the admin user updates the product to remove the notification
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static bool ProductStockUpdated(Product product)
        {
            try
            {
                return DashboardNotificationDAO.Delete(product.Id);
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.ProductStock.ProductStockUpdated()" + e.Message);
            }

            return false;
        }
Esempio n. 4
0
        /// <summary>
        /// Process a purchased product after the stock level has been altered from the purchase order
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static bool ProcessPurchasedProduct(SettingGroup paypalSettings, Product product)
        {
            try
            {
                string StockLevelWarningString = paypalSettings.GetSettingVal(PayPalSettingKeys.StockLevelWarning);

                int StockLevelWarning = Int32.Parse(!string.IsNullOrWhiteSpace(StockLevelWarningString) ? StockLevelWarningString : "0");

                if (product.PurchaseSettings.StockLevel <= StockLevelWarning)
                {
                    Notification NewNotification = GenerateNewNotification(product.Name, product.Id, product.PurchaseSettings.StockLevel);

                    DashboardNotificationDAO.Save(NewNotification);
                }

                if (product.CheckoutPropertySettingsList != null && product.CheckoutPropertySettingsList.Count > 0)
                {
                    foreach (var CheckPropSetting in product.CheckoutPropertySettingsList)
                    {
                        if (CheckPropSetting.PurchaseSettings.StockLevel <= StockLevelWarning)
                        {
                            Notification NewNotification = GenerateNewNotification(product.Name, product.Id, product.PurchaseSettings.StockLevel, CheckPropSetting.CheckoutPropertySettingKeys);

                            DashboardNotificationDAO.Save(NewNotification);
                        }
                    }
                }

                return true;
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("Chimera.Core.Notifications.ProductStock.ProcessPurchasedProduct()" + e.Message);
            }

            return false;
        }
Esempio n. 5
0
        /// <summary>
        /// Save or update a product.
        /// </summary>
        /// <param name="product"></param>
        /// <returns></returns>
        public static bool Save(Product product)
        {
            if (product.Id.Equals(string.Empty))
            {
                product.CreatedDateUtc = DateTime.UtcNow;
            }

            return Execute.Save<Product>(COLLECTION_NAME, product);
        }
        /// <summary>
        /// Called to load a preview of the unique product list module
        /// </summary>
        /// <param name="viewType"></param>
        /// <returns></returns>
        public ActionResult Preview(string viewType, int numFakeProds)
        {
            try
            {
                List<Product> ProductList = new List<Product>();

                for (int i = 1; i <= numFakeProds; i++)
                {
                    Product Prod = new Product();

                    Prod.Name = "Fake Product " + i;
                    Prod.Description = "Praesent at tellus porttitor nisl porttitor sagittis. Mauris in massa ligula, a tempor nulla. Ut tempus interdum mauris vel vehicula. Nulla ullamcorper tortor commodo in sagittis est accumsan.";
                    Prod.PurchaseSettings.PurchasePrice = i * 5;

                    ProductList.Add(Prod);

                }

                return Content(CompanyCommons.Utility.RenderPartialViewToString(ControllerContext, GetPartialViewPath(viewType), new ProductListModel(viewType, ProductList), false));
            }
            catch (Exception e)
            {
                CompanyCommons.Logging.WriteLog("ChimeraWebsite.Controllers.SearchProductsController.Active() " + e.Message);
            }

            return Content("");
        }
Esempio n. 7
0
 public ProductModel(string viewType, CE.Product product)
 {
     ViewType = viewType;
     Product  = product;
 }