public virtual IQueryable <TModel> GetAll(FilterParameters filter = null)
        {
            var entities = (filter == null || filter.PageNumber == default || filter.PageSize == default) ?
                           DbSet : DbSet.Skip((filter.PageNumber - 1) * filter.PageSize)
                           .Take(filter.PageSize);
            var models = Сonverter.ConvertTo(entities);

            return(models.AsQueryable());
        }
        public virtual IEnumerable <TModel> Create(IEnumerable <TModel> models)
        {
            var createdModels = new List <TModel>();

            foreach (var model in models)
            {
                var foundEntity = DbSet.Find(model.Id);

                if (foundEntity == null)
                {
                    var entity        = Сonverter.ConvertFrom(model);
                    var createdEntity = DbSet.Add(entity);
                    var createdModel  = Сonverter.ConvertTo(createdEntity.Entity);
                    createdModels.Add(createdModel);
                }
            }

            return(createdModels);
        }
        public override IEnumerable <ProductModel> Create(IEnumerable <ProductModel> models)
        {
            var createdModels = new List <ProductModel>();

            foreach (var model in models)
            {
                var foundProduct = DbSet.FirstOrDefault(p => p.Name == model.Name);

                if (foundProduct == null)
                {
                    var productEntity  = UpdateProductCategories(model);
                    var createdProduct = DbSet.Add(productEntity);
                    var createdModel   = Сonverter.ConvertTo(createdProduct.Entity);
                    createdModels.Add(createdModel);
                }
            }

            return(createdModels);
        }
        public virtual TModel GetById(TId id)
        {
            var entity = DbSet.FirstOrDefault(entity => entity.Id.Equals(id));

            return(Сonverter.ConvertTo(entity));
        }