コード例 #1
0
ファイル: InitSystem.cs プロジェクト: hadasat/Web-Store-
        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");
            }
        }
コード例 #2
0
ファイル: LoginProxy.cs プロジェクト: hadasat/Web-Store-
 public int AddProductToStore(int storeId, string name, string desc, double price, string category)
 {
     if (!loggedIn)
     {
         notLoggedInException();
     }
     return(StoreService.AddProductToStore(user, storeId, name, desc, price, category));
 }
コード例 #3
0
        public string AddProductToStore(int storeId, string name, string desc, double price, string category)
        {
            if (!loggedIn)
            {
                return(notLoggedInError());
            }
            int ret;

            try
            {
                ret = StoreService.AddProductToStore(user, storeId, name, desc, price, category);
                return(intJson(ret));
            }
            catch (Exception e)
            {
                return(generateMessageFormatJason(e.Message));
            }
        }