public void SetUp() { DbCommerce.GetInstance().StartTests(); LinkedList <string> policy = new LinkedList <string>(); system = Workshop192.MarketManagment.System.GetInstance(); AllRegisteredUsers.GetInstance().CreateUser(); user = AllRegisteredUsers.GetInstance().GetUser(1); system.OpenStore("store1"); system.OpenStore("store2"); store1 = system.GetStore("store1"); store2 = system.GetStore("store2"); product1 = new Product(1, "", "", 10); product2 = new Product(2, "", "", 20); product3 = new Product(3, "", "", 30); product4 = new Product(4, "", "", 40); store1.AddProducts(product1, 10); store1.AddProducts(product2, 10); store2.AddProducts(product3, 10); store2.AddProducts(product4, 10); policy.AddLast("Ban"); policy.AddLast("AND"); policy.AddLast("1"); policy.AddLast("user"); product1.AddDiscountPolicy(policy, 50); policy = new LinkedList <string>(); policy.AddLast("Min"); policy.AddLast("AND"); policy.AddLast("1"); policy.AddLast("0"); policy.AddLast("5"); product1.AddSellingPolicy(policy); policy = new LinkedList <string>(); policy.AddLast("Min"); policy.AddLast("AND"); policy.AddLast("0"); policy.AddLast("0"); policy.AddLast("5"); store1.AddSellingPolicy(policy); policy = new LinkedList <string>(); policy.AddLast("Max"); policy.AddLast("AND"); policy.AddLast("0"); policy.AddLast("0"); policy.AddLast("50"); store1.AddSellingPolicy(policy); }
public bool RemoveAppointedManager(UserInfo child) { foreach (StoreManager manager in appointedManagers) { if (manager.GetUser().Equals(child)) { Logger.GetInstance().WriteToEventLog(user.GetUserName() + " removed appointed manager " + child.GetUserName() + " of store [" + store + "]"); manager.RemoveSelf(); DbCommerce.GetInstance().SaveDb(); try//push notifications { string message = child.GetUserName() + " is removed from being a manager in store:" + store; for (int i = 0; i < storeOwners.GetStoreOwners().Count; i++) { Notifications.Notification.GetInstance().SendMessageToUser(storeOwners.GetStoreOwners().ElementAt(i).GetUser().GetUserName(), message); } Notifications.Notification.GetInstance().SendMessageToUser(child.GetUserName(), "you removed from being manager in store:" + store); } catch (Exception) { } return(true); } } Logger.GetInstance().WriteToEventLog(user.GetUserName() + " tried removing user " + child.GetUserName() + " from the store managers but the given user wasn't a manager of store [" + store + "]"); throw new ErrorMessageException("The given user is not a store manager this user appointed"); }
public bool AddManager(UserInfo user, bool[] privileges) { if (CheckUserExists(user)) { Logger.GetInstance().WriteToErrorLog(this.user.GetUserName() + " tried adding user " + user.GetUserName() + " as a manager but the given user is already a owner/manager of store [" + store + "]"); throw new ErrorMessageException("The given user is already a store owner/manager in the store"); } Logger.GetInstance().WriteToEventLog(this.user.GetUserName() + " added user " + user.GetUserName() + " as a manager in store [" + store + "] with the following privileges " + privileges.ToString()); StoreManager manager = new StoreManager(user, store, privileges, this); user.GetStoreManagers().AddLast(manager); appointedManagers.AddLast(manager); DbCommerce.GetInstance().SaveDb(); try {//push notifications string message = user.GetUserName() + " is added to be manager in store:" + store; for (int i = 0; i < storeOwners.GetStoreOwners().Count; i++) { Notifications.Notification.GetInstance().SendMessageToUser(storeOwners.GetStoreOwners().ElementAt(i).GetUser().GetUserName(), message); } Notifications.Notification.GetInstance().SendMessageToUser(user.GetUserName(), "you assigned to be manager in store:" + store); } catch (Exception) { } return(true); }
public bool RemoveSellingPolicy(int productId) { if (productId == 0) { if (MarketManagment.System.GetInstance().GetStore(store).RemoveSellingPolicy()) { DbCommerce.GetInstance().SaveDb(); return(true); } } else { foreach (ProductAmountInventory productAmount in MarketManagment.System.GetInstance().GetStore(store).GetInventory()) { if (productAmount.productId.Equals(productId)) { if (productAmount.product.RemoveSellingPolicy()) { DbCommerce.GetInstance().SaveDb(); return(true); } return(false); } } } throw new ErrorMessageException("Given product id doesn't exist in store"); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); InitializationOfTheSystem System = new InitializationOfTheSystem(); System.Initalize(null); UserId_Orel = CreateAndGetUser.CreateUser(); UserId_Nati = CreateAndGetUser.CreateUser(); UserId_Saar = CreateAndGetUser.CreateUser(); Register.Registration("orel", "123456", UserId_Orel); LogIn.Login("orel", "123456", UserId_Orel); OpenStore.openStore("victory", UserId_Orel); OpenStore.openStore("Mega", UserId_Orel); ManageProducts.ManageProduct(UserId_Orel, -1, "white bread", "bread", 10, 50, "victory", "add"); ManageProducts.ManageProduct(UserId_Orel, -1, "black bread", "bread", 15, 50, "victory", "add"); ManageProducts.ManageProduct(UserId_Orel, -1, "chocolate", "chocolate", 11, 50, "victory", "add"); ManageProducts.ManageProduct(UserId_Orel, -1, "milki", "dairy products", 12, 50, "Mega", "add"); ManageProducts.ManageProduct(UserId_Orel, -1, "humus", "humus", 15, 50, "Mega", "add"); ManageProducts.ManageProduct(UserId_Orel, -1, "water", "water", 7, 50, "Mega", "add"); SaveProductToCart.SaveProduct(1, UserId_Orel, 10); SaveProductToCart.SaveProduct(2, UserId_Orel, 10); SaveProductToCart.SaveProduct(4, UserId_Orel, 10); SaveProductToCart.SaveProduct(5, UserId_Orel, 10); SaveProductToCart.SaveProduct(3, UserId_Nati, 10); SaveProductToCart.SaveProduct(6, UserId_Nati, 10); }
public bool RemoveSellingPolicy(int productId) { if (!p6) { Logger.GetInstance().WriteToErrorLog(user.GetUserName() + " Tried removing selling policy of store [" + store + "] without privileges"); throw new ErrorMessageException("This manager dosent have the privilege to preform the given action"); } if (productId == 0) { MarketManagment.System.GetInstance().GetStore(store).RemoveSellingPolicy(); DbCommerce.GetInstance().SaveDb(); return(true); } else { foreach (ProductAmountInventory productAmount in MarketManagment.System.GetInstance().GetStore(store).GetInventory()) { if (productAmount.productId.Equals(productId)) { productAmount.product.RemoveSellingPolicy(); DbCommerce.GetInstance().SaveDb(); return(true); } } } throw new ErrorMessageException("Given product id doesnt exist in store"); }
public bool AddSellingPolicy(LinkedList <string> policy) { if (!p4) { Logger.GetInstance().WriteToErrorLog(user.GetUserName() + " Tried adding selling policy to store [" + store + "] without privileges"); throw new ErrorMessageException("This manager dosent have the privilege to preform the given action"); } if (Int32.Parse(policy.ElementAt(2)) == 0) { MarketManagment.System.GetInstance().GetStore(store).AddSellingPolicy(policy); DbCommerce.GetInstance().SaveDb(); return(true); } else { foreach (ProductAmountInventory productAmount in MarketManagment.System.GetInstance().GetStore(store).GetInventory()) { if (productAmount.productId.Equals(Int32.Parse(policy.ElementAt(2)))) { productAmount.product.AddSellingPolicy(policy); DbCommerce.GetInstance().SaveDb(); return(true); } } } throw new ErrorMessageException("Given product id doesnt exist in store"); }
public bool AddOwner(UserInfo user) { if (CheckUserExists(user)) { Logger.GetInstance().WriteToErrorLog(this.user.GetUserName() + " tried adding user " + user.GetUserName() + " as a owner but the given user is already a owner/manager of store [" + store + "]"); throw new ErrorMessageException("The given user is already a store owner/manager in the store"); } foreach (StoreOwner owner in storeOwners.GetStoreOwners()) { if (owner.GetUser().Equals(user) || owner.GetPendingUsers().Contains(user)) { Logger.GetInstance().WriteToErrorLog(this.user.GetUserName() + " tried adding user " + user.GetUserName() + " as a owner but the given user is already a apending owner of store [" + store + "]"); throw new ErrorMessageException("The given user is already a pending owner"); } } Logger.GetInstance().WriteToEventLog(this.user.GetUserName() + " initiated the owner adding proccess to user " + user.GetUserName() + " for store [" + store + "]"); foreach (StoreOwner owner in storeOwners.GetStoreOwners()) { owner.pendingUsers += "$" + user.GetUserName(); } pendingUsers = pendingUsers.Replace(user.GetUserName(), ""); if (storeOwners.GetStoreOwners().Count == 1) { AddOwnerFinal(user); } else//push notifications to store owners for accept the appointment { foreach (StoreOwner owner in storeOwners.GetStoreOwners()) { Notifications.Notification.GetInstance().SendMessageToUser(owner.GetUser().GetUserName(), user.GetUserName() + " is waiting for you to accept his appointment to be store owner in store:" + store); } } DbCommerce.GetInstance().SaveDb(); return(true); }
public void OpenStore(string storeName) { Store store = new Store(storeName); stores.AddLast(store); DbCommerce.GetInstance().AddStore(store); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); Workshop192.UserManagment.AllRegisteredUsers.GetInstance().CreateUser(); Workshop192.UserManagment.AllRegisteredUsers.GetInstance().RegisterUser("user", "123456"); cart = new Cart(new Store("store"), new MultiCart(1)); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); Workshop192.MarketManagment.System.GetInstance().OpenStore("newStore"); product = new Product(1, "air", "element", 5); Workshop192.MarketManagment.System.GetInstance().GetStore("newStore").AddProducts(product, 4); cart = new Cart(Workshop192.MarketManagment.System.GetInstance().GetStore("newStore"), new MultiCart(1)); }
public void TearDown() { DbCommerce.GetInstance().EndTests(); white_bread = new LinkedList <string>(); black_bread = new LinkedList <string>(); cutted_bread = new LinkedList <string>(); l1 = new LinkedList <LinkedList <string> >(); SystemReset.Reset(); }
public void Init() { userId = AllRegisteredUsers.GetInstance().CreateUser(); DbCommerce.GetInstance().StartTests(); AllRegisteredUsers.GetInstance().CreateUser(); user = AllRegisteredUsers.GetInstance().GetUser(1); AllRegisteredUsers.GetInstance().RegisterUser("user", "123456"); info = AllRegisteredUsers.GetInstance().GetUserInfo("user"); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); InitializationOfTheSystem System = new InitializationOfTheSystem(); System.Initalize(null); UserId_Nati = CreateAndGetUser.CreateUser(); UserId_Orel = CreateAndGetUser.CreateUser(); }
public bool AddProducts(Product product, int amount) { if (MarketManagment.System.GetInstance().GetStore(store).AddProducts(product, amount)) { Logger.GetInstance().WriteToEventLog(user.GetUserName() + " Added Product [" + product.GetId() + "] [" + product.GetName() + "] [" + product.GetCategory() + "] [" + product.GetPrice() + "] [" + amount + "] as a owner of store [" + store + "]"); DbCommerce.GetInstance().SaveDb(); return(true); } return(false); }
public bool SetAdmin() { if (IsAdmin()) { throw new ErrorMessageException("This user is already admin"); } admin = new Admin(this); DbCommerce.GetInstance().SaveDb(); return(true); }
public bool EditProduct(int productId, string name, string category, int price, int amount) { if (MarketManagment.System.GetInstance().GetStore(store).EditProduct(productId, name, category, price, amount)) { Logger.GetInstance().WriteToEventLog(user.GetUserName() + " edited product [" + productId + "] to: [" + name + "] [" + category + "] [" + price + "] [" + amount + "] as owner of store [" + store + "]"); DbCommerce.GetInstance().SaveDb(); return(true); } return(false); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); AllRegisteredUsers.GetInstance().RegisterUser("User1", "123456"); AllRegisteredUsers.GetInstance().RegisterUser("User2", "123456"); AllRegisteredUsers.GetInstance().RegisterUser("User3", "123456"); AllRegisteredUsers.GetInstance().GetUserInfo("User1").OpenStore("Store"); AllRegisteredUsers.GetInstance().GetUserInfo("User1").AddStoreManager("Store", AllRegisteredUsers.GetInstance().GetUserInfo("User2"), new bool [] { false, false, false, false, false, false, false }); AllRegisteredUsers.GetInstance().GetUserInfo("User1").AddStoreManager("Store", AllRegisteredUsers.GetInstance().GetUserInfo("User3"), new bool[] { true, true, true, true, true, true, true }); }
public bool RemoveProductFromInventory(int productId) { if (MarketManagment.System.GetInstance().GetStore(store).RemoveProductFromInventory(productId)) { Logger.GetInstance().WriteToEventLog(user.GetUserName() + " removed Product [" + productId + "] as a owner of store [" + store + "]"); DbCommerce.GetInstance().SaveDb(); return(true); } return(false); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); Store store = new Store("Temp Store"); cart = new Cart(store, new MultiCart(1)); Workshop192.UserManagment.AllRegisteredUsers.GetInstance().CreateUser(); truePolicy = new PolicyLeafBannedUser("user"); falsePolicy = new PolicyLeafBannedUser(""); }
public void AddNewMultiCartToDb(int multiCartId) { foreach (MultiCart multiCart in multiCarts) { if (multiCart.multiCartId == multiCartId) { DbCommerce.GetInstance().AddMultiCart(multiCart); return; } } }
public void SetUp() { DbCommerce.GetInstance().StartTests(); InitializationOfTheSystem System = new InitializationOfTheSystem(); System.Initalize(null); UserId_Nati = CreateAndGetUser.CreateUser(); UserId_Orel = CreateAndGetUser.CreateUser(); //int userIDnati = Allusers.CreateUser(); Register.Registration("orel", "123456", UserId_Orel); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); InitializationOfTheSystem System = new InitializationOfTheSystem(); System.Initalize(null); UserId_Nati = CreateAndGetUser.CreateUser(); UserId_Orel = CreateAndGetUser.CreateUser(); Register.Registration("orel", "111111", UserId_Orel); LogIn.Login("orel", "111111", UserId_Orel); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); Workshop192.UserManagment.AllRegisteredUsers.GetInstance().CreateUser(); Workshop192.MarketManagment.System.GetInstance().OpenStore("temp"); store = Workshop192.MarketManagment.System.GetInstance().GetStore("temp"); cart = new Cart(store, new MultiCart(1)); product = new Product(1, "cake", "food", 10); store.AddProducts(product, 10); cart.AddProductsToCart(1, 10); }
public void ResetMultiCart() { while (carts.Count > 0 && !DbCommerce.GetInstance().forTests) { DbCommerce.GetInstance().RemoveCart(carts.First.Value); } //foreach (Cart cart in carts) // DbCommerce.GetInstance().RemoveCart(cart); carts = new LinkedList <Cart>(); DbCommerce.GetInstance().SaveDb(); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); Workshop192.MarketManagment.System.GetInstance().OpenStore("store1"); Workshop192.MarketManagment.System.GetInstance().OpenStore("store2"); store1 = Workshop192.MarketManagment.System.GetInstance().GetStore("store1"); store2 = Workshop192.MarketManagment.System.GetInstance().GetStore("store2"); multiCart = new MultiCart(1); store1.AddProducts(new Product(1, "can", "tin", 5), 5); store1.AddProducts(new Product(2, "floor", "wood", 10), 10); store2.AddProducts(new Product(3, "nike", "shoes", 25), 5); }
private AllRegisteredUsers() { passwords = new Dictionary <string, string>(); userInfos = new Dictionary <string, UserInfo>(); userId = 0; users = new Dictionary <int, User>(); foreach (UserInfo info in DbCommerce.GetInstance().GetUserInfos()) { passwords[info.userName] = info.password; userInfos[info.userName] = info; } }
public void SetUp() { DbCommerce.GetInstance().StartTests(); Workshop192.UserManagment.AllRegisteredUsers.GetInstance().CreateUser(); Workshop192.MarketManagment.System.GetInstance().OpenStore("store"); store = Workshop192.MarketManagment.System.GetInstance().GetStore("store"); cart = new Cart(store, new MultiCart(1)); product1 = new Product(1, "toaster", "cooking supplies", 15); product2 = new Product(2, "grenade", "weapon", 5); store.AddProducts(product1, 10); cart.AddProductsToCart(1, 10); }
public void SetUp() { DbCommerce.GetInstance().StartTests(); InitializationOfTheSystem System = new InitializationOfTheSystem(); System.Initalize(null); UserId_Orel = CreateAndGetUser.CreateUser(); UserId_Nati = CreateAndGetUser.CreateUser(); Register.Registration("orel", "123456", UserId_Orel); LogIn.Login("orel", "123456", UserId_Orel); OpenStore.openStore("victory", UserId_Orel); ManageProducts.ManageProduct(UserId_Orel, -1, "black bread", "bread", 10, 50, "victory", "add"); ManageProducts.ManageProduct(UserId_Orel, -1, "white bread", "bread", 15, 50, "victory", "add"); }
public bool OpenStore(string storeName) { if (storeName.Equals("") || MarketManagment.System.GetInstance().GetStore(storeName) != null) { throw new ErrorMessageException("A store with the given name already exists"); } MarketManagment.System.GetInstance().OpenStore(storeName); storeOwners.AddLast(new StoreOwner(this, storeName, null)); for (int i = 0; i < AllRegisteredUsers.GetInstance().GetAllUserNames().Count; i++) { Notifications.Notification.GetInstance().SendMessageToUser(AllRegisteredUsers.GetInstance().GetAllUserNames().ElementAt(i), "The shop " + storeName + " was opened now!"); } DbCommerce.GetInstance().SaveDb(); return(true); }