Beispiel #1
0
        protected override async Task OnInitializedAsync()
        {
            var result = await ProductGateway.GetProductsWithIdNameDescriptionAndMicroName();

            if (result.IsValid)
            {
                Products = result.Success;
            }

            IsValid = result.IsValid;
        }
Beispiel #2
0
 public int InsertProductInfo(Products product)
 {
     try
     {
         using (ProductGateway productGateway = new ProductGateway())
         {
             actionResult = productGateway.InsertProductInfo(product);
         }
     }
     catch (Exception ex)
     {
     }
     return(actionResult);
 }
Beispiel #3
0
        public void TestIdentityMapOfProductFinder()
        {
            int productId        = 9;
            int anotherProductId = 54;

            ProductFinder  productFinder   = new ProductFinder();
            ProductGateway productGateway1 = productFinder.FindProductGatewayById(productId);
            ProductGateway productGateway2 = productFinder.FindProductGatewayById(productId);

            Assert.AreEqual(productGateway1, productGateway2);

            ProductGateway productGateway3 = productFinder.FindProductGatewayById(anotherProductId);

            Assert.AreNotEqual(productGateway1, productGateway3);
            Assert.AreNotEqual(productGateway2, productGateway3);
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            var optionsBuilder = new DbContextOptionsBuilder <DAL_EF.EF.RetailContext>();

            optionsBuilder.UseSqlServer(ConfigurationManager.ConnectionStrings["RetailContext"].ConnectionString);
            StandardKernel kernel = new StandardKernel(
                new UIModule(optionsBuilder.Options));

            IProductService  product  = kernel.Get <IProductService>();
            ICategoryService category = kernel.Get <ICategoryService>();
            ISupplierService supplier = kernel.Get <ISupplierService>();

            var cat = new CategoryDTO()
            {
                Name = "smth43242"
            };

            /*prod.Category=cat;
             * prod1.Category=cat;
             * prod2.Category=cat;*/

            /*category.Create(cat);
            *
            *  var prod = new ProductDTO () {Name= "smth", CategoryId=1, Price = 10};
            *  var prod1 = new ProductDTO () {Name= "smth1", CategoryId=1, Price= 20};
            *
            *
            *  var sup = new SupplierDTO () {Name="sm", Products= new List<ProductDTO> {prod, prod1}};
            *  supplier.Create(sup);*/

            //Console.WriteLine(product.GetWithMaxPrice().ProductId);
            //Console.WriteLine(product.GetWithMinPrice().ProductId);

            ProductGateway  prod  = new ProductGateway(new SqlContext());
            CategoryGateway categ = new CategoryGateway(new SqlContext());

            categ.Create(new ADOCategory()
            {
                Name = "Category"
            });

            prod.Create(new ADOProduct()
            {
                Name = "oof", Price = 10, CategoryId = 1
            });
        }
Beispiel #5
0
        async Task InitializeCreateAsync()
        {
            var result = await ProductGateway.GetCategoriesAndAttributes();

            if (result.IsValid)
            {
                var(categories, attributes) = result.Success;

                Categories = categories;
                Attributes = attributes.ToList();

                Product     = new Product();
                EditContext = new EditContext(Product);
            }

            IsValid = result.IsValid;
        }
Beispiel #6
0
        async Task InitializeUpdateAsync()
        {
            var result = await ProductGateway.GetProductByIdWithCategoriesAndAttributes(ProductId);

            if (result.IsValid)
            {
                var(product, categories, attributes) = result.Success;

                Categories = categories;
                Attributes = attributes.ToList();

                Product     = product;
                EditContext = new EditContext(Product);
            }

            IsValid = result.IsValid;
        }
Beispiel #7
0
        public void TestProductFinder()
        {
            int productId = 9;

            ProductFinder  productFinder  = new ProductFinder();
            ProductGateway productGateway = productFinder.FindProductGatewayById(productId);

            Assert.AreEqual(productId, productGateway.ProductID);
            Assert.AreEqual("Mishi Kobe Niku", productGateway.ProductName);
            Assert.AreEqual(4, productGateway.SupplierID);
            Assert.AreEqual(6, productGateway.CategoryID);
            Assert.AreEqual("18 - 500 g pkgs.", productGateway.QuantityPerUnit);
            Assert.AreEqual(97.0000m, productGateway.UnitPrice);
            Assert.AreEqual((short)29, productGateway.UnitsInStock);
            Assert.AreEqual((short)0, productGateway.UnitsOnOrder);
            Assert.AreEqual((short)0, productGateway.ReorderLevel);
            Assert.AreEqual(true, productGateway.Discontinued);
        }
