Esempio n. 1
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Product EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToProduct(Product product)
 {
     base.AddObject("Product", product);
 }
Esempio n. 2
0
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="features">Initial value of the Features property.</param>
 /// <param name="image">Initial value of the Image property.</param>
 /// <param name="categoryID">Initial value of the CategoryID property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="dateListed">Initial value of the DateListed property.</param>
 /// <param name="quantity">Initial value of the Quantity property.</param>
 public static Product CreateProduct(global::System.Int32 id, global::System.String name, global::System.String features, global::System.String image, global::System.Int32 categoryID, global::System.Decimal price, global::System.DateTime dateListed, global::System.Int32 quantity)
 {
     Product product = new Product();
     product.ID = id;
     product.Name = name;
     product.Features = features;
     product.Image = image;
     product.CategoryID = categoryID;
     product.Price = price;
     product.DateListed = dateListed;
     product.Quantity = quantity;
     return product;
 }
Esempio n. 3
0
 partial void DeleteProduct(Product instance);
        public ActionResult AddProduct(AddProductInputModel model)
        {
            if (ModelState.IsValid)
            {
                var newProduct = new Product
                {
                    Name = model.Name,
                    Description = this.sanitizer.Sanitize(model.Description),
                    DateAdded = DateTime.UtcNow,
                    Price = model.Price,
                    Quantity = model.Quantity,
                    ProductType = (ProductType)model.ProductType,
                    HazardClassificationId = int.Parse(model.HazardClassificationId),
                    ProducerId = int.Parse(model.ProducerId)
                };

                var productIndustries = new List<Industry>();
                for (int i = 0; i < model.Industries.Count; i++)
                {
                    if (model.Industries[i].IsSelected)
                    {
                        productIndustries.Add(new Industry
                        {
                            Id = model.Industries[i].Id,
                            Name = model.Industries[i].Name
                        });
                    }
                }

                newProduct.Industries = productIndustries;

                if (model.UploadedImage != null)
                {
                    using (var memory = new MemoryStream())
                    {
                        model.UploadedImage.InputStream.CopyTo(memory);
                        var content = memory.GetBuffer();

                        var image = new Image
                        {
                            Content = content,
                            FileExtension = model.UploadedImage.FileName.Split(new[] { '.' }).Last()
                        };

                        newProduct.Image = image;
                    }
                }

                this.products.Add(newProduct);

                return Redirect("/");
            }

            return View();
        }
Esempio n. 5
0
 partial void UpdateProduct(Product instance);
