public async Task <IActionResult> Delete(int id) { // find log to delete var logToDelete = _mapper.Map <Log>(await _repo.GetLogById(id)); // then delete log _repo.Delete <Log>(logToDelete); if (await _repo.SaveAll()) { return(Ok()); } throw new Exception("Error deleting log id " + id); }