Example #1
0
        /// <summary>
        /// Occurs when the Products Grid View Selected Index is Changed
        /// Level: External
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvProducts_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                lblImageError.Text   = "";
                lblErrorDisplay.Text = "&nbsp;";

                imgProduct.Visible  = true;
                btnAdd.Visible      = false;
                btnUpdate.Visible   = true;
                reqValImage.Visible = false;

                Product myProduct = new ProductsLogic().RetrieveProductByID(gvProducts.SelectedValue.ToString());

                txtName.Text              = myProduct.Name;
                txtDescription.Text       = myProduct.Description;
                ddlStatus.SelectedValue   = myProduct.Status.ToString().ToLower();
                ddlCategory.SelectedValue = myProduct.CategoryFK.ToString();
                ddlSupplier.SelectedValue = myProduct.SupplierFK.ToString();
                txtVatRate.Text           = myProduct.Vatrate.Vatrate1.ToString();
                txtReorderLevel.Text      = myProduct.ReorderLevel.ToString();
                imgProduct.ImageUrl       = Page.ResolveClientUrl(myProduct.ImageURL);
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public string PopulateProducts(string SupplierID)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    int mySupplierID = Convert.ToInt32(SupplierID);

                    List <OrderItem> myList = (List <OrderItem>)Session["SupplierOrder"];

                    List <Product> myProducts = new ProductsLogic().RetrieveProductsForDisplayBySupplier(mySupplierID).ToList();
                    string         HTML       = "<option value=\"0\">Select</option>";

                    foreach (Product myProduct in myProducts)
                    {
                        if (myList.SingleOrDefault(oi => oi.Id == myProduct.Id) == null)
                        {
                            HTML += "<option value=\"" + myProduct.Id + "\">" + myProduct.Name + "</option>";
                        }
                    }

                    return(HTML);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
Example #3
0
        public void GetProducts_PageShouldSucceed(int page, int pageSize)
        {
            ProductsLogic logic  = new ProductsLogic(new MockUnitOfWork());
            var           result = logic.GetProducts(page, pageSize);

            Assert.Empty(result.Item1);
        }
Example #4
0
        public void UpdateProduct_ShouldThrowNotFoundException(int id, string title, string descirption,
                                                               string imageURL, double price, int[] dts, string vendorUID)
        {
            ProductsLogic logic = new ProductsLogic(new MockUnitOfWork());

            Assert.Throws <NotFoundException>(() => logic.UpdateProduct(id, title, descirption, imageURL, price, dts, vendorUID));
        }
Example #5
0
        public void CreateProduct_ShouldThrowBadRequestException(string title, string descirption,
                                                                 string imageURL, double price, int[] dts, string vendorUID)
        {
            ProductsLogic logic = new ProductsLogic(new MockUnitOfWork());

            Assert.Throws <BadRequestException>(() => logic.CreateProduct(title, descirption, imageURL, price, dts, vendorUID));
        }
Example #6
0
        public IHttpActionResult DeleteProduct(string token, int userId, int id)
        {
            if (!ApplicationHelper.IsTokenValid(token, userId))
            {
                return(Content(HttpStatusCode.BadRequest, "BadRequest"));
            }

            var product = ProductsLogic.GetProduct(id);

            if (product == null)
            {
                return(Content(HttpStatusCode.NotFound, "NotFound"));
            }

            var result = ProductsLogic.DeleteProduct(id);

            if (!result.Success)
            {
                ApplicationHelper.Log(result.Message);
            }

            return(result.Success
                ? Content(HttpStatusCode.OK, "OK")
                : Content(HttpStatusCode.InternalServerError, result.Message));
        }
