Esempio n. 1
0
 public Product(string name, ProductCategory category, ProductSeller typeSeller)
 {
     if (String.IsNullOrEmpty(name))
     {
         throw new ArgumentNullException(paramName: nameof(name));
     }
     this.Name       = name;
     this.Category   = category;
     this.TypeSeller = typeSeller;
 }
Esempio n. 2
0
 public static IEnumerable <Product> FilterProductsByCategory(IEnumerable <Product> products,
                                                              ProductSeller typeSelling)
 {
     foreach (var currentProduct in products)
     {
         if (currentProduct.TypeSeller == typeSelling)
         {
             yield return(currentProduct);
         }
     }
 }
Esempio n. 3
0
        public ActionResult SaveData(ProductSeller item)
        {
            if (item.ProductName != null && item.Price != null && item.ImageUpload != null)
            {
                string fileName  = Path.GetFileNameWithoutExtension(item.ImageUpload.FileName);
                string extension = Path.GetExtension(item.ImageUpload.FileName);
                fileName    = fileName + DateTime.Now.ToString("yymmssff") + extension;
                item.PicUrl = fileName;
                item.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/Content/Images"), fileName));
                db.ProductSellers.Add(item);
                db.SaveChanges();
            }
            var result = "Successfully Added";

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
        /**
         * Realiza la venta del producto a nivel de datos. Decrementa el stock del producto o lo elimina si correcponde
         */
        public void DoSell(int idProduct, int idSeller)
        {
            //Buscar en el stock, decrementar, remover del stock si queda cero, agregar a la lista de vendidos
            Product p = this.FindProductInStock(idProduct);
            Seller  s = this.FindSellerById(idSeller);

            if (p != null && s != null)
            {
                p.Stock--;
                if (p.Stock < 0)
                {
                    //this.Stock.Remove(p);
                    //RNProduct.Remove(p);
                }
                else
                {
                    RNProduct.UpdateProduct(p);
                    ProductSeller ps = new ProductSeller(idProduct, idSeller, p.Price);
                    //this.Sold.Add(ps);
                    RNProductSeller.AddProductSeller(ps);
                }
            }
        }
Esempio n. 5
0
 public static void AddProductSeller(ProductSeller ps)
 {
     context.ProductSeller.Add(ps);
     context.SaveChanges();
 }
Esempio n. 6
0
 public ProductSellerSpecification(ProductSeller productSeller)
 {
     this.productSeller = productSeller;
 }