public virtual Result Delete(TDeleteDto dto, string deletedBy)
        {
            var bo = Mapper.Map <TEntity>(dto);

            Repository.Delete(bo, deletedBy);

            var result = UnitOfWork.Complete();

            if (result.IsFailure)
            {
                switch (result.ErrorType)
                {
                case ErrorType.ValidationFailed:
                    return(result);

                case ErrorType.NotFound:
                    return(result);

                case ErrorType.ConcurrencyConflict:
                    return(result);

                default:
                    throw new ArgumentException();
                }
            }

            if (HubContext != null)
            {
                HubContext.DeletedAsync(dto).Wait();
            }

            return(Result.Ok());
        }
        public virtual Result Delete(TDeleteDto dto, string deletedBy)
        {
            var bo     = Mapper.Map <TEntity>(dto);
            var result = DomainService.Delete(bo, deletedBy);

            if (result.IsFailure)
            {
                switch (result.ErrorType)
                {
                case ErrorType.ObjectValidationFailed:
                    return(result);

                case ErrorType.DatabaseValidationFailed:
                    return(result);

                case ErrorType.ObjectDoesNotExist:
                    return(result);

                case ErrorType.ConcurrencyConflict:
                    return(result);

                default:
                    throw new ArgumentException();
                }
            }

            if (HubContext != null)
            {
                HubContext.DeletedAsync(dto).Wait();
            }

            return(Result.Ok());
        }
        public virtual Result Delete(TDeleteDto dto, string deletedBy)
        {
            AuthorizeResourceOperationAsync(ResourceCollectionsCore.CRUD.Operations.Delete, ResourceCollectionsCore.CRUD.Operations.DeleteOwner).Wait();

            var bo = Mapper.Map <TEntity>(dto);

            AuthorizeResourceOperationAsync(bo, ResourceCollectionsCore.CRUD.Operations.Delete, ResourceCollectionsCore.CRUD.Operations.DeleteOwner).Wait();

            Repository.Delete(bo, deletedBy);

            var result = UnitOfWork.Complete();

            if (result.IsFailure)
            {
                switch (result.ErrorType)
                {
                case ErrorType.ObjectValidationFailed:
                    return(result);

                case ErrorType.DatabaseValidationFailed:
                    return(result);

                case ErrorType.ObjectDoesNotExist:
                    return(result);

                case ErrorType.ConcurrencyConflict:
                    return(result);

                default:
                    throw new ArgumentException();
                }
            }

            if (HubContext != null)
            {
                HubContext.DeletedAsync(dto).Wait();
            }

            return(Result.Ok());
        }