Пример #1
0
        /// <summary>
        /// The add current account.
        /// </summary>
        /// <param name="owner">
        /// The owner.
        /// </param>
        /// <param name="input">
        /// The input.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// The Argument Null Exception.
        /// </exception>
        public async Task <Guid> AddCurrentAccount(Guid owner, CurrentAccountIn input)
        {
            if (owner == null)
            {
                throw new ArgumentNullException(nameof(owner));
            }

            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            // TODO: Add validations
            if (!this.cacheProvider.Banks.Select(x => x.Code).Contains(input.Bank))
            {
                throw new Exception("The Bank " + input.Bank + " doesnt look valid.");
            }

            if (!this.cacheProvider.Currencies.Select(x => x.Code).Contains(input.Currency))
            {
                throw new Exception("The currency " + input.Currency + " doesnt look valid.");
            }

            var currentGuid = Guid.NewGuid();

            var result = await this.accountRepository.Add(owner, currentGuid, input);

            return(result != 0 ? currentGuid : Guid.Empty);
        }
Пример #2
0
        /// <summary>
        /// The add.
        /// </summary>
        /// <param name="owner">
        /// The owner.
        /// </param>
        /// <param name="code">
        /// The code.
        /// </param>
        /// <param name="input">
        /// The input.
        /// </param>
        /// <returns>
        /// The <see cref="Task"/>.
        /// </returns>
        public async Task <int> Add(Guid owner, Guid code, CurrentAccountIn input)
        {
            var account = new CurrentAccountEntity
            {
                Code        = code,
                Owner       = owner,
                Holder      = input.Holder,
                IsArchived  = input.IsArchived,
                Bank        = input.Bank,
                Description = input.Description,
                Amount      = input.Amount,
                Currency    = input.Currency,
                Iban        = input.Iban,
                Number      = input.Number,
                StartDate   = input.StartDate
            };

            this.context.Accounts.Add(account);

            foreach (var loan in input.Loans)
            {
                this.context.Accounts.Add(GetLoans(owner, code, Guid.NewGuid(), loan));
            }

            foreach (var saving in input.Savings)
            {
                this.context.Accounts.Add(GetSavings(owner, code, Guid.NewGuid(), saving));
            }

            var myint = await this.context.SaveChangesAsync();

            return(myint);
        }
Пример #3
0
 /// <summary>
 /// The add current details.
 /// </summary>
 /// <param name="owner">
 /// The owner.
 /// </param>
 /// <param name="account">
 /// The account.
 /// </param>
 /// <returns>
 /// The <see cref="Task"/>.
 /// </returns>
 public Task <HttpResponseMessage> AddCurrentDetails(Guid owner, CurrentAccountIn account)
 {
     throw new NotImplementedException();
 }
Пример #4
0
 public async Task <HttpResponseMessage> AddCurrentDetails(Guid owner, CurrentAccountIn account)
 {
     return(await this.ProcessActionAsync(owner, account, this.accountService.AddCurrentAccount));
 }