public Category GetOne(Guid id)
    {
        CustomValidator.ValidateId(id);
        var exists = Exists(id);

        if (exists)
        {
            var categoryDbModel = _context.Categories.Find(id);
            return(_categoryMapper.DbToDomain(categoryDbModel));
        }

        return(null);
    }
        public async Task <IReadOnlyCollection <Category> > GetAll()
        {
            await using var context = new MyDbContext(_options);
            _categoryMapper         = new CategoryMapper(context);
            var categoryDbModels = await context.Categories.ToListAsync();

            var categories =
                (from categoryDbModel in categoryDbModels select _categoryMapper.DbToDomain(categoryDbModel))
                .ToList();

            return(categories.AsReadOnly());
        }
        public async Task <Category> GetOne(Guid id)
        {
            CustomValidator.ValidateId(id);
            await using var context = new MyDbContext(_options);
            _categoryMapper         = new CategoryMapper(context);
            if (Exists(id))
            {
                var categoryDbModel = await context.Categories.FindAsync(id);

                return(_categoryMapper.DbToDomain(categoryDbModel));
            }

            return(null);
        }