public static bool DeleteCategory(int categoryID) { bool result = false; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.RemoveCategory(categoryID); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return result; }
public static ProductCategory UpdateCategory(CategoryData category) { ProductCategory result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.UpdateCategory(new ProductCategory() { Name = category.Name, IsActive = category.IsActive, ProductCategoryID = category.ProductCategoryID }); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return(result); }
public static bool DeleteCategory(int categoryID) { bool result = false; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.RemoveCategory(categoryID); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return(result); }
public static List<ProductData> GetProductList() { List<ProductData> result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.ProductList(); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return result; }
public static List <ProductData> GetProductList() { List <ProductData> result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.ProductList(); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return(result); }
public static Product UpdateProduct(ProductData product) { Product result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.UpdateProduct(new Product() { ProductID = product.ProductID, Name = product.Name, ProductNumber = product.ProductNumber, Color = product.Color, ListPrice = product.ListPrice, ProductDescription = product.ProductDescription, Quantity = product.Quantity, ProductCategoryID = product.CategoryID, IsActive = product.IsActive }); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return(result); }
public static List <CategoryData> GetCategoryList() { List <CategoryData> result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; List <ProductCategory> productsList = client.CategoriesList(); var q = from product in productsList select new CategoryData() { ProductCategoryID = product.ProductCategoryID, Name = product.Name, IsActive = product.IsActive, ProductCount = product.ProductCount }; result = q.ToList(); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return(result); }
public static List<CategoryData> GetCategoryList() { List<CategoryData> result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; List<ProductCategory> productsList = client.CategoriesList(); var q = from product in productsList select new CategoryData() { ProductCategoryID = product.ProductCategoryID, Name = product.Name, IsActive = product.IsActive, ProductCount = product.ProductCount }; result = q.ToList(); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return result; }
public static void RunTest() { PermissiveCertificatePolicy.Enact("CN=HTTPS-Server"); Console.Write("Initializing Proxy for Category Tests..."); BicycleWorldServiceClient proxy = new BicycleWorldServiceClient("DefaultBinding_BicycleWorldService_BicycleWorldService"); Console.WriteLine(" done"); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; try { Console.WriteLine(proxy.Test()); Console.WriteLine("Test 1: List all categories"); var categories = proxy.CategoriesList(); foreach (var category in categories) { Console.WriteLine(" Category ID: {0:000}, Name: {1}", category.ProductCategoryID, category.Name); } Console.WriteLine("Test 2: Removing all 'TEST' categories"); foreach (var category in categories.Where(c => c.Name == "TEST")) { Console.Write(" Removing ProductCategoryID {0:000}... ", category.ProductCategoryID); if (proxy.RemoveCategory(category.ProductCategoryID)) { Console.WriteLine("Removed."); } else { Console.WriteLine("Not removed."); } } Console.WriteLine("Test 3: Add 'TEST' category"); int productCategoryID = proxy.AddCategory(new ProductCategory() { Name = "TEST", }); Console.WriteLine(" New category added. ProductCategoryID: {0}", productCategoryID); Console.WriteLine(" Test 4: Update 'TEST' category"); ProductCategory categoryToUpdate = proxy.GetCategory(productCategoryID); Console.WriteLine(" Name was: {0}", categoryToUpdate.Name); categoryToUpdate.Name = "test"; categoryToUpdate = proxy.UpdateCategory(categoryToUpdate); categoryToUpdate = proxy.GetCategory(productCategoryID); Console.WriteLine(" Name is now: {0}", categoryToUpdate.Name); Console.WriteLine("Test 4: Remove 'TEST' category"); bool removalSuccessful = proxy.RemoveCategory(productCategoryID); Console.WriteLine(" Removal Successful: {0}", removalSuccessful); Console.WriteLine(); // Disconnect from the service proxy.Close(); } catch (FaultException <SystemFault> sf) { Console.WriteLine("SystemFault {0}: {1}\n{2}", sf.Detail.SystemOperation, sf.Detail.SystemMessage, sf.Detail.SystemReason); } catch (FaultException <DatabaseFault> dbf) { Console.WriteLine("DatabaseFault {0}: {1}\n{2}", dbf.Detail.DbOperation, dbf.Detail.DbMessage, dbf.Detail.DbReason); } catch (FaultException e) { Console.WriteLine("{0}: {1}", e.Code.Name, e.Reason); } catch (Exception e) { Console.WriteLine("General exception: {0}", e.Message); Console.WriteLine("Inner Exception: {0}", e.InnerException); } //Console.WriteLine("Press ENTER to continue"); //Console.ReadLine(); }
public static void RunTest() { // Create a proxy object and connect to the service PermissiveCertificatePolicy.Enact("CN=HTTPS-Server"); Console.Write("Initializing Product Proxy..."); BicycleWorldServiceClient proxy = new BicycleWorldServiceClient("DefaultBinding_BicycleWorldService_BicycleWorldService"); Console.WriteLine(" done"); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; // Test the operations in the service try { Console.WriteLine(proxy.Test()); // Obtain a list of all products Console.WriteLine("Test 1: List all products"); var products = proxy.ProductList(); foreach (var product in products) { Console.WriteLine(" Product ID: {0:000}, ProductNumber: {1}", product.ProductID, product.ProductNumber); } Console.WriteLine("Test 2: Removing all 'TEST' products"); foreach (var product in products.Where(p=>p.ProductNumber=="TEST")) { Console.Write(" Removing productID {0:000}... ", product.ProductID); if (proxy.RemoveProduct(product.ProductID)) Console.WriteLine("Removed."); else Console.WriteLine("Not removed."); } Console.WriteLine("Test 3: Add 'TEST' product"); int productID = proxy.AddProduct(new Product() { Name = "Test", Color = "RED", ListPrice = (decimal)3.99, ProductCategoryID = 1, ProductDescription = "Test Mountain bike", ProductNumber = "TEST", Quantity = 5, }); Console.WriteLine(" New producted added. ProductID: {0}", productID); Console.WriteLine(" Test 4: Update 'TEST' product"); Product productToUpdate = proxy.GetProduct(productID); Console.WriteLine(" Price was: {0}", productToUpdate.ListPrice); productToUpdate.ListPrice = (decimal)7.99; productToUpdate = proxy.UpdateProduct(productToUpdate); productToUpdate = proxy.GetProduct(productID); Console.WriteLine(" Price is now: {0}", productToUpdate.ListPrice); Console.WriteLine("Test 4: Remove 'TEST' product"); bool removalSuccessful = proxy.RemoveProduct(productID); Console.WriteLine(" Removal Successful: {0}", removalSuccessful); Console.WriteLine(); // Disconnect from the service proxy.Close(); } catch (FaultException<SystemFault> sf) { Console.WriteLine("SystemFault {0}: {1}\n{2}", sf.Detail.SystemOperation, sf.Detail.SystemMessage, sf.Detail.SystemReason); } catch (FaultException<DatabaseFault> dbf) { Console.WriteLine("DatabaseFault {0}: {1}\n{2}", dbf.Detail.DbOperation, dbf.Detail.DbMessage, dbf.Detail.DbReason); } catch (FaultException e) { Console.WriteLine("{0}: {1}", e.Code.Name, e.Reason); } catch (Exception e) { Console.WriteLine("General exception: {0}", e.Message); Console.WriteLine("Inner Exception: {0}", e.InnerException); } //Console.WriteLine("Press ENTER to continue"); //Console.ReadLine(); }
public static ProductCategory UpdateCategory(CategoryData category) { ProductCategory result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.UpdateCategory(new ProductCategory() { Name = category.Name, IsActive = category.IsActive, ProductCategoryID = category.ProductCategoryID }); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return result; }
public static void RunTest() { PermissiveCertificatePolicy.Enact("CN=HTTPS-Server"); Console.Write("Initializing Proxy for Category Tests..."); BicycleWorldServiceClient proxy = new BicycleWorldServiceClient("DefaultBinding_BicycleWorldService_BicycleWorldService"); Console.WriteLine(" done"); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; try { Console.WriteLine(proxy.Test()); Console.WriteLine("Test 1: List all categories"); var categories = proxy.CategoriesList(); foreach (var category in categories) { Console.WriteLine(" Category ID: {0:000}, Name: {1}", category.ProductCategoryID, category.Name); } Console.WriteLine("Test 2: Removing all 'TEST' categories"); foreach (var category in categories.Where(c => c.Name == "TEST")) { Console.Write(" Removing ProductCategoryID {0:000}... ", category.ProductCategoryID); if (proxy.RemoveCategory(category.ProductCategoryID)) Console.WriteLine("Removed."); else Console.WriteLine("Not removed."); } Console.WriteLine("Test 3: Add 'TEST' category"); int productCategoryID = proxy.AddCategory(new ProductCategory() { Name = "TEST", }); Console.WriteLine(" New category added. ProductCategoryID: {0}", productCategoryID); Console.WriteLine(" Test 4: Update 'TEST' category"); ProductCategory categoryToUpdate = proxy.GetCategory(productCategoryID); Console.WriteLine(" Name was: {0}", categoryToUpdate.Name); categoryToUpdate.Name = "test"; categoryToUpdate = proxy.UpdateCategory(categoryToUpdate); categoryToUpdate = proxy.GetCategory(productCategoryID); Console.WriteLine(" Name is now: {0}", categoryToUpdate.Name); Console.WriteLine("Test 4: Remove 'TEST' category"); bool removalSuccessful = proxy.RemoveCategory(productCategoryID); Console.WriteLine(" Removal Successful: {0}", removalSuccessful); Console.WriteLine(); // Disconnect from the service proxy.Close(); } catch (FaultException<SystemFault> sf) { Console.WriteLine("SystemFault {0}: {1}\n{2}", sf.Detail.SystemOperation, sf.Detail.SystemMessage, sf.Detail.SystemReason); } catch (FaultException<DatabaseFault> dbf) { Console.WriteLine("DatabaseFault {0}: {1}\n{2}", dbf.Detail.DbOperation, dbf.Detail.DbMessage, dbf.Detail.DbReason); } catch (FaultException e) { Console.WriteLine("{0}: {1}", e.Code.Name, e.Reason); } catch (Exception e) { Console.WriteLine("General exception: {0}", e.Message); Console.WriteLine("Inner Exception: {0}", e.InnerException); } //Console.WriteLine("Press ENTER to continue"); //Console.ReadLine(); }
public static Product UpdateProduct(ProductData product) { Product result = null; BicycleWorldServiceClient client = new BicycleWorldServiceClient(); try { client.ClientCredentials.UserName.UserName = LoginUser.Current.Username; client.ClientCredentials.UserName.Password = LoginUser.Current.Password; result = client.UpdateProduct(new Product() { ProductID = product.ProductID, Name = product.Name, ProductNumber = product.ProductNumber, Color = product.Color, ListPrice = product.ListPrice, ProductDescription = product.ProductDescription, Quantity = product.Quantity, ProductCategoryID = product.CategoryID, IsActive = product.IsActive }); client.Close(); } catch (FaultException) { client.Abort(); } catch (CommunicationException) { client.Abort(); } catch (TimeoutException) { client.Abort(); } catch { throw; } return result; }
public static void RunTest() { // Create a proxy object and connect to the service PermissiveCertificatePolicy.Enact("CN=HTTPS-Server"); Console.Write("Initializing Product Proxy..."); BicycleWorldServiceClient proxy = new BicycleWorldServiceClient("DefaultBinding_BicycleWorldService_BicycleWorldService"); Console.WriteLine(" done"); proxy.ClientCredentials.UserName.UserName = "******"; proxy.ClientCredentials.UserName.Password = "******"; // Test the operations in the service try { Console.WriteLine(proxy.Test()); // Obtain a list of all products Console.WriteLine("Test 1: List all products"); var products = proxy.ProductList(); foreach (var product in products) { Console.WriteLine(" Product ID: {0:000}, ProductNumber: {1}", product.ProductID, product.ProductNumber); } Console.WriteLine("Test 2: Removing all 'TEST' products"); foreach (var product in products.Where(p => p.ProductNumber == "TEST")) { Console.Write(" Removing productID {0:000}... ", product.ProductID); if (proxy.RemoveProduct(product.ProductID)) { Console.WriteLine("Removed."); } else { Console.WriteLine("Not removed."); } } Console.WriteLine("Test 3: Add 'TEST' product"); int productID = proxy.AddProduct(new Product() { Name = "Test", Color = "RED", ListPrice = (decimal)3.99, ProductCategoryID = 1, ProductDescription = "Test Mountain bike", ProductNumber = "TEST", Quantity = 5, }); Console.WriteLine(" New producted added. ProductID: {0}", productID); Console.WriteLine(" Test 4: Update 'TEST' product"); Product productToUpdate = proxy.GetProduct(productID); Console.WriteLine(" Price was: {0}", productToUpdate.ListPrice); productToUpdate.ListPrice = (decimal)7.99; productToUpdate = proxy.UpdateProduct(productToUpdate); productToUpdate = proxy.GetProduct(productID); Console.WriteLine(" Price is now: {0}", productToUpdate.ListPrice); Console.WriteLine("Test 4: Remove 'TEST' product"); bool removalSuccessful = proxy.RemoveProduct(productID); Console.WriteLine(" Removal Successful: {0}", removalSuccessful); Console.WriteLine(); // Disconnect from the service proxy.Close(); } catch (FaultException <SystemFault> sf) { Console.WriteLine("SystemFault {0}: {1}\n{2}", sf.Detail.SystemOperation, sf.Detail.SystemMessage, sf.Detail.SystemReason); } catch (FaultException <DatabaseFault> dbf) { Console.WriteLine("DatabaseFault {0}: {1}\n{2}", dbf.Detail.DbOperation, dbf.Detail.DbMessage, dbf.Detail.DbReason); } catch (FaultException e) { Console.WriteLine("{0}: {1}", e.Code.Name, e.Reason); } catch (Exception e) { Console.WriteLine("General exception: {0}", e.Message); Console.WriteLine("Inner Exception: {0}", e.InnerException); } //Console.WriteLine("Press ENTER to continue"); //Console.ReadLine(); }