public async Task <IActionResult> DeleteAsync(int id) { try { var result = await _repo.DeleteAsync(id, User); return(result ? new OkResult() : (IActionResult) new NotFoundResult()); } catch (Exception ex) { return(new BadRequestObjectResult(ex)); } }
private static async Task HardDeleteWithUnitOfWorkAsync <TEntity>( IBasicRepository <TEntity> repository, TEntity entity, bool autoSave, CancellationToken cancellationToken, IUnitOfWork currentUow ) where TEntity : class, IEntity, ISoftDelete { var hardDeleteEntities = (HashSet <IEntity>)currentUow.Items.GetOrAdd( UnitOfWorkItemNames.HardDeletedEntities, () => new HashSet <IEntity>() ); hardDeleteEntities.Add(entity); await repository.DeleteAsync(entity, autoSave, cancellationToken); }