Esempio n. 1
0
        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();
        }
Esempio n. 2
0
        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();
 *
 */
        }