public static void addProductStore(string[] fullcommand) { if (fullcommand.Length == 8) { string username = fullcommand[1]; string storeName = fullcommand[2]; string productName = fullcommand[3]; string category = fullcommand[4]; string desc = fullcommand[5]; int price = int.Parse(fullcommand[6]); int amount = int.Parse(fullcommand[7]); try { User user = getUser(username, users[username]); Store store = getStore(storeName); int storeId = store.id; int productId = StoreService.AddProductToStore(user, storeId, productName, desc, price, category); StoreService.AddProductToStock(user, storeId, productId, amount); Logger.Log("event", logLevel.INFO, $"Init system: product {productName} add to store {storeName}"); } catch (Exception e) { Logger.Log("error", logLevel.ERROR, $"Init system: add Product to Store {e.Data}"); } } else { Logger.Log("error", logLevel.ERROR, "Init system: add Product to Store bad input"); } }
public bool AddProductToStock(int storeId, int productId, int amount) { if (!loggedIn) { notLoggedInException(); } return(StoreService.AddProductToStock(user, storeId, productId, amount)); }
public string AddProductToStock(int storeId, int productId, int amount) { if (!loggedIn) { return(notLoggedInError()); } bool ret; try { ret = StoreService.AddProductToStock(user, storeId, productId, amount); return(resultJson(ret)); } catch (Exception e) { return(generateMessageFormatJason(e.Message)); } }