Esempio n. 6
0
 partial void InsertProduct(Product instance);
        //ProductsView myCurrentProduct
        /// <summary>
        /// Generates TD Contents for Product
        /// Level: External
        /// </summary>
        /// <param name="myProduct">The Product</param>
        /// <returns>HTML</returns>
        private string TDContents(Product myProduct)
        {
            try
            {
                string Name = myProduct.Name;
                string ImageURL = VirtualPathUtility.ToAbsolute(myProduct.ImageURL);
                string ProductID = myProduct.Id.ToString();
                string ProductLink = "/user/viewproduct.aspx?id=" + new Encryption().Encrypt(myProduct.Id.ToString());

                User myLoggedUser = new UsersLogic().RetrieveUserByUsername(Context.User.Identity.Name);
                UserTypeProduct myPriceType = new PriceTypesLogic().RetrievePriceTypeByID(myLoggedUser.UserTypeFK, myProduct.Id);

                string Price = "";

                if (myPriceType != null)
                {
                    Price = "€" + myPriceType.Price.ToString("F");
                    double? NewPrice = 0;

                    if ((myPriceType.DiscountDateFrom != null) && (myPriceType.DiscountDateTo != null) && (myPriceType.DiscountPercentage != null))
                    {
                        if ((DateTime.Now >= myPriceType.DiscountDateFrom) && (DateTime.Now <= myPriceType.DiscountDateTo))
                        {
                            NewPrice = myPriceType.Price - ((myPriceType.DiscountPercentage / 100) * myPriceType.Price);

                            string myDisplayedNewPrice = Convert.ToDouble(NewPrice).ToString("F");

                            Price = myPriceType.DiscountPercentage + "% Off : €" + myDisplayedNewPrice;
                        }
                    }
                }

                //string Price = new ProductsLogic().RetrieveProductPrice(_UserType, myProduct.Id).ToString("F");
                string ButtonHTML = "<input type=\"image\" class=\"ProductButton\" alt=\"\" ProductID=\"" + ProductID + "\" ClickAction=\"Add\" src=\"/images/Add.jpg\" onclick=\"return false;\" />" +
                                    "<div class=\"ProductButtonSpacer\"></div>" +
                                    "<input type=\"image\" class=\"ProductButton\" alt=\"\" ProductID=\"" + ProductID + "\" ClickAction=\"Remove\" src=\"/images/Remove.jpg\" onclick=\"return false;\"/>";
                string OutOfStock = "No Stock &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                string LowOnStock = "Low Stock &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
                string TextBox = "<div class=\"MiniFontGrey\"><div style=\"padding-top: 5px; float: left;\">Quantity&nbsp;&nbsp;</div><input type=\"text\" name=\"" + ProductID + "\" class=\"CatalogTextBox\"></div>" +
                                 "<br />";

                if (myProduct.StockQuantity == 0)
                {
                    ButtonHTML = "";
                    LowOnStock = "";
                    TextBox = "<div style=\"height: 27px; width: 1px\"></div>";
                }
                else if (myProduct.StockQuantity <= myProduct.ReorderLevel)
                {
                    OutOfStock = "";
                }
                else
                {
                    LowOnStock = "";
                    OutOfStock = "";
                }

                string HTML = "<div>" +
                                  "<div class=\"ProductContent\">" +
                                      "<img class=\"ProductImage\" alt=\"\" src=\"" + ImageURL + "\" />" +
                                      "<br />" +
                                      "<a href=\"" + ProductLink + "\" target=\"_blank\" class=\"MiniFontGrey\">" + Name + "</a><br />" +
                                   "<div class=\"MiniFontBlue\">" + OutOfStock + LowOnStock + Price + "</div>" +
                                   "<br />" +
                                   TextBox +
                               "</div>" +
                               "<div class=\"ProductButtons\">" +
                                    ButtonHTML +
                               "</div>";

                return HTML;
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the ID property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="features">Initial value of the Features property.</param>
 /// <param name="stock_Amount">Initial value of the Stock_Amount property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="date_Listed">Initial value of the Date_Listed property.</param>
 public static Product CreateProduct(global::System.Guid id, global::System.String name, global::System.String features, global::System.Int32 stock_Amount, global::System.Decimal price, global::System.DateTime date_Listed)
 {
     Product product = new Product();
     product.ID = id;
     product.Name = name;
     product.Features = features;
     product.Stock_Amount = stock_Amount;
     product.Price = price;
     product.Date_Listed = date_Listed;
     return product;
 }
 /// <summary>
 /// Create a new Product object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="description">Initial value of the Description property.</param>
 /// <param name="stockQuantity">Initial value of the StockQuantity property.</param>
 /// <param name="imageURL">Initial value of the ImageURL property.</param>
 /// <param name="status">Initial value of the Status property.</param>
 /// <param name="categoryFK">Initial value of the CategoryFK property.</param>
 /// <param name="vatrateFK">Initial value of the VatrateFK property.</param>
 /// <param name="supplierFK">Initial value of the SupplierFK property.</param>
 public static Product CreateProduct(global::System.Guid id, global::System.String name, global::System.String description, global::System.Int32 stockQuantity, global::System.String imageURL, global::System.Boolean status, global::System.Int32 categoryFK, global::System.Int32 vatrateFK, global::System.Int32 supplierFK)
 {
     Product product = new Product();
     product.Id = id;
     product.Name = name;
     product.Description = description;
     product.StockQuantity = stockQuantity;
     product.ImageURL = imageURL;
     product.Status = status;
     product.CategoryFK = categoryFK;
     product.VatrateFK = vatrateFK;
     product.SupplierFK = supplierFK;
     return product;
 }