private void DoSave() { ExecuteFaultHandledOperation(() => { event_aggregator.GetEvent <AccountUpdatedEvent>().Publish(ApplicationStrings.BeginningSave); ICleaningUtility cleaner = Unity.Container.Resolve <ICleaningUtility>(); using (TransactionScope scope = new TransactionScope()) // TransactionScopeAsyncFlowOption.Enabled { if (Account.AccountKey == 0 && Account.AccountCode == "") { GetNextAccountNumber(); } List <EntityAttributeWrapper> atts_with_values = Account.AccountAttributes.Where(i => i.AttributeValue != "" || i.AttributeKey > 0).ToList(); Account.AccountAttributes.Clear(); foreach (var good_att in atts_with_values) { Account.AccountAttributes.Add(good_att); } Account.Model.Addresses.Clear(); cleaner.CleanAddress(DefaultBillingAddress.Model); DefaultBillingAddress.AddressType = QIQOAddressType.Billing; Account.Model.Addresses.Add(DefaultBillingAddress.Model); cleaner.CleanAddress(DefaultShippingAddress.Model); DefaultShippingAddress.AddressType = QIQOAddressType.Shipping; Account.Model.Addresses.Add(DefaultShippingAddress.Model); cleaner.CleanAddress(DefaultMailingAddress.Model); DefaultMailingAddress.AddressType = QIQOAddressType.Mailing; Account.Model.Addresses.Add(DefaultMailingAddress.Model); IAccountService account_service = service_factory.CreateClient <IAccountService>(); using (account_service) { int _account_key = account_service.CreateAccount(Account.Model); event_aggregator.GetEvent <AccountUpdatedEvent>().Publish($"{Account.AccountCode} - {Account.AccountName} updated sucessfully"); Account.AcceptChanges(); } scope.Complete(); working_account_service.CloseAccount(Account); } }); }
private void DoSave() { ExecuteFaultHandledOperation(() => { IEmployeeService employee_service = service_factory.CreateClient <IEmployeeService>(); ICleaningUtility cleaner = Unity.Container.Resolve <ICleaningUtility>(); cleaner.CleanAddress(DefaultAddress.Model); DefaultAddress.AddressType = QIQOAddressType.Mailing; CurrentEmployee.Model.Addresses.Add(DefaultAddress.Model); //foreach (var att in CurrentEmployee.PersonAttributes) // if (att.AttributeValue == "") CurrentEmployee.PersonAttributes.Remove(att); using (employee_service) { int emp_key = employee_service.CreateEmployee(CurrentEmployee.Model); notification.Confirmed = true; FinishInteraction(); } }); }
private void MapPropsToObject() { ICleaningUtility cleaner = Unity.Container.Resolve <ICleaningUtility>(); // Need to add the addresses one at a time from properties??? Ah, yeah! Company.CompanyAddresses.Clear(); // clear this for updates and inserts cleaner.CleanAddress(DefaultBillingAddress.Model); DefaultBillingAddress.AddressType = QIQOAddressType.Billing; cleaner.CleanAddress(DefaultShippingAddress.Model); DefaultShippingAddress.AddressType = QIQOAddressType.Shipping; Company.CompanyAddresses.Add(DefaultBillingAddress); Company.CompanyAddresses.Add(DefaultShippingAddress); Company.GLAccounts.Select(item => item.CompanyKey = CurrentCompanyKey); List <EntityAttributeWrapper> atts_with_values = Company.CompanyAttributes.Where(i => i.AttributeValue != "" || i.AttributeKey > 0).ToList(); Company.CompanyAttributes.Clear(); foreach (var good_att in atts_with_values) { Company.CompanyAttributes.Add(good_att); } }