Ejemplo n.º 1
0
 public Account(Domain.Entities.Account account, int?globalReservationLimit)
 {
     Id               = account.Id;
     IsLevy           = account.IsLevy;
     Name             = account.Name;
     ReservationLimit = account.ReservationLimit ?? globalReservationLimit;
 }
Ejemplo n.º 2
0
 public Domain.Entities.Account ToDomainAccount()
 {
     Domain.Entities.Account account = new Domain.Entities.Account();
     account.AccountId = this.AccountId;
     account.AccountName = this.AccountName;
     return account;
 }
Ejemplo n.º 3
0
            public async Task <Guid> Handle(Add request, CancellationToken cancellationToken)
            {
                try
                {
                    using var unitOfWork = new ContactFormServerUnitOfWork(context);

                    var account = new Domain.Entities.Account
                    {
                        Id = Guid.NewGuid(),

                        EMail = request.email,

                        Enabled = false,

                        Created = DateTime.Now,

                        //TODO: Add Currente User Id Management
                        CreatedBy = "me"
                    };

                    await unitOfWork.Accounts.AddAsync(account, cancellationToken).ConfigureAwait(false);

                    await unitOfWork.CompleteAsync(cancellationToken);

                    return(account.Id);
                }
                catch (Exception ex)
                {
                    string content = ex.InnerException != null ? ex.InnerException.Message : ex.Message;
                    this.logger.LogError(content);
                    return(Guid.Empty);
                    // throw ex;
                }
            }
Ejemplo n.º 4
0
        public async Task <Response <Guid> > Handle(TransferAccountCommand request, CancellationToken cancellationToken)
        {
            if (request.Invalid)
            {
                return(new Response <Guid>(request.Notifications.Select(p => p.Message)));
            }

            var source = new Domain.Entities.Account(
                request.Source.BankId,
                request.Source.Number,
                request.Source.Agency,
                request.Source.Amount
                );

            var destination = new Domain.Entities.Account(
                request.Destination.BankId,
                request.Destination.Number,
                request.Destination.Agency,
                request.Destination.Amount
                );

            var debitResponse = await _mediator.Send(new DebitAccountCommand(source.BankId, source.Number, source.Agency, source.Amount));

            var creditResponse = await _mediator.Send(new CreditAccountCommand(destination.BankId, destination.Number, destination.Agency, destination.Amount));

            await _emailService.SendEmail(
                new EmailDto {
                From    = "*****@*****.**",
                To      = "*****@*****.**",
                Subject = "Tranferência realizada com sucesso",
                Body    = $"Uma nova transferência foi realizada no valor de: {request.Amount}"
            });

            return(new Response <Guid>(Guid.NewGuid()));
        }
        public async Task <Response> Handle(CreateAccount request, CancellationToken cancellationToken)
        {
            var response = new Response();
            var account  = new Domain.Entities.Account(request.Agency, request.Account, request.Amount);

            if (!account.Valid)
            {
                response.AddNotifications(account.Notifications);
            }
            else
            {
                var exists = await _repository.Get(request.Account);

                if (exists == null)
                {
                    response.AddValue(await _repository.Add(account));
                }
                else
                {
                    response.AddNotification(new Notification("Conta", "Conta já cadastrada"));
                }
            }

            return(response);
        }
        public async Task Handler(CreateAccountCommand command)
        {
            var account = new Domain.Entities.Account
            {
                Frequency = command.Frequency,
                Created   = command.Created
            };

            await _context.Accounts.AddAsync(account);
        }
        public void Then_If_There_Is_No_Limit_On_The_Account_The_Global_Value_Is_Used(
            Domain.Entities.Account accountEntity, int globalReservationLimit)
        {
            //Arrange
            accountEntity.ReservationLimit = null;

            //Act
            var actual = new Domain.Account.Account(accountEntity, globalReservationLimit);

            //Assert
            Assert.AreEqual(globalReservationLimit, actual.ReservationLimit);
        }
        public void Then_The_Entity_Is_Mapped_To_The_Domain(
            Domain.Entities.Account accountEntity)
        {
            //Act
            var actual = new Domain.Account.Account(accountEntity, 1);

            //Assert
            actual.Should()
            .BeEquivalentTo(accountEntity,
                            options => options
                            .Excluding(c => c.ProviderPermissions)
                            .Excluding(c => c.AccountLegalEntities));
        }
Ejemplo n.º 9
0
        public async Task Then_Gets_Entity_From_Repository(
            Domain.Entities.Account account,
            [Frozen] Mock <IAccountRepository> mockRepository,
            AccountsService service)
        {
            mockRepository
            .Setup(repository => repository.Get(account.Id))
            .ReturnsAsync(account);

            await service.GetAccount(account.Id);

            mockRepository.Verify(repository => repository.Get(account.Id), Times.Once);
        }
