/// <summary> /// New the account. /// </summary> /// <param name="personId">The person identifier.</param> /// <param name="balance">The balance.</param> /// <param name="typeId">The type identifier.</param> public void NewAccount(int personId, decimal balance, int typeId) { AccountBll temp = FactoryAccounts.CreateAccount(typeId, personId, generator.GenerateNumber(personId, balance, typeId), balance); accountRepository.Create(temp.ToDalAccount()); context.Save(); }
/// <summary> /// To the BLL account. /// </summary> /// <param name="accountDal">The account DAL.</param> /// <returns>Equal BLL account.</returns> public static AccountBll ToBllAccount(this AccountDal accountDal) { AccountBll temp = FactoryAccounts.CreateAccount(accountDal.Type, accountDal.PersonId, accountDal.Number, accountDal.Balance); temp.Person = accountDal.Person.PartialMapPersonBll(); return(temp); }
/// <summary> /// To the DAL account. /// </summary> /// <param name="accountBll">The account BLL.</param> /// <returns>Equal DAL account.</returns> public static AccountDal ToDalAccount(this AccountBll accountBll) { AccountDal temp = FactoryAccounts.CreateAccount(accountBll.TypeId); temp.Valid = accountBll.Valid; temp.Number = accountBll.Number; temp.Balance = accountBll.Balance; temp.Point = accountBll.Point; temp.PersonalInfo.Id = accountBll.PersoneId; return(temp); }
public IEnumerable <AccountDal> GetAll() { foreach (Account account in context.Accounts) { AccountDal temp = FactoryAccounts.CreateAccount(account.AccountType.Id); temp.Id = account.Id; temp.Number = account.Number; temp.Balance = account.Balance; temp.PersonalInfo.Id = account.PersonId; temp.Point = account.Points; temp.Valid = account.Valid; yield return(temp); } }
public AccountDal Get(int id) { Account temp = context.Accounts.FirstOrDefault(item => item.Id == id); if (ReferenceEquals(temp, null)) { throw new ArgumentNullException($"{nameof(id)} doesn't contains in the database"); } AccountDal result = FactoryAccounts.CreateAccount(temp.AccountType.Id); result.Id = temp.Id; result.Number = temp.Number; result.Balance = temp.Balance; result.PersonalInfo.Id = temp.PersonId; result.Point = temp.Points; result.Valid = temp.Valid; return(result); }
/// <summary> /// Partials the map account BLL. /// </summary> /// <param name="accountDal">The account DAL.</param> /// <returns>Current BLL account.</returns> internal static AccountBll PartialMapAccountBll(this AccountDal accountDal) { return(FactoryAccounts.CreateAccount(accountDal.Type, accountDal.PersonId, accountDal.Number, accountDal.Balance)); }