public void AccoutTypeMapperToDTOTest()
        {
            AccountType    accountType    = AccountType.BASE;
            AccountTypeDTO accountTypeDTO = AccountTypeMapper.MapAccountTypeToDTO(accountType);

            Assert.That(accountType.ToString(), Is.EqualTo(accountTypeDTO.ToString()));
        }
Exemplo n.º 2
0
        private void txtUsername_TextChanged(object sender, EventArgs e)
        {
            string     username = txtUsername.Text.Trim();
            AccountDTO account  = AccountDAO.Instance.GetAccountByUsername(username);

            if (account != null)
            {
                AccountTypeDTO type = AccountTypeDAO.Instance.GetTypeByID(account.Type);
                if (type != null)
                {
                    int index = -1;
                    int i     = 0;
                    foreach (AccountTypeDTO item in cbAccountType.Items)
                    {
                        if (item.Id == type.Id)
                        {
                            index = i;
                            break;
                        }
                        i++;
                    }

                    cbAccountType.SelectedIndex = index;
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="accountType"></param>
        /// <returns></returns>
        public async Task UpdateItem(AccountTypeDTO accountType)
        {
            var accountTypeEntity = _mapper.Map <AccountType>(accountType);

            _dbContext.AccountTypes.Update(accountTypeEntity);

            await _dbContext.SaveChangesAsync();
        }
Exemplo n.º 4
0
 public void Add(AccountTypeDTO DTO)
 {
     using (var container = new InventoryContainer())
     {
         PayAccountTypeInfo gur = new PayAccountTypeInfo();
         container.PayAccountTypeInfoes.AddObject((PayAccountTypeInfo)DTOMapper.DTOObjectConverter(DTO, gur));
         container.SaveChanges();
     }
 }
Exemplo n.º 5
0
        public async Task <ActionResult> Post([FromBody] AccountTypeDTO newAccountType)
        {
            if (newAccountType == null)
            {
                return(BadRequest("Invalid data"));
            }

            return(Ok(await _mediator.Send(new CreateAccountTypeCommand {
                AccountType = newAccountType
            })));
        }
Exemplo n.º 6
0
        public async Task <ActionResult> Get(int id)
        {
            if (id < 0)
            {
                return(BadRequest("Invalid data"));
            }

            AccountTypeDTO response = await _mediator.Send(new GetAccountTypeQuery { Id = id });

            return(response == null?NotFound("Entry not found") : Ok(response));
        }
Exemplo n.º 7
0
        public List <AccountTypeDTO> GetListAccountType()
        {
            List <AccountTypeDTO> accountTypeDTOs = new List <AccountTypeDTO>();
            string    query     = string.Format("SELECT * FROM dbo.AccountType");
            DataTable dataTable = DataProvider.Instance.ExcuteQuery(query);

            foreach (DataRow item in dataTable.Rows)
            {
                AccountTypeDTO accountTypeDTO = new AccountTypeDTO(item);
                accountTypeDTOs.Add(accountTypeDTO);
            }
            return(accountTypeDTOs);
        }
Exemplo n.º 8
0
        public AccountTypeDTO GetTypeByID(int id)
        {
            AccountTypeDTO type = null;
            string         SQL  = "Select * From AccountType Where TypeID = " + id;
            DataTable      data = DBUtilities.Instance.ExecuteQuery(SQL);

            foreach (DataRow item in data.Rows)
            {
                type = new AccountTypeDTO(item);
                return(type);
            }

            return(type);
        }
Exemplo n.º 9
0
        public List <AccountTypeDTO> GetListType()
        {
            List <AccountTypeDTO> listType = new List <AccountTypeDTO>();
            string    SQL  = "Select * From AccountType";
            DataTable data = DBUtilities.Instance.ExecuteQuery(SQL);

            foreach (DataRow item in data.Rows)
            {
                AccountTypeDTO type = new AccountTypeDTO(item);
                listType.Add(type);
            }

            return(listType);
        }
Exemplo n.º 10
0
        public async Task <ActionResult> PostAccountType(AccountTypeDTO accountType)
        {
            try
            {
                await _service.InsertItem(accountType);

                return(CreatedAtAction("GetAccountType", new { id = accountType.AccountTypeId }, accountType));
            }

            catch (Exception ex)
            {
                Log.LogError($"Chyba při ukládání do databáze: {ex.InnerException}");
                return(NotFound());
            }
        }
Exemplo n.º 11
0
        public void Edit(AccountTypeDTO EduDTO)
        {
            using (var container = new InventoryContainer())
            {
                var Comp = new PayAccountTypeInfo();
                Comp = container.PayAccountTypeInfoes.FirstOrDefault(o => o.AccountTypeId.Equals(EduDTO.AccountTypeId));

                Comp.AccountTypeId   = EduDTO.AccountTypeId;
                Comp.AccountTypeName = EduDTO.AccountTypeName;
                Comp.UpdateBy        = EduDTO.UpdateBy;
                Comp.UpdateDate      = EduDTO.UpdateDate;
                Comp = (PayAccountTypeInfo)DTOMapper.DTOObjectConverter(EduDTO, Comp);

                container.SaveChanges();
            }
        }
Exemplo n.º 12
0
        public async Task <IActionResult> PutAccountType(int id, AccountTypeDTO accountType)
        {
            if (id != accountType.AccountTypeId)
            {
                Log.LogError($"Chyba!!! Záznam s tímto Id nebyl nalezen.");
                return(BadRequest());
            }

            try
            {
                await _service.UpdateItem(accountType);

                return(CreatedAtAction("GetAccountType", new { id = accountType.AccountTypeId }, id));
            }

            catch (Exception ex)
            {
                Log.LogError($"Chyba při ukládání do databáze: {ex.InnerException}");
                return(NotFound());
            }
        }
Exemplo n.º 13
0
 public AccountRangeDTO(int? id, int companyId, string name, int codeFrom, int codeTo, AccountTypeDTO type, bool currentAccount, bool removable)
     : base(id, name, codeFrom, codeTo, type, currentAccount, removable)
 {
     this.CompanyId = companyId;
 }
 public static AccountType MapAccountTypeFromDTO(AccountTypeDTO accountTypeDTO)
 {
     return((AccountType)accountTypeDTO);
 }
 public void Add(AccountTypeDTO DTO)
 {
     acctypedal.Add(DTO);
 }
Exemplo n.º 16
0
        public void AccountTest_ThreeAccounts_ToWithdrayMoneyFromAccount_Moq(int id, string name, string surname, decimal amount, int bonus, AccountTypeDTO accountType)
        {
            // Arrange
            Mock <IBonus> mockWithraw       = new Mock <IBonus>();
            Mock <IBonus> mockReplenishment = new Mock <IBonus>();

            // Act
            mockWithraw.Setup(m => m.GetBonusPoints(It.IsAny <BankAccountDTO>(), It.IsAny <decimal>()))
            .Returns <BankAccountDTO, decimal>((account, balance) => account.BonusPointToWithdraw);

            mockReplenishment.Setup(m => m.GetBonusPoints(It.IsAny <BankAccountDTO>(), It.IsAny <decimal>()))
            .Returns <BankAccountDTO, decimal>((account, balance) => account.BonusPointToReplenishment);

            IBankAccountFactory bankAccount = new BankAccountFactory()
            {
                Withdraw      = mockWithraw.Object,
                Replenishment = mockReplenishment.Object
            };

            BankAccountDTO accountDTO = bankAccount.GetAccount(id, name, surname, amount, bonus, accountType);

            accountDTO.ReplenishmentMoney(100500);
            accountDTO.WithdrawMoney(100500);

            // Assert
            Assert.AreEqual(0, accountDTO.Amount);
        }
 public void Edit(AccountTypeDTO EduDTO)
 {
     acctypedal.Edit(EduDTO);
 }