public async Task <IActionResult> Delete(int id) { var entity = await AccountDto.ToEntity(id, _context); if (entity == null) { return(NotFound()); } _context.Accounts.Remove(entity); await _context.SaveChangesAsync(); return(NoContent()); }
public async Task <IActionResult> Put(AccountDto dto) { var entity = await AccountDto.ToEntity(dto, _context); if (entity == null) { return(NotFound()); } _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); return(CreatedAtAction("Get", new { }, dto)); }
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)); }