public async Task <ActionResult <IEnumerable <AccountDto> > > Get() { return(await _context.Accounts .OrderBy(i => i.PaymentDate) .Select(i => AccountDto.FromEntity(i)) .ToListAsync()); }
public async Task <IActionResult> GetAccountById(string id) { int ID = Convert.ToInt32(id); var entity = await AccountDto.FromEntity(ID, _context); if (entity == null) { return(NotFound()); } return(Ok(entity)); }
public async Task <ActionResult <AccountDto> > Post(AccountDto dto) { var entity = await AccountDto.ToEntity(dto, _context); if (entity == null) { return(NotFound()); } await _context.Accounts.AddAsync(entity); await _context.SaveChangesAsync(); var contractDto = AccountDto.FromEntity(entity); return(CreatedAtAction("Get", new { }, contractDto)); }