Beispiel #8
0
        protected async Task HandleSubmit()
        {
            if (!EditContext.Validate())
            {
                return;
            }

            if (ProductId == Guid.Empty)
            {
                await ProductGateway.CreateProduct(Product);
            }
            else
            {
                await ProductGateway.UpdateProduct(Product, ProductId);
            }

            NavigationManager.NavigateTo("products");
        }
        static void Main(string[] args)
        {
            // Usage - no ORM or Mapper for DTO example
            var productGateway = new ProductGateway(ConnectionString);
            var product        = productGateway.GetById(1);
            var success        = productGateway.DeleteById(2);

            foreach (DataRow row in product.Rows)
            {
                Console.WriteLine($"{row["ID"]} {row["name"]}");
            }

            Console.WriteLine($"Is row deleted: {success}");

            // Usage - with ORM
            var customerGateway = new CustomerGateway(new DemoContext());
            var customer        = customerGateway.SelectById(1);

            Console.WriteLine($"Customer last name: {customer.LastName}");
        }
Beispiel #10
0
    public string LoadProductInfo()
    {
        StringBuilder tableRow = new StringBuilder();

        try
        {
            using (ProductGateway productGateway = new ProductGateway())
            {
                int       count = 0;
                DataTable dt    = productGateway.LoadProductsInfo();
                if (dt.Rows.Count > 0)
                {
                    tableRow.Append("<table class='table table-bordered'><thead><tr class='success'>" +
                                    "<th style='text-align:center;padding: 12px; color: #FFFFFF; background-color:#0099FF;border: 2px solid #ffffff'>Serial No</th>" +
                                    // "<th>Product Type</th>" +
                                    "<th style='text-align:center;padding: 12px; color: #FFFFFF; background-color:#0099FF;border: 2px solid #ffffff'>Product Category Name</th>" +
                                    "</tr></thead >");
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        count++;

                        tableRow.Append("<tbody><tr style='border:1px solid #ffffff;background-color:lavender;'>");

                        tableRow.Append("<td  style='text-align:center; border: 2px solid #ffffff;padding: 5px;color: black;'>" + count + "</td>");
                        // tableRow.Append("<td>" + dt.Rows[i]["ProductType"] + "</td>");
                        tableRow.Append("<td style='text-align:center; border: 2px solid #ffffff;padding: 5px;color: black;'>" + dt.Rows[i]["ProductName"] + "</td>");
                        tableRow.Append("</tr></tbody>");
                    }
                    tableRow.Append("</table>");
                }
                else
                {
                    tableRow.Append("No Data Found");
                }
            }
        }
        catch (Exception ex)
        {
        }
        return(tableRow.ToString());
    }
Beispiel #11
0
 public ProductManager()
 {
     productGateway = new ProductGateway();
 }
Beispiel #12
0
 public static List <Product> GetAllProduct()
 {
     return(ProductGateway.GetAllProduct());
 }
Beispiel #13
0
 public DbOrderGateway(SqlConnection connection, ProductGateway productGateway)
 {
     this.connection     = connection;
     this.productGateway = productGateway;
 }
Beispiel #14
0
 /// <summary>
 /// Lauches the entry form on startup
 /// </summary>
 public ProductList()
 {
     InitializeComponent();
     gateway = new ProductGateway();
     ProductsListView.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(ProductsListView_MouseDoubleClick);
 }
 public ProductBLL()
 {
     aProductGateway = new ProductGateway();
 }
 /// <summary>
 /// Lauches the entry form on startup
 /// </summary>
 public ProductView(ProductGateway gateway)
 {
     InitializeComponent();
     this.gateway = gateway;
 }
Beispiel #17
0
 protected override AbstractGateway CreateGateway(IDataRecord reader)
 {
     return(ProductGateway.Load(reader));
 }