Exemple #1
0
        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));
            }
        }
Exemple #2
0
        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);
        }