public ViewUsersSlave(User user, IUserDL userDB) { Answer = null; _user = user; _userDB = userDB; userID = user?.SystemID ?? -1; }
public User SignIn(string name, string password) { try { MarketLog.Log("UserSpot", "User " + guestID + " attempting to sign in the system..."); ApproveSignIn(name, password); string encryptedPassword = UserSecurityService.ToEncryptPassword(_guest.SystemID, password); MarketLog.Log("UserSpot", "Searching for existing user and logging in Guest " + guestID + " into the system..."); object[] userData = ValidateUserExist(name, encryptedPassword); User loggedUser = _userDB.LoadUser(userData, _guest.Cart.GetCartStorage()); MarketLog.Log("UserSpot", "User " + loggedUser.SystemID + " sign in to the system has been successfull!"); MarketLog.Log("UserSpot", "User " + loggedUser.SystemID + " is now recognized as Registered User " + loggedUser.SystemID); string returnedState = loggedUser.IsSystemAdmin() ? "Admin" : "Registered"; Answer = new UserAnswer(SignInStatus.Success, "Sign in has been successful!", loggedUser.SystemID, returnedState); return(loggedUser); } catch (UserException e) { MarketLog.Log("UserSpot", "User " + guestID + " has failed to sign in. Error message has been created!"); Answer = new UserAnswer((SignInStatus)e.Status, e.GetErrorMessage()); return(_guest); } catch (DataException e) { Answer = new UserAnswer((SignInStatus)e.Status, e.GetErrorMessage()); return(_guest); } }
public GetControlledStoreNamesSlave(User user, IUserDL userDB) { Answer = null; _user = user; _userDB = userDB; userID = user?.SystemID ?? -1; }
public void RemoveFromCart(string product, string store, double unitPrice) { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to remove his cart item: " + product + " from store: " + store + " ..."); CartItem toRemove = ApproveModifyCart(store, product, unitPrice); MarketLog.Log("UserSpot", "User " + userID + " found cart item: " + product + " from store: " + store + ". proceeding for the removal..."); _user.Cart.RemoveFromCart(toRemove); MarketLog.Log("UserSpot", "User " + userID + "successfully removed cart item: " + product + " from store: " + store + " ..."); Answer = new UserAnswer(RemoveFromCartStatus.Success, "Remove Cart Item has been successful!"); } catch (UserException e) { Answer = new UserAnswer((RemoveFromCartStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new UserAnswer((RemoveFromCartStatus)e.Status, e.GetErrorMessage()); } }
public void GetStoreManagerPolicies(string store) { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to view this policies in the store " + store); ApproveEnetered(); MarketLog.Log("UserSpot", "User " + userID + " has successfully viewing his policies in this store..."); StoreManagerPolicy[] policies = _user.GetStoreManagerPolicies(store); string[] stringPolicies = { "Manage Products", "Promote Store Admins", "Manage Store Discounts", "View Purchase History", "View Promotion History", "Manage Store Purchase-Policy" }; if (!_user.IsSystemAdmin()) { stringPolicies = new string[policies.Length]; int count = 0; foreach (StoreManagerPolicy policy in policies) { stringPolicies[count] = StoreManagerPolicy.GetStoreActionName(policy.Action); count++; } } Answer = new UserAnswer(GetStoreManagerPoliciesStatus.Success, "View of store policies has been successfully granted!", stringPolicies); } catch (UserException e) { Answer = new UserAnswer((GetStoreManagerPoliciesStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new UserAnswer((GetStoreManagerPoliciesStatus)e.Status, e.GetErrorMessage()); } }
public SignInSlave(User guest, IUserDL userDB) { _userDB = userDB; Answer = null; _guest = guest; guestID = _guest?.SystemID ?? -1; }
public User SignUp(string name, string address, string password, string creditCard) { try { MarketLog.Log("UserSpot", "User " + currentID + " attempting to sign up to the system..."); ApproveSignUp(name, address, password, creditCard); string encryptedPassword = UserSecurityService.ToEncryptPassword(_guest.SystemID, password); MarketLog.Log("UserSpot", "Searching for existing user and storing newly Registered User " + currentID + " data..."); ValidateUserNotExist(name); RegisteredUser newRegistered = _userDB.RegisterUser(_guest.SystemID, name, address, encryptedPassword, creditCard, _guest.Cart.GetCartStorage()); MarketLog.Log("UserSpot", "User " + newRegistered.SystemID + " sign up to the system has been successfull!"); Answer = new UserAnswer(SignUpStatus.Success, "Sign up has been successfull!"); _publisher.AddFeedQueue(newRegistered.SystemID); return(newRegistered); } catch (UserException e) { Answer = new UserAnswer((SignUpStatus)e.Status, e.GetErrorMessage()); return(_guest); } catch (DataException e) { Answer = new UserAnswer((SignUpStatus)e.Status, e.GetErrorMessage()); return(_guest); } }
public SignUpSlave(User guest, IUserDL userDB, IPublisher publisher) { _userDB = userDB; Answer = null; _guest = guest; currentID = _guest?.SystemID ?? -1; _publisher = publisher; }
public void ViewStores() { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to view all store names..."); ApproveEnetered(); var storeNames = _userDB.GetAllActiveStoreNames(); Answer = new UserAnswer(ViewStoresStatus.Success, "you've got all the store names!", storeNames); } catch (UserException) { Answer = new UserAnswer(ViewStoresStatus.NoPermission, "The operation didn't succeed!"); } catch (DataException e) { Answer = new UserAnswer((GetControlledStoresStatus)e.Status, e.GetErrorMessage()); } }
public void GetControlledStoreNames() { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to view which store he can manage..."); ApproveEnetered(); MarketLog.Log("UserSpot", "User " + userID + " has successfully retrieved all store names..."); Answer = new UserAnswer(GetControlledStoresStatus.Success, "View of store names has been granted successfully!", FindControlledStoresOfUser()); } catch (UserException e) { Answer = new UserAnswer((GetControlledStoresStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new UserAnswer((GetControlledStoresStatus)e.Status, e.GetErrorMessage()); } }
public void ViewUsers() { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to view all users..."); ApproveEnetered(); MarketLog.Log("UserSpot", "User " + userID + " has successfully retrieved all users info..."); Answer = new UserAnswer(ViewUsersStatus.Success, "View of users has been granted successfully!", _userDB.UserNamesInSystem()); } catch (UserException e) { Answer = new UserAnswer((ViewUsersStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new UserAnswer((ViewUsersStatus)e.Status, e.GetErrorMessage()); } }
public void ViewCart() { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to view his cart..."); ApproveEnetered(); MarketLog.Log("UserSpot", "User " + userID + " has successfully retrieved his cart info..."); Answer = new UserAnswer(ViewCartStatus.Success, "View of the user's cart has been granted successfully!", _user.Cart.GetCartStorageToString()); } catch (UserException e) { Answer = new UserAnswer((ViewCartStatus)e.Status, e.GetErrorMessage(), null); } catch (DataException e) { Answer = new UserAnswer((ViewCartStatus)e.Status, e.GetErrorMessage(), null); } }
public void GetUserDetails() { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to view his own details..."); ApproveEnetered(); var userDetails = ExtractDetails(); MarketLog.Log("UserSpot", "User " + userID + " has successfully retrieved all his own user details..."); Answer = new UserAnswer(GetUserDetailsStatus.Success, "Data of user details has been granted successfully!", userDetails); } catch (UserException e) { Answer = new UserAnswer((GetUserDetailsStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new UserAnswer((GetUserDetailsStatus)e.Status, e.GetErrorMessage()); } }
public User EnterSystem() { try { MarketLog.Log("UserSpot", "New User attempting to enter the system..."); User newGuest = new User(_userDB, GenerateSystemID()); MarketLog.Log("UserSpot", "User " + newGuest.SystemID + " has entered the system! " + "attempting to save the user entry..."); _userDB.SaveUser(newGuest); MarketLog.Log("UserSpot", "User " + newGuest.SystemID + " has been saved successfully as new " + "guest entry in the system!"); Answer = new UserAnswer(EnterSystemStatus.Success, "You've been entered the system successfully!", newGuest.SystemID); _userDB.InsertSignedInUser(newGuest.SystemID); return(newGuest); } catch (DataException e) { Answer = new UserAnswer((EnterSystemStatus)e.Status, e.GetErrorMessage()); return(null); } }
public void EditCartItem(string store, string product, int quantity, double unitPrice) { try { MarketLog.Log("UserSpot", "User " + userID + " attempting to edit his cart item: " + product + " from store: " + store + " ..."); CartItem toEdit = ApproveModifyCart(store, product, unitPrice); MarketLog.Log("UserSpot", "User " + userID + " found cart item: " + product + " from store: " + store + ". proceeding for the edit..."); _user.Cart.EditCartItem(toEdit, quantity); MarketLog.Log("UserSpot", "User " + userID + "successfully edited cart item: " + product + " from store: " + store + " ..."); Answer = new UserAnswer(EditCartItemStatus.Success, "Edit Cart Item has been successful!"); } catch (UserException e) { Answer = new UserAnswer((EditCartItemStatus)e.Status, e.GetErrorMessage()); } catch (DataException e) { Answer = new UserAnswer((EditCartItemStatus)e.Status, e.GetErrorMessage()); } }
public EditCartItemSlave(User user) { Answer = null; _user = user; userID = user?.SystemID ?? -1; }
public GetStoreManagerPoliciesSlave(User user) { Answer = null; _user = user; userID = user?.SystemID ?? -1; }
public ViewCartSlave(User user) { Answer = null; _user = user; userID = user?.SystemID ?? -1; }
public EnterSystemSlave(IUserDL userDB) { _userDB = userDB; Answer = null; }
public RemoveFromCartSlave(User user) { Answer = null; _user = user; userID = user?.SystemID ?? -1; }
public GetUserDetailsSlave(User user) { Answer = null; _user = user; userID = user?.SystemID ?? -1; }