示例#1
0
        public static async Task <Result> CheckExistence <TEntity>(
            this IReadonlyRepository <TEntity> repository, int id) where TEntity : BaseEntity
        {
            var isEntityExists = await repository.AnyAsync(entity => entity.Id == id);

            if (!isEntityExists)
            {
                return(Result.Fail($"Entity {typeof(TEntity)} with id {id} wasn't found"));
            }

            return(Result.Ok());
        }