// public static 

        internal static Store getSender(string smsContent)
        {
            try
            {
                string[] arrArgs = smsContent.Split(separateChar);
                Store newStore = new Store();
                newStore.Phone = arrArgs[0];
                newStore.PassStore = arrArgs[1];

                return newStore;
            }
            catch
            {
                return null;
            }
        }
        //internal static string 

        private static string buyNewPacificCode(Store senderStore, int amountBuy, Customer buyerCustomer, int amountBuyConfirm)
        {
            
            string smsResponse = "";
            string sErrorMessage = "";


            // KIỂM TRA
            // 01. Kiểm tra Store tồn tại & STATUS của Store.
            // (Tách kiểm tra exist & pass ra thành 2 phần để báo lỗi rõ hơn)

            bool bSenderExist = StoreBUS.checkExist(senderStore);

            if (!bSenderExist)
            {
                smsResponse = MessageManager.GenNotExistStoreMessage(senderStore.Phone);
                return smsResponse;
            }

            // 02. Kiểm tra PassStore
            
            bool bCheckValidPassword = false;

            bCheckValidPassword = StoreDAO.checkPassword(senderStore);

            if (!bCheckValidPassword)
            {
                sErrorMessage += MessageManager.GenErrorPasswordStoreMessage();
            }
            else // Neu dung password thi moi cho lay thong tin
            {
                // Sau khi kiem tra xong tồn tại thì nhận thông tin Store, Store ID để tạo PacificCode
                senderStore = StoreBUS.getStore(senderStore.Phone, senderStore.PassStore);
            }        

            
            
            
            // 03. Kiểm tra AMOUNT hợp lệ (load các loại thẻ đang bán)
            
            bool bValidAmount = MoneyCardBUS.checkValid(amountBuy);
            
            if (!bValidAmount)
            {
                sErrorMessage += MessageManager.GenInValidAmountMessage(amountBuy);
            }

            // 04. Kiểm tra AMOUNT_CONFIRM             

            bool bValidConfirm = (amountBuy == amountBuyConfirm);

            if (!bValidConfirm)
            {
                sErrorMessage += MessageManager.GenInValidAmountConfirmMessage();
            }

            // 05. Kiểm tra CUSTOMER_PHONE hợp lệ

            bool bValidPhone = checkPhoneNumber(buyerCustomer.Phone);
            
            if (!bValidPhone)
            {
                sErrorMessage += MessageManager.GenInValidPhoneMessage();
            }

            // 06. Kiểm tra CUSTOMER_PHONE (tồn tại và STATUS)

            bool bCheckValidCustomer = false;

            buyerCustomer = CustomerBUS.getCustomer(buyerCustomer.Phone);
            bCheckValidCustomer = CustomerBUS.checkCustomer(buyerCustomer);
                       
            
            // Gửi 2 tin nhắn cho CUSTOMER & STORE (chưa làm cái này, phải xác định lại cấu trúc tin nhắn mới có thể làm được)

            bool bRegisterSuccess = (
                bCheckValidPassword
                && bValidAmount
                && bValidConfirm
                && bValidPhone
                && bCheckValidCustomer
                );

            if (bRegisterSuccess)
            {
                // Tạo PACIFIC_CODE mới với buyerCustomer (chắc chắn tạo dc)
                PacificCode newPacificCode = PacificCodeBUS.getNewPacificCode(senderStore.ID, buyerCustomer.ID, amountBuy); 
                
                smsResponse = buyerCustomer.Phone.Trim();
                smsResponse += "*" + MessageManager.GenSucessCreatePacificCodeMessage(newPacificCode);

                // Log Transaction
                TransactionBUS.AddNew(newPacificCode);
            }
            else
            {
                
                smsResponse = senderStore.Phone;
                smsResponse += "*" + sErrorMessage;

                // Log Transaction
            }

            return smsResponse;
        }
Example #3
0
        //public Money

        internal static bool checkExist(Store senderStore)
        {
            return StoreDAO.checkExist(senderStore);
        }
 partial void DeleteStore(Store instance);
 partial void UpdateStore(Store instance);
 partial void InsertStore(Store instance);
		private void detach_Stores(Store entity)
		{
			this.SendPropertyChanging();
			entity.StoreStatus = null;
		}
		private void attach_Stores(Store entity)
		{
			this.SendPropertyChanging();
			entity.StoreStatus = this;
		}