protected override async Task OnInitializedAsync() { var result = await ProductGateway.GetProductsWithIdNameDescriptionAndMicroName(); if (result.IsValid) { Products = result.Success; } IsValid = result.IsValid; }
public int InsertProductInfo(Products product) { try { using (ProductGateway productGateway = new ProductGateway()) { actionResult = productGateway.InsertProductInfo(product); } } catch (Exception ex) { } return(actionResult); }
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); }
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 }); }
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; }
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; }
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); }
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}"); }
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()); }
public ProductManager() { productGateway = new ProductGateway(); }
public static List <Product> GetAllProduct() { return(ProductGateway.GetAllProduct()); }
public DbOrderGateway(SqlConnection connection, ProductGateway productGateway) { this.connection = connection; this.productGateway = productGateway; }
/// <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; }
protected override AbstractGateway CreateGateway(IDataRecord reader) { return(ProductGateway.Load(reader)); }