Example #7
0
        public void GetProducts_ShouldSucceed(int page, int pageSize)
        {
            ProductsLogic logic  = new ProductsLogic(new MockUnitOfWork());
            var           result = logic.GetProducts(page, pageSize);

            Assert.Equal(pageSize, result.Item1.Count);
        }
        public string PopulateProducts()
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    List <ProductsView> myProducts = new ProductsLogic().RetrieveAllProducts().ToList();
                    string HTML = "<option value=\"0\"> Select </option>";

                    foreach (ProductsView myProduct in myProducts)
                    {
                        HTML += "<option value=\"" + myProduct.Id + "\">" + myProduct.Name + "</option>";
                    }

                    return(HTML);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
Example #9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            ProductsLogic productsLogic = new ProductsLogic();

            //Devuelve el último string +1
            this.lblIdProducto.Text = (productsLogic.GetLastID() + 1).ToString();
        }
Example #10
0
        private void FillProductsGrid()
        {
            ProductsLogic productsLogic = new ProductsLogic();

            gridProductList.DataSource = productsLogic.GetAll();
            gridProductList.DataBind();
        }
Example #11
0
        private void GetDatos()
        {
            ProductsLogic pl = new ProductsLogic();

            GridViewProducts.DataSource = pl.GetAllProducts();
            GridViewProducts.DataBind();
        }
Example #12
0
        public void GetProduct_ShouldSucceed(int id)
        {
            ProductsLogic logic  = new ProductsLogic(new MockUnitOfWork());
            var           result = logic.GetProduct(id);

            Assert.Equal(result.Id, id);
        }
