private static void UpdateOwner(AccountOwner updatingOwner, DtoAccountOwner owner) { updatingOwner.Email = owner.Email; updatingOwner.FirstName = owner.FirstName; updatingOwner.LastName = owner.LastName; updatingOwner.Password = owner.Password; }
public static AccountOwner ToBllAccountOwner(this DtoAccountOwner owner) { var result = new AccountOwner(owner.FirstName, owner.LastName, owner.Email); result.Accounts.AddRange(owner.Accounts.Select(account => account.ToBllAccount(result))); return(result); }
public static AccountOwner ToOrmAccountOwner(this DtoAccountOwner accountOwner) => new AccountOwner { Email = accountOwner.Email, FirstName = accountOwner.FirstName, LastName = accountOwner.LastName, Password = accountOwner.Password };
public static DtoAccount ToDtoAccount(this Account account, DtoAccountOwner accountOwner) => new DtoAccount { AccountType = account.AccountType.Name, Balance = account.Balance, Bonus = account.Bonus, AccountNumber = account.AccountNumber, AccountOwner = accountOwner };
public static DtoAccountOwner ToDtoAccountOwner(this AccountOwner accountOwner) { var dtoOwner = new DtoAccountOwner { Email = accountOwner.Email, FirstName = accountOwner.FirstName, LastName = accountOwner.LastName, Password = accountOwner.Password }; dtoOwner.Accounts.AddRange(accountOwner.Accounts.Select(account => account.ToDtoAccount(dtoOwner))); return(dtoOwner); }
/// <inheritdoc /> public void AddOwner(DtoAccountOwner owner) { if (owner is null) { throw new ArgumentNullException(nameof(owner)); } try { var ormAccountOwner = _context.Set <AccountOwner>().FirstOrDefault(own => own.Email == owner.Email); if (!(ormAccountOwner is null)) { throw new RepositoryException("Owner with specified email already exists in repository."); } _context.Set <AccountOwner>().Add(owner.ToOrmAccountOwner()); } catch (Exception ex) { throw new RepositoryException("Error in adding new account owner.", ex); } }
/// <inheritdoc /> public void UpdateOwner(DtoAccountOwner owner) { if (owner is null) { throw new ArgumentNullException(nameof(owner)); } try { var updatingOwner = _context.Set <AccountOwner>().FirstOrDefault(own => own.Email == owner.Email); if (updatingOwner is null) { throw new RepositoryException("Updating owner does not exist."); } UpdateOwner(updatingOwner, owner); _context.Entry(updatingOwner).State = EntityState.Modified; } catch (Exception ex) { throw new RepositoryException("Error in updating account owner.", ex); } }