internal static int AddNew(string sPhoneNumber) { // Kiểm tra tồn tại duy nhất // throw new NotImplementedException(); Customer newCustomer = new Customer(); newCustomer.Phone = sPhoneNumber; mpdb.Customers.InsertOnSubmit(newCustomer); mpdb.SubmitChanges(); return newCustomer.ID; }
internal static Customer getCustomer(string smsContent) { Customer newCustomer = new Customer(); try { string[] arrArgs = smsContent.Split(separateChar); newCustomer.Phone = arrArgs[3]; } catch { newCustomer.Phone = "ERROR!."; } return newCustomer; }
//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; }
private void detach_Customers(Customer entity) { this.SendPropertyChanging(); entity.CustomerStatus = null; }
partial void DeleteCustomer(Customer instance);
partial void UpdateCustomer(Customer instance);
partial void InsertCustomer(Customer instance);