internal static bool IsExist(StoreUser senderStore) { DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext(); bool bResult = mpdb.StoreUsers.Any(l => l.Phone.Trim() == senderStore.Phone.Trim()); mpdb.Connection.Close(); return bResult; }
// private static DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext(); internal static bool CheckPassword(StoreUser senderStore) { DBMoneyPacificDataContext mpdb = new DBMoneyPacificDataContext(); bool bResult = mpdb.StoreUsers.Where(l => (l.Phone == senderStore.Phone && l.PINStore == senderStore.PINStore)).Any(); mpdb.Connection.Close(); return bResult; }
internal static bool checkPassword(StoreUser senderStore) { return StoreUserDAO.CheckPassword(senderStore); }
internal static bool IsExist(StoreUser senderStore) { return StoreUserDAO.IsExist(senderStore); }
partial void DeleteStoreUser(StoreUser instance);
partial void UpdateStoreUser(StoreUser instance);
partial void InsertStoreUser(StoreUser instance);
private void detach_StoreUsers(StoreUser entity) { this.SendPropertyChanging(); entity.StoreUserState = null; }
private void attach_StoreUsers(StoreUser entity) { this.SendPropertyChanging(); entity.StoreUserState = this; }
private void detach_StoreUsers(StoreUser entity) { this.SendPropertyChanging(); entity.PacificCode = null; }
public string Execute(string[] args) { // Cú pháp SMS: // <StorePhone>*<PINStore>*<Amount>*<CustomerPhone>*<AmountConfirm> string smsRespones = ""; string sErrorMessage = ""; string sReceiverPhone = ""; string sContentSMS = ""; // Get information :----------------------- StoreUser senderStore = new StoreUser(); senderStore.Phone = args[0]; senderStore.PINStore = args[1]; int amountBuy = int.Parse(args[2]); int amountBuyConfirm = int.Parse(args[4]); Customer buyerCustomer = new Customer(); buyerCustomer.Phone = args[3]; // Check Information:----------------------- // 01. check STORE bool bSenderExists = StoreUserBUS.IsExist(senderStore); if (!bSenderExists) { sReceiverPhone = senderStore.Phone.Trim(); sContentSMS = MessageManager.GetValue("NOT_EXIST_STORE"); smsRespones = sReceiverPhone + "*" + sContentSMS; return smsRespones; } // 02. check StoreUser (password & status) bool bValidPassword = false; bValidPassword = StoreUserBUS.checkPassword(senderStore); if (!bValidPassword) { sErrorMessage += MessageManager.GetValue("WRONG_PASSWORD"); } else { senderStore = StoreUserBUS.getStoreUser(senderStore.Phone, senderStore.PINStore); } // *** KIEM TRA KH BLACK LIST sau khi Kiem tra STORE if (CustomerBUS.isInBlackList(buyerCustomer.Phone)) return senderStore.Phone.Trim() + "*" + MessageManager.GetValue("CUSTOMER_IN_BLACK_LIST"); // 03. check PACIFIC CODE Categories bool bValidAmount = false; bValidAmount = CategoriesBUS.isValidAmount(amountBuy); if (!bValidAmount) { sErrorMessage += MessageManager.GetValue("INVALID_AMOUNT_MESSAGE", amountBuy.ToString()); } // 04. check CONFIRM AMOUNT bool bValidConfirm = (amountBuy == amountBuyConfirm); if (!bValidConfirm) { sErrorMessage += MessageManager.GetValue("INVALID_AMOUNT_CONFIRM"); } // 05. check PHONE (valid and status) bool bValidPhone = Validator.isPhoneNumber(buyerCustomer.Phone); if (!bValidPhone) { sErrorMessage = MessageManager.GetValue("INVALID_PHONE"); } // 06. check CUSTOMER (exist and status) buyerCustomer = CustomerBUS.getCustomerOrCreateNotYetBuy(buyerCustomer.Phone); // Get result: -------------------------- bool bBuyPCodeSuccess = ( bValidPassword && bValidAmount && bValidConfirm && bValidPhone ); if (bBuyPCodeSuccess) { if (StoreUserBUS.IsEnable(senderStore.Id)) { PacificCode newPacificCode = PacificCodeBUS.getNewPacificCode(senderStore.Id, buyerCustomer.Id, amountBuy); sReceiverPhone = buyerCustomer.Phone.Trim(); sContentSMS = MessageManager.GetValue("GENERATE_SUCCESSFUL", Utility.insertSeparateChar(newPacificCode.CodeNumber.Trim(), ' ', 4), newPacificCode.ActualAmount.ToString(), ((DateTime)newPacificCode.ExpireDate).ToShortDateString()); smsRespones = sReceiverPhone + "*" + sContentSMS; // Mua thanh cong thi CustomerSTATUS = "x01" CustomerBUS.setStatus(buyerCustomer.Phone, "x01"); // Log Transaction info TransactionBUS.addNew(newPacificCode); } else // DISABLE { sReceiverPhone = senderStore.Phone.Trim(); sContentSMS = MessageManager.GetValue("STORE_IS_DISABLE"); smsRespones = sReceiverPhone + "*" + sContentSMS; } } else //ERROR: { sReceiverPhone = senderStore.Phone.Trim(' '); sContentSMS = sErrorMessage; smsRespones = sReceiverPhone + "*" + sContentSMS; // Log Transaction info // ... } return smsRespones; }