Ejemplo n.º 10
0
        public async Task Then_Maps_Entity_To_Domain_Model(
            Domain.Entities.Account account,
            [Frozen] Mock <IAccountRepository> mockRepository,
            AccountsService service)
        {
            mockRepository
            .Setup(repository => repository.Get(account.Id))
            .ReturnsAsync(account);

            var actual = await service.GetAccount(account.Id);

            actual.Should().BeOfType <Domain.Account.Account>();
            account.Should().BeEquivalentTo(actual);
        }
        public override Domain.Entities.Account GetAccountByName(string accountName)
        {
            var query = (from r in context.Accounts
                         where String.Compare(r.AccountName, accountName, true) == 0
                         select r).FirstOrDefault();

            Domain.Entities.Account retAccount = null;

            if (query != null)
            {
                retAccount = new Domain.Entities.Account();
                retAccount.AccountId = query.AccountId;
                retAccount.AccountName = query.AccountName;
            }

            return retAccount;
        }
Ejemplo n.º 12
0
        protected void btnAddNewAccount_Click(object sender, EventArgs e)
        {
            try
            {
                Domain.Entities.Account account = new Domain.Entities.Account();
                account.AccountName = txtAccountName.Text;
                Ioc.Container.Resolve<Domain.Services.AccountService>().AddAccount(account);

                // Refresh from data source
                gvAccount.DataBind();
            }
            catch (Exception ex)
            {
                lblAddNewAccountError.Visible = true;
                lblAddNewAccountError.Text = ex.Message;

            }
        }
        public void Arrange()
        {
            var account = new Domain.Entities.Account
            {
                Id               = 1,
                Name             = "Test",
                IsLevy           = true,
                ReservationLimit = 3
            };

            _legalEntities = new List <Domain.Entities.AccountLegalEntity>
            {
                new Domain.Entities.AccountLegalEntity
                {
                    Id                     = Guid.NewGuid(),
                    AccountId              = 1,
                    AccountLegalEntityId   = 2,
                    AccountLegalEntityName = "Test",
                    LegalEntityId          = 43,
                    AgreementSigned        = false,
                    ProviderPermissions    = null,
                    Account                = account
                },
                new Domain.Entities.AccountLegalEntity
                {
                    Id                     = Guid.NewGuid(),
                    AccountId              = 1,
                    AccountLegalEntityId   = 3,
                    AccountLegalEntityName = "Test 2",
                    LegalEntityId          = 54,
                    AgreementSigned        = true,
                    ProviderPermissions    = null,
                    Account                = account
                }
            };

            _repository = new Mock <IAccountLegalEntitiesRepository>();
            _repository.Setup(x => x.GetByAccountId(ExpectedAccountId)).ReturnsAsync(_legalEntities);

            _options = new Mock <IOptions <ReservationsConfiguration> >();
            _options.Setup(x => x.Value.MaxNumberOfReservations).Returns(ExpectedReservationLimit);

            _service = new AccountLegalEntitiesService(_repository.Object, _options.Object);
        }
Ejemplo n.º 14
0
        public async Task Then_If_There_Is_No_Reservation_Limit_On_The_Account_It_Is_Taken_From_Config(
            Domain.Entities.Account account,
            int numberOfReservations,
            [Frozen] Mock <IOptions <ReservationsConfiguration> > configuration,
            [Frozen] Mock <IAccountRepository> mockRepository
            )
        {
            configuration.Setup(x => x.Value.MaxNumberOfReservations).Returns(numberOfReservations);
            account.ReservationLimit = null;
            mockRepository
            .Setup(repository => repository.Get(account.Id))
            .ReturnsAsync(account);

            var service = new AccountsService(mockRepository.Object, configuration.Object);

            var actual = await service.GetAccount(account.Id);

            actual.ReservationLimit.Should().Be(numberOfReservations);
        }
        public override Domain.Entities.Account GetAccountByName(string accountName)
        {
            dsHomeBudget ds = ReadData();

            var query = (from row in ds.Account
                        where String.Compare(row.AccountName, accountName, true) == 0
                        select row).FirstOrDefault();

            if (query == null)
            {
                return null;
            }

            Domain.Entities.Account account = new Domain.Entities.Account();
            account.AccountId = query.AccountId;
            accountName = query.AccountName;

            return account;
        }
Ejemplo n.º 16
0
 private Domain.Account.Account MapAccount(Domain.Entities.Account account)
 {
     return(new Domain.Account.Account(account, _configuration.MaxNumberOfReservations));
 }