static void ActnVendor() { //Returns all VendorsController VendorCtrl = new VendorsController(@"STUDENT50\SQLEXPRESS", "prssql"); IEnumerable <Vendor> vendor = VendorCtrl.List(); foreach (Vendor Vendor1 in vendor) { Console.WriteLine($"{Vendor1.Code} {Vendor1.Name} {Vendor1.Address}"); } Vendor Amzn = VendorCtrl.Get(1); if (Amzn == null) { Console.WriteLine("Vendor not found"); } else { Console.WriteLine($"{Amzn.Code} {Amzn.Name} {Amzn.Address}"); } Amzn = VendorCtrl.Get(999); if (Amzn == null) { Console.WriteLine("User not found"); } else { Console.WriteLine($"{Amzn.Code} {Amzn.Name} {Amzn.Address}"); } Vendor newVendor = new Vendor() { Code = "Walm", Address = "564 Walmart way", Name = "Walmart", City = "Walmartville", State = "GA", Zip = "98123", Email = "*****@*****.**", Phone = "987-456-1203", Active = true, IsPreapproved = true }; //bool success = VendorCtrl.Create(newVendor); Vendor vendorWal = VendorCtrl.Get(5); vendorWal.Code = "WAL"; //bool success = VendorCtrl.Change(vendorWal); bool success = VendorCtrl.Remove(vendorWal); VendorCtrl.CloseConnection(); }
static void Main(string[] args) { UsersController UserCtrl = new SqlLibrary.UsersController(@"STUDENT12\SQLEXPRESS", "PRSDatabase"); // IEnumerable<User> users = UserCtrl.List(); // foreach (User user1 in users) { // Console.WriteLine($"{user1.FirstName} {user1.LastName}"); //} //User user = UserCtrl.Get(5); //if(user == null) { // Console.WriteLine("User not found"); //} else { // Console.WriteLine($"{user.FirstName} {user.LastName}"); //} //user = UserCtrl.Get(999); //if (user == null) { // Console.WriteLine("User not found"); //} else { // Console.WriteLine($"{user.FirstName} {user.LastName}"); //} //User newUser = new User(); //newUser.Username = "******"; ; //newUser.Password = "******"; //newUser.FirstName = "Last"; //newUser.LastName = "first"; //newUser.Phone = "513-555-0000"; //newUser.Email = "newuser@gmail"; //newUser.IsReviewer = true; //newUser.IsAdmin = true; //newUser.Active = true; //bool success = UserCtrl.Create(newUser); //User user = UserCtrl.Get(5); //user.FirstName = "Harvy"; //bool success = UserCtrl.Change(user); //user = UserCtrl.Get(10); //success = UserCtrl.Remove(user); //UserCtrl.CloseConection(); VendorsController vendorctrl = new VendorsController(@"STUDENT12\SQLEXPRESS", "PRSDatabase"); IEnumerable <Vendor> Vendors = vendorctrl.List(); foreach (Vendor vendors in Vendors) { Console.WriteLine($"{vendors.Code} {vendors.Name}"); } //Vendor newVendor = new Vendor(); //newVendor.Code = "EGG"; //Must be a unique value //newVendor.Name = "New Egg"; //newVendor.Address = "123 Main Street"; //newVendor.City = "Cincinnati"; //newVendor.State = "OH"; //newVendor.Zip = "45002"; //newVendor.Phone = "nani"; //newVendor.Email = "nano"; //newVendor.IsPreApproved = true; //bool success = vendorctrl.Create(newVendor); //Console.WriteLine($"New vendor successfully added = {success}"); //Vendor vendor = vendorctrl.Get(2); //vendor.Code = "TAR"; //success = vendorctrl.Change(vendor); Vendor vendordlt = vendorctrl.Get(12); bool deleted = vendorctrl.Remove(vendordlt); Console.WriteLine($"Vendor Successfully removed = {deleted}"); }
static void Main(string[] args) { VendorsController VendorCtrl = new VendorsController(@"dsi-workstation\SQLEXPRESS", "prssql"); IEnumerable <Vendor> vendors = VendorCtrl.List(); Vendor v1 = VendorCtrl.Get(1); int AmazonId = v1.Id; v1.Name = "Amazon, Inc."; VendorCtrl.Change(v1); v1.Id = 0; v1.Name = "Walmart"; v1.Code = "WALM"; VendorCtrl.Create(v1); v1.Id = 3; VendorCtrl.Remove(v1); VendorCtrl.CloseConnection(); /* * UsersController UserCtrl = new UsersController(@"dsi-workstation\SQLEXPRESS", "prssql"); * * IEnumerable<User> users = UserCtrl.List(); * foreach(User user1 in users) { * Console.WriteLine($"{user1.Firstname} {user1.Lastname}"); * } * * User user = UserCtrl.Get(6); * if(user == null) { * Console.WriteLine("User not found"); * } else { * Console.WriteLine($"{user.Firstname} {user.Lastname}"); * } * * user = UserCtrl.Get(999); * if (user == null) { * Console.WriteLine("User not found"); * } else { * Console.WriteLine($"{user.Firstname} {user.Lastname}"); * } * * User newUser = new User(); * newUser.Username = "******"; * newUser.Password = "******"; * newUser.Firstname = "New"; * newUser.Lastname = "User"; * newUser.Phone = "513-555-1212"; * newUser.Email = "*****@*****.**"; * newUser.IsReviewer = false; * newUser.IsAdmin = true; * * //bool success = UserCtrl.Create(newUser); * * user = UserCtrl.Get(6); * user.Firstname = "Kimmie"; * //bool success = UserCtrl.Change(user); * * user = UserCtrl.Get(19); * if(user != null) * UserCtrl.Remove(user); * * UserCtrl.CloseConnection(); * */ }