예제 #1
0
 public async Task <ActionResult <IEnumerable <AccountDto> > > Get()
 {
     return(await _context.Accounts
            .OrderBy(i => i.PaymentDate)
            .Select(i => AccountDto.FromEntity(i))
            .ToListAsync());
 }
예제 #2
0
        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));
        }
예제 #3
0
        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));
        }