protected void SaveAccount(object sender, EventArgs e) { var sub = new SubAccount(); sub.MasterAccountId = MasterAccountId; sub.AccountName = Account.AccountName; sub.BillingAddressType = Account.BillingAddressType; sub.BillingMethod = Account.BillingMethod; sub.ContactRole = Account.ContactRole; sub.EmailBill = Account.EmailBill; sub.EmailBillDataFile = Account.EmailBillDataFile; sub.Password = Account.Password; sub.PostBill = Account.PostBill; sub.IsInvoiceRoot = Account.IsInvoiceRoot; sub.IsInternational = Account.IsInternational; sub.AmountPaid = Account.AmountPaid; if (hdnContactId.Value.Length > 0) { int contactId; if (int.TryParse(hdnContactId.Value, out contactId)) { if (contactId > 0) sub.ContactId = contactId; } } var request = new SaveAccountRequest { Account = sub, User = Users.Current }; var response = AccountService.SaveAccount(request); if (response.IsSuccessful) { UserMessage.SetSuccess("Acount Saved"); SavedPanel.Visible = true; SavePanel.Visible = false; } else { LoggingUtility.LogDebug("SaveAccount", GetType().FullName, "Could not save new Sub Account: " + response.Message); UserMessage.SetFailure(response.Message); SavedPanel.Visible = false; SavePanel.Visible = true; } }
protected void SaveAccount(object sender, EventArgs e) { Account account; if (IsMaster) { var master = new MasterAccount(Account.AccountId.Value); if (hdnCompanyId.Value.Length > 0) { int id; if (int.TryParse(hdnCompanyId.Value, out id)) { if (id > 0) master.CompanyId = id; } } account = master; } else { var sub = new SubAccount(Account.AccountId.Value); if (hdnMasterAccountId.Value.Length > 0) { int id; if (int.TryParse(hdnMasterAccountId.Value, out id)) { if (id > 0) sub.MasterAccountId = id; } } account = sub; } account.AccountName = Account.AccountName; account.AccountNumber = Account.AccountNumber; account.BillingAddressType = Account.BillingAddressType; account.BillingMethod = Account.BillingMethod; account.ContactRole = Account.ContactRole; account.EmailBill = Account.EmailBill; account.EmailBillDataFile = Account.EmailBillDataFile; account.Password = Account.Password; account.PostBill = Account.PostBill; account.IsInvoiceRoot = Account.IsInvoiceRoot; account.IsInternational = Account.IsInternational; account.AmountPaid = Account.AmountPaid; account.PreviousBill = Account.PreviousBill; if (hdnContactId.Value.Length > 0) { int contactId; if (int.TryParse(hdnContactId.Value, out contactId)) { if (contactId > 0) account.ContactId = contactId; } } var request = new SaveAccountRequest { Account = account, User = Users.Current }; var response = AccountService.SaveAccount(request); if (response.IsSuccessful) { UserMessage.SetSuccess("Acount Saved"); } else { UserMessage.SetFailure(response.Message); } }
public static Contract CreateContractOnSubAccount(SubAccount _subAccount, Plan plan) { return new Contract(2, DateTime.Now) { AccountId = _subAccount.Id.Value, ActivationDate = DateTime.Today.AddMonths(-9), EndDate = DateTime.Today.AddMonths(2), AgentId = null, ContractNumber = "LW00002", ContractStatus = ContractStatus.Active, Data = true, MessageBank = true, IMEINumber = "42932323123", SimCard = "12312312313", PhoneNumber1 = "0410000000", Pin = "1234", Puk = "1234", UsedBy = "Test", PlanId = plan.Id.Value }; }
public static SubAccount CreateSubAccount(MasterAccount rootAccount) { var subAccount = new SubAccount(2) { AccountName = "Test Sub Account", AccountNumber = "LW0002", BillingAddressType = BillingAddressType.Postal, // Doesn't matter for sub accounts. BillingMethod = BillingMethod.CreditCard, // Doesn't matter for sub accounts. ContactId = rootAccount.ContactId, ContactRole = "CEO", EmailBill = false, IsInvoiceRoot = false, PostBill = true, EmailBillDataFile = false, HasRequestedInvoicing = false, Password = "******", MasterAccountId = rootAccount.Id.Value }; return subAccount; }
public static AirtimeBilling.Core.Entities.Account CreateEntity(this Account account) { if (account.ParentAccountId == null) { var entity = new MasterAccount(account.AccountId) { AccountNumber = account.AccountNumber, AccountName = account.AccountName, ContactId = account.ContactId, ContactRole = account.ContactRole, BillingMethod = (BillingMethod) Enum.Parse(typeof(BillingMethod), account.BillingMethod.ToString()), EmailBillDataFile = account.EmailBillDataFile, EmailBill = account.EmailBill, PostBill = account.PostBill, Password = account.Password, BillingAddressType = (BillingAddressType) Enum.Parse(typeof(BillingAddressType), account.BillingAddressType.ToString()), IsInvoiceRoot = account.IsInvoiceRoot, CompanyId = account.CompanyId, HasRequestedInvoicing = account.HasRequestedInvoicing, IsInternational = account.IsInternational, AmountPaid = account.AmountPaid, PreviousBill = account.PreviousBill }; return entity; } else { var entity = new AirtimeBilling.Core.Entities.SubAccount(account.AccountId) { AccountNumber = account.AccountNumber, AccountName = account.AccountName, ContactId = account.ContactId, ContactRole = account.ContactRole, BillingMethod = (BillingMethod) Enum.Parse(typeof(BillingMethod), account.BillingMethod.ToString()), EmailBillDataFile = account.EmailBillDataFile, EmailBill = account.EmailBill, PostBill = account.PostBill, Password = account.Password, BillingAddressType = (BillingAddressType) Enum.Parse(typeof(BillingAddressType), account.BillingAddressType.ToString()), IsInvoiceRoot = account.IsInvoiceRoot, MasterAccountId = account.ParentAccountId.Value, HasRequestedInvoicing = account.HasRequestedInvoicing, IsInternational = account.IsInternational, AmountPaid = account.AmountPaid, PreviousBill = account.PreviousBill }; return entity; } }