public IAccountBus LoadDetails(IAccountBus account) { if (account.AccountData != null) { var dataService = ServiceLocator.Current.GetInstance<IDataService>(); if (dataService != null) { var repo = dataService.Repo; var address = repo.Query<Address>(String.Format("EntityId={0}",account.AccountData.AccountId),"",0,"*") .FirstOrDefault(); account.AddressData = null; if (address != null) { account.AddressData = address; } var contacts = repo.Query<Contact>(String.Format("AccountId={0}",account.AccountData.AccountId),"",0,"*"); account.Contacts.Clear(); foreach (var contact in contacts) { account.Contacts.Add(contact); } } } return account; }
public ValuesController(IOptions <AccountModel> account, IConfiguration configuration, IAccountBus accountBus, ITokenDto tokenDto, IMemoryCache cache) { _configuration = configuration; this._account = account.Value; _accountBus = accountBus; _tokenDto = tokenDto; _cache = cache; }
public UserController(JWTHelper jWTHelper, IAuthBus authBus, IAccountBus accountBus) { _accountBus = accountBus; _authBus = authBus; _jWTHelper = jWTHelper; }
public void SaveAccount (IAccountBus account) { // Account data switch (account.AccountData.ObjectStatus) { case DataObjectStatus.Modified: _repo.Update(account.AccountData); break; case DataObjectStatus.Added: _repo.Insert(account.AccountData); break; } // Address if (account.AddressData != null) { switch (account.AddressData.ObjectStatus) { case DataObjectStatus.Modified: _repo.Update(account.AddressData); break; case DataObjectStatus.Added: account.AddressData.EntityId = account.AccountData.AccountId; _repo.Insert(account.AddressData); break; } } // Contacts foreach (var contact in account.Contacts) { switch (contact.ObjectStatus) { case DataObjectStatus.Modified: _repo.Update(contact); break; case DataObjectStatus.Added: _repo.Insert(contact); break; case DataObjectStatus.Deleted: _repo.Delete<Contact>(contact.ContactId); break; } } }
public void DeleteAccount(IAccountBus account) { // Address if (account.AddressData != null) { _repo.Delete<Address>(account.AddressData.AddressId); } // Contacts foreach (var contact in account.Contacts) { _repo.Delete<Contact>(contact.ContactId); } // Account _repo.Delete<Account>(account.AccountData.AccountId); }