public string removeRole(string username, int storeId) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().removeRole(storeId, username, session); //WebSocketController.messageClient(username, "you have no longer a role in store " + storeId); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Remove Role Error: " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Remove Role; Stack Trace: " + e.StackTrace); throw e; } }
public Object setDiscountPercentage(int discountID, int percentage) { try { double p = percentage / 100.0; int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().setDiscountPercentage(discountID, p); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("discount percentage :" + e.Message.ToString()); return(e.Message); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Set Discount Percentage; Stack Trace: " + e.StackTrace); throw e; } }
public string addVisibleDiscount(int productID, string percentage, string duration) { try { double per = Double.Parse(percentage); int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().addProductVisibleDiscount(productID, session, per, duration); return(""); } catch (ClientException e) { SystemLogger.getEventLog().Error("Error in adding a visible discount : " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getEventLog().Error("An Error has occured. Stack Trace: " + e.StackTrace + " Function: addDiscount"); throw e; } }
public string searchByKey(string param) { if (param == null) { param = ""; } try { string list = UserService.getInstance().searchByKeyword(param); return(list); } catch (ClientException e) { SystemLogger.getEventLog().Error("Search error : " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getEventLog().Error("An Error has occured. Stack Trace: " + e.StackTrace + " Function: Search , Params: " + param); throw e; } }
public string addStore(string name, string description) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().addStore(name, description, session); return("ok"); } catch (ILLArgumentException e) { return("cant open store with no name"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Error in adding a store : " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: getStore; Stack Trace: " + e.StackTrace); throw e; } }
public string addToBasket(int productID, string amount) { try { int am = Int32.Parse(amount); int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); UserService.getInstance().addToShoppingBasket(productID, am, session); return("ok"); } catch (FormatException) { return("please enter a valid Number"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Error in adding to shopping cart : " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getEventLog().Error("An Error has occured. Stack Trace: " + e.StackTrace + " Function: addToBasket"); throw e; } }
public string StorePolicies(int storeID) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); return(StoreService.getInstance().getStorePolicies(storeID, session)); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Get Store Policies; Stack Trace: " + e.StackTrace); throw e; } }
public string getShoppingBasket() { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); return(UserService.getInstance().getShoppingBasket(session)); } catch (ClientException e) { SystemLogger.getEventLog().Error("getShoppingBasket : " + e.Message.ToString()); return(e.Message); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: getShoppingBasket; Stack Trace: " + e.StackTrace); throw e; } }
public string removeUser(String username) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); UserService.getInstance().removeUser(session, username); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("removeUser : "******"An Error has occured. Function: removeUser; Stack Trace: " + e.StackTrace); throw e; } }
public Object login(String Username, String Password) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); UserService.getInstance().login(session, Username, Password); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Login : "******"An Error has occured. Function: login; Stack Trace: " + e.StackTrace); throw e; } }
public string addManager(string username, int storeId, bool prod, bool disc, bool poli) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().addManager(storeId, username, prod, disc, poli, session); return("ok"); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (ClientException e) { SystemLogger.getEventLog().Error("Add Manager : " + e.Message.ToString()); return(e.Message.ToString()); } }
public string Checkout(string address, string creditcard, string month, string year, string holder, string cvv) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); UserService.getInstance().purchaseBasket(session, address, creditcard, month, year, holder, cvv); return("OK"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Checkout : " + e.Message.ToString()); return(e.Message.ToString()); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Checkout; Stack Trace: " + e.StackTrace); throw e; } }
public string setProductQuantity(int product, int quantity) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); BasketService.getInstance().changeQuantity(session, product, quantity); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("setQuantity : " + e.Message.ToString()); return(e.Message); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: setQuantity; Stack Trace: " + e.StackTrace); throw e; } }
public string removeProductFromCart(int productId) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); UserService.getInstance().removeFromShoppingBasket(session, productId); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Remove from Cart : " + e.Message.ToString()); return(e.Message.ToString()); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: removeFromCart; Stack Trace: " + e.StackTrace); throw e; } }
public string getAllRoles(int storeId) { try { return(StoreService.getInstance().getAllRoles(storeId)); } catch (ClientException e) { return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Get All Roles; Stack Trace: " + e.StackTrace); throw e; } }
public string getAllProducts() { try { string list = UserService.getInstance().getAllProducts(); return(list); } catch (ClientException e) { SystemLogger.getEventLog().Error("Catalog Error : " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getEventLog().Error("An Error has occured. Stack Trace: " + e.StackTrace + " Function: getAllProducts"); throw e; } }
public string addOwner(string username, int storeId) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().addOwner(storeId, username, session); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Error in adding an owner : " + e.Message.ToString()); return(e.Message.ToString()); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: addOwner; Stack Trace: " + e.StackTrace); throw e; } }
public string addProduct(string productName, string productCategory, int price, int rank, int quantityLeft, int storeID) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().addProduct(productName, productCategory, price, rank, quantityLeft, storeID, session); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Add Product Error : " + e.Message.ToString()); return(e.Message); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Add Product; Stack Trace: " + e.StackTrace); throw e; } }
public Object complexDiscount(string discounts, int storeID, string type, double percentage, string duration) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().complexDiscount(discounts, storeID, type, percentage, duration, session); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("complex discount :" + e.Message.ToString()); return(e.Message); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: complex discount; Stack Trace: " + e.StackTrace); throw e; } }
public Object AddTotalPolicy(int storeID, int totalVal) { try { int session = UserService.getInstance().getUserByHash(System.Web.HttpContext.Current.Request.Cookies["HashCode"].Value); StoreService.getInstance().addTotalPolicy(storeID, totalVal, session); return("ok"); } catch (ClientException e) { SystemLogger.getEventLog().Error("Add to total policy:" + e.Message.ToString()); return(e.Message); } catch (ConnectionException e) { SystemLogger.getEventLog().Error("Database Error : " + e.Message.ToString()); return("There has been a problem with the connection to the database. Please try again."); } catch (Exception e) { SystemLogger.getErrorLog().Error("An Error has occured. Function: Add Total Policy; Stack Trace: " + e.StackTrace); throw e; } }