예제 #1
0
        public async Task <Cuenta> CreateCuentaRootAsync(string numero, CuentaTypeEnum tipo, string monedaId, BalanceTypeEnum balance, string nombre)
        {
            if (formatProvider.GetLevelOf(numero) != 0)
            {
                throw new NumeroCuentaNotRootException(numero, nameof(numero));
            }

            return(await CreateCuentaAsync(numero, tipo, monedaId, balance, nombre));
        }
예제 #2
0
        public Cuenta(string id, string parentId, CuentaTypeEnum tipo, Moneda moneda, BalanceTypeEnum balance) : this()
        {
            Check.NotNull(moneda, nameof(moneda));
            Check.NotNull(id, nameof(id));
            Check.NotNull(moneda, nameof(moneda));

            Id = id;
            if (!string.IsNullOrEmpty(parentId))
            {
                ParentId = parentId;
            }

            Tipo    = tipo;
            Moneda  = moneda;
            Balance = balance;
        }
예제 #3
0
        private async Task <Cuenta> CreateCuentaAsync(string numero, CuentaTypeEnum tipo, string monedaId, BalanceTypeEnum balance, string nombre)
        {
            numero = CheckNumero(numero, nameof(numero));

            if (await cuentaStore.AnyAsync(x => x.Id == numero))
            {
                throw new CuentaDuplicadaException(numero);
            }

            var moneda = await monedaManager.GetAsync(monedaId);

            var cuenta = new Cuenta(numero, null, tipo, moneda, balance)
            {
                Nombre = nombre
            };

            await cuentaStore.InsertAsync(cuenta, autoSave : true);

            return(cuenta);
        }
예제 #4
0
 public static string CuentaTypeEnumToString(CuentaTypeEnum input)
 {
     return(input.ToString("g"));
 }