public static bool AddNew(PartPacificCode entity)
 {
     MoneyPacificDataContext mpdb = new MoneyPacificDataContext();
     mpdb.PartPacificCodes.InsertOnSubmit(entity);
     mpdb.SubmitChanges();
     mpdb.Connection.Close();
     return true;
 }
 public static bool Update(PartPacificCode entity)
 {
     MoneyPacificDataContext mpdb = new MoneyPacificDataContext();
     PartPacificCode existPPC = mpdb.PartPacificCodes
         .Where(p => p.Id.Equals(entity.Id))
         .Single<PartPacificCode>();
     existPPC.CopyFrom(entity);
     mpdb.SubmitChanges();
     mpdb.Connection.Close();
     return true;
 }
        /// <summary>
        /// Tạo 1 PacificCode có giá trị amountBuy
        /// Lấy 12/16 lưu lại trong PartPacificCode
        /// </summary>
        internal static PartPacificCode GetNewPacificCode(Guid storeGuid, Guid customerGuid, int amountBuy)
        {
            BlackBoxServiceClient clientService = new BlackBoxServiceClient();
            PartPacificCode newPartPacificCode = new PartPacificCode();
  
            string codeNumber = clientService.NewPacificCode(amountBuy);    
            
            newPartPacificCode.PartCodeNumber = GetPartCodeNumber(codeNumber);
            newPartPacificCode.StoreUserId = storeGuid;
            newPartPacificCode.CustomerId = customerGuid;

            PartPacificCodeDAO.AddNew(newPartPacificCode);

            ///clientService.Close(); // Lỗi khi đang gọi bị đóng seviceClient
            return newPartPacificCode;            
        }
        internal static PacificCodeViewModel SendMoney(string codeNumber, string phoneNumber, double amount)
        {
            BlackBoxServiceClient clientService = new BlackBoxServiceClient();
            string newCodeNumber = clientService.MakePayment(codeNumber, (int)amount);

            /// Lưu thông tin liên quan đến khách hàng
            PartPacificCode newPartPacficiCode = new PartPacificCode();
            Customer existCustomer = CustomerBUS.GetCustomerOrCreateNotYetBuy(phoneNumber);

            newPartPacficiCode.CustomerId = existCustomer.UserId;
            newPartPacficiCode.StoreUserId = null;

            // Lấy ID tự động?
            PartPacificCodeDAO.AddNew(newPartPacficiCode);

            /// Lấy payment model, trả ra kết quả
            PacificCodeViewModel model = clientService.GetPacificCodeViewModel(newCodeNumber);
            return model;
        }
 partial void DeletePartPacificCode(PartPacificCode instance);
 partial void UpdatePartPacificCode(PartPacificCode instance);
 partial void InsertPartPacificCode(PartPacificCode instance);
		private void detach_PartPacificCodes(PartPacificCode entity)
		{
			this.SendPropertyChanging();
			entity.StoreUser = null;
		}
		private void attach_PartPacificCodes(PartPacificCode entity)
		{
			this.SendPropertyChanging();
			entity.Customer = this;
		}
		private void detach_PartPacificCodes(PartPacificCode entity)
		{
			this.SendPropertyChanging();
			entity.Category = null;
		}