public void AccoutTypeMapperToDTOTest() { AccountType accountType = AccountType.BASE; AccountTypeDTO accountTypeDTO = AccountTypeMapper.MapAccountTypeToDTO(accountType); Assert.That(accountType.ToString(), Is.EqualTo(accountTypeDTO.ToString())); }
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(); }
public void Add(AccountTypeDTO DTO) { using (var container = new InventoryContainer()) { PayAccountTypeInfo gur = new PayAccountTypeInfo(); container.PayAccountTypeInfoes.AddObject((PayAccountTypeInfo)DTOMapper.DTOObjectConverter(DTO, gur)); container.SaveChanges(); } }
public async Task <ActionResult> Post([FromBody] AccountTypeDTO newAccountType) { if (newAccountType == null) { return(BadRequest("Invalid data")); } return(Ok(await _mediator.Send(new CreateAccountTypeCommand { AccountType = newAccountType }))); }
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)); }
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); }
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); }
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); }
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()); } }
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(); } }
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()); } }
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); }
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); }