Example #13
0
        public string LoadProducts(string OrderID)
        {
            try
            {
                if (Context.User.IsInRole("Administrator"))
                {
                    string HTML = "";

                    Guid myOrderID = Guid.Parse(OrderID.Trim());

                    List <OrderProduct> myProductItems = new OrdersLogic().RetrieveItemsByOrderID(myOrderID).ToList();

                    HTML += "<table>";

                    int Counter = 0;

                    foreach (OrderProduct myProductItem in myProductItems)
                    {
                        HTML += "<tr class=\"GridViewTuple\">";

                        HTML += "<td>";
                        HTML += new ProductsLogic().RetrieveProductByID(myProductItem.ProductFK.ToString()).Name;
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<div style=\"padding-top: 4px; float: left;\">x&nbsp;&nbsp;</div><input class=\"CatalogTextBox\" id=\"" + myProductItem.ProductFK + "\" Use=\"Quantity\" type=\"text\" value=\"" + myProductItem.Quantity.ToString() + "\">";
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<input type=\"button\" ProductID=\"" + myProductItem.ProductFK + "\" Use=\"Update\" value=\"Update\">";
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<input type=\"button\" ProductID=\"" + myProductItem.ProductFK + "\" Use=\"Remove\" value=\"Remove\">";
                        HTML += "</td>";

                        HTML += "<td>";
                        HTML += "<div Use=\"ErrorDiv\" ProductID=\"" + myProductItem.ProductFK + "\" class=\"MiniFontBlue\">Not Enough Stock</div>";
                        HTML += "</td>";

                        HTML += "</tr>";

                        Counter++;
                    }

                    HTML += "</table>";

                    return(HTML);
                }
                else
                {
                    return("");
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
Example #14
0
        public void CreateProduct_ShouldSucceed(string title, string descirption,
                                                string imageURL, double price, int[] dts, string vendorUID)
        {
            ProductsLogic logic = new ProductsLogic(new MockUnitOfWork());

            logic.CreateProduct(title, descirption, imageURL, price, dts, vendorUID);
            Assert.True(true);
        }
Example #15
0
        private void GetProduct(int id)
        {
            ProductsLogic pl = new ProductsLogic();
            Products      p  = pl.GetProduct(id);

            ProductPanel.Visible    = true;
            idProductTextBox.Text   = p.ProductID.ToString();
            productNameTextBox.Text = p.ProductName;
        }
Example #16
0
        public IHttpActionResult GetById(int id)
        {
            var product = new ProductsLogic().GetById(id);

            if (product == null)
            {
                return(NotFound());
            }
            return(Ok(product));
        }
Example #17
0
        public IHttpActionResult GetAll()
        {
            var products = new ProductsLogic().GetAll();

            if (products == null)
            {
                return(NotFound());
            }
            return(Ok(products));
        }
Example #18
0
 public MarketPageUserViewModel()
 {
     usersLogic     = UsersLogic.GetInstance();
     historiesLogic = HistoriesLogic.GetInstance();
     Condition      = "Visible";
     FullName       = usersLogic.GetFullName();
     Checks         = new ObservableCollection <Check>(historiesLogic.GetChecks(UsersLogic.GetId()));
     SeeCheck       = new RelayCommand <int>(ThisCheck);
     ProductsLogic.GetInstance();
 }
Example #19
0
        private void FillProductData()
        {
            ProductsLogic productsLogic = new ProductsLogic();
            Products      product       = new Products();

            product = productsLogic.GetData(productID);

            this.txtNombre.Text   = product.ProductName;
            this.txtCantidad.Text = product.QuantityPerUnit;
            this.txtPrecio.Text   = (product.UnitPrice).ToString();
        }
Example #20
0
        /// <summary>
        /// Occurs when the Product Update Button is Clicked
        /// Level: External
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (Page.IsValid)
                {
                    lblImageError.Text   = "";
                    lblErrorDisplay.Text = "&nbsp;";

                    Tuple <string, UploadResult> myResult = new UploadImage().Upload(fuImage);
                    string PreviousURL = new ProductsLogic().RetrieveProductByID(gvProducts.SelectedValue.ToString()).ImageURL;

                    string ProductID    = gvProducts.SelectedValue.ToString();
                    string Name         = txtName.Text;
                    string Description  = txtDescription.Text;
                    bool   Status       = Convert.ToBoolean(ddlStatus.SelectedValue);
                    int    CategoryID   = Convert.ToInt32(ddlCategory.SelectedValue);
                    int    SupplierID   = Convert.ToInt32(ddlSupplier.SelectedValue);
                    int    ReorderLevel = Convert.ToInt32(txtReorderLevel.Text);
                    double VatRate      = Convert.ToDouble(txtVatRate.Text);
                    string ImageURL     = null;

                    if (myResult.Item2 == UploadResult.InvalidExtension)
                    {
                        lblImageError.Text = "Invalid Image Extension";
                    }
                    else if (myResult.Item2 == UploadResult.NoImageFound)
                    {
                        new ProductsLogic().UpdateProduct(ProductID, Name, Description, ImageURL, Status, CategoryID, VatRate, SupplierID, ReorderLevel);

                        gvProducts.DataSource = new ProductsLogic().RetrieveAllProducts();
                        gvProducts.DataBind();
                    }
                    else
                    {
                        File.Delete(Server.MapPath(PreviousURL));

                        ImageURL = myResult.Item1;

                        new ProductsLogic().UpdateProduct(ProductID, Name, Description, ImageURL, Status, CategoryID, VatRate, SupplierID, ReorderLevel);

                        gvProducts.DataSource = new ProductsLogic().RetrieveAllProducts();
                        gvProducts.DataBind();

                        imgProduct.ImageUrl = Page.ResolveClientUrl(ImageURL);
                    }
                }
            }
            catch (Exception Exception)
            {
                throw Exception;
            }
        }
        public AuctionController(IRepository <Product> _ProductRepo, IRepository <Batch> _ProductInStoreRepo, IRepository <Transaction> _TransactiontRepo,
                                 IRepository <Auction> _AuctionRepo, IRepository <ProductToBeAuctioned> _ProductToBeAuctionedRepo, IRepository <Loss> _LossRepo,
                                 IRepository <AuctionTransactionStatus> _AuctionStatusTransactionRepo, ProductsLogic _Logic)
        {
            ProductRepo       = _ProductRepo;
            Auctionrepo       = _AuctionRepo;
            BatchRepo         = _ProductInStoreRepo;
            TransactionRepo   = _TransactiontRepo;
            ToBeAuctionedRepo = _ProductToBeAuctionedRepo;

            ProductsLogic = _Logic;
        }
 private void LoadProducts()
 {
     Task.Run(() =>
     {
         productsLogic = ProductsLogic.GetInstance();
         while (productsLogic.GetListProducts() == null)
         {
             ;
         }
         Products = new ObservableCollection <Product>(productsLogic.GetListProducts());
     });
 }
Example #23
0
 public OrderViewModel()
 {
     Condition        = "Visible";
     historiesLogic   = HistoriesLogic.GetInstance();
     productsLogic    = ProductsLogic.GetInstance();
     Products         = new ObservableCollection <Product>(productsLogic.GetListProducts());
     InCheck          = new ObservableCollection <Product>();
     FinishSum        = 0;
     ViewAboutProduct = new RelayCommand <int>(ViewProduct);
     AddToCheck       = new RelayCommand <int>(AddToBuy);
     DeleteProduct    = new RelayCommand <int>(DeleteAtCheck);
 }
Example #24
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            ProductsLogic productsLogic = new ProductsLogic();

            productsLogic.Add(new Products
            {
                //ProductID = productsLogic.GetLastID() + 1, /* Tiene generador de ID automático, no es necesario  */
                ProductName     = this.txtNombre.Text,
                QuantityPerUnit = this.txtCantidad.Text,
                UnitPrice       = decimal.Parse(this.txtPrecio.Text)
            });
            ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "alert('Producto agregado!'); window.location='" + Request.ApplicationPath + "Default.aspx';", true);
        }
 public ProductsController(IRepository <Product> _ProductRepo, IRepository <FoodWastePreventionSystem.Models.Batch> _ProductInStoreRepo,
                           IRepository <Transaction> _TransactiontRepo, IRepository <Auction> _AuctionRepo,
                           IRepository <ProductToBeAuctioned> _ProductToBeAuctionedRepo, IRepository <Loss> _LossRepo,
                           IRepository <AuctionTransactionStatus> _AuctionTransactionStausRepo,
                           AuctionLogic _AuctionL, ProductsLogic _ProductL, SalesLogic _SalesL, BackgroundTasks _cron)
 {
     Cron              = _cron;
     ProductRepo       = _ProductRepo;
     Auctionrepo       = _AuctionRepo;
     ToBeAuctionedRepo = _ProductToBeAuctionedRepo;
     ProductLogic      = _ProductL;
     AuctionLogic      = _AuctionL;
     SalesLogic        = _SalesL;
 }
Example #26
0
        static void Main(string[] args)
        {
            Console.WriteLine("A continuación se muestran las categorías:");
            Console.WriteLine("");

            CategoriesLogic categoriesLogic = new CategoriesLogic();
            var             categories      = categoriesLogic.Categories();

            foreach (var item in categories)
            {
                Console.WriteLine($"ID: {item.CategoryID.ToString()} , NOMBRE: {item.CategoryName.ToString()}, DESCRIPCIÓN: {item.Description.ToString()} ");
            }

            Console.ReadKey();
            Console.Clear();


            Console.WriteLine("Ingrese un número de ID de Producto o ingrese 0 para finalizar.");
            Console.WriteLine("");
            string paramProducto = Console.ReadLine();

            while (paramProducto != "0")
            {
                int  i     = 0;
                bool EsInt = int.TryParse(paramProducto, out i);

                ProductsLogic productsLogic = new ProductsLogic();
                var           products      = productsLogic.Products();
                var           item          = productsLogic.Products(i);
                productsLogic.Products(i);
                if (EsInt && i < products.Count)
                {
                    Console.WriteLine($" ID: {item.ProductID} , NOMBRE: {item.ProductName} , ID DE PROVEEDOR: {item.SupplierID} , CATEGORIA: {item.CategoryID}, {System.Environment.NewLine} " +
                                      $"CANTIDAD POR UNIDAD: {item.QuantityPerUnit} , PRECIO UNITARIO: {item.UnitPrice} ,  UNIDADES EN STOCK: {item.UnitsInStock}, {System.Environment.NewLine} UNIDADES ENCARGADAS: {item.UnitsOnOrder} , PUNTO DE PEDIDO: {item.ReorderLevel} , DESCONTINUADO: {item.Discontinued}");
                }
                else
                {
                    Console.WriteLine("");
                    Console.WriteLine($"Ingrese un valor numérico válido menor que {products.Count}");
                }
                Console.WriteLine("");
                Console.WriteLine("Ingrese otro número de ID de Producto o ingrese 0 para finalizar.");
                Console.WriteLine("");
                paramProducto = Console.ReadLine();
            }
            Console.WriteLine("Finalizó la consulta.");
            Console.ReadKey();
        }
Example #27
0
        public AnalysisController(IRepository <Product> _ProductRepo, IRepository <Batch> _ProductInStoreRepo,
                                  IRepository <Transaction> _TransactiontRepo, IRepository <Auction> _AuctionRepo,
                                  IRepository <ProductToBeAuctioned> _ProductToBeAuctionedRepo, IRepository <Loss> _LossRepo,
                                  IRepository <AuctionTransactionStatus> _AuctionStatusTransactionRepo, ProfitLogic _ProfitLogic,
                                  SalesLogic _SalesLogic, ProductsLogic _ProductsLogic)
        {
            ProductRepo        = _ProductRepo;
            Auctionrepo        = _AuctionRepo;
            ProductInStoreRepo = _ProductInStoreRepo;
            TransactionRepo    = _TransactiontRepo;
            ToBeAuctionedRepo  = _ProductToBeAuctionedRepo;

            ProfitLogic   = _ProfitLogic;
            SalesLogic    = _SalesLogic;
            ProductsLogic = _ProductsLogic;
        }
Example #28
0
        public IHttpActionResult GetProduct(string token, int userId, int id)
        {
            if (!ApplicationHelper.IsTokenValid(token, userId))
            {
                return(Content(HttpStatusCode.BadRequest, "BadRequest"));
            }

            var product = ProductsLogic.GetProduct(id);

            if (product == null)
            {
                return(Content(HttpStatusCode.NotFound, "NotFound"));
            }

            return(Content(HttpStatusCode.OK, product));
        }
Example #29
0
        protected void btnEditar_Click(object sender, EventArgs e)
        {
            ProductsLogic productsLogic = new ProductsLogic();

            Products product = new Products
            {
                ProductID       = productID,
                ProductName     = this.txtNombre.Text,
                QuantityPerUnit = this.txtCantidad.Text,
                UnitPrice       = decimal.Parse(this.txtPrecio.Text)
            };

            productsLogic.Update(product);

            Response.Redirect("Default.aspx");
        }
        public void addproductCart()
        {
            int input = 0;

            input = Int32.Parse(Console.ReadLine());
            var cart     = new CartsLogic();
            var products = new ProductsLogic();


            Console.WriteLine("                                                                         ");
            Console.WriteLine("                                                                         ");
            Console.WriteLine("                                                                         ");
            Console.WriteLine("       +================================================================+");
            Console.WriteLine("       |                                                                |");
            Console.WriteLine("       |             WELCOME TO JOY LORUTH'S GROCERY STORE              |");
            Console.WriteLine("       |                                                                |");
            Console.WriteLine("       +================================================================+");
            Console.WriteLine("       +----------------------------------------------------------------+");
            Console.WriteLine("       |                    [1] ADD ANOTHER PRODUCT                     |");
            Console.WriteLine("       +----------------------------------------------------------------+");
            Console.WriteLine("       +----------------------------------------------------------------+");
            Console.WriteLine("       |                    [2] MAIN MENU                                  |");
            Console.WriteLine("       +----------------------------------------------------------------+");

            input = Int32.Parse(Console.ReadLine());

            switch (input)
            {
            case 1:
                Console.Clear();
                products.GetProducts();
                cart.Add();

                break;

            case 2:
                Console.Clear();


                break;

            default:
                var mainMenu2 = new MainMenu();
                mainMenu2.viewMainMenu();
                break;
            }
        }