public IEnumerable <TCatalog> GetCatalogValues <TCatalog>() where TCatalog : CatalogBase, new()
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.CatalogsRepository <TCatalog>().GetAll());
     }
 }
 public TCatalog GetCatalogValue <TCatalog>(int catalogValueId) where TCatalog : CatalogBase, new()
 {
     using (var repositoriesContainer = new InnostarRepositoriesContainer())
     {
         return(repositoriesContainer.CatalogsRepository <TCatalog>().GetBy(new Query <TCatalog>(e => e.Id == catalogValueId)));
     }
 }
        public TCatalog SaveCatalogValue <TCatalog>(TCatalog catalog) where TCatalog : CatalogBase, new()
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                repositoriesContainer.CatalogsRepository <TCatalog>().Save(catalog);
                repositoriesContainer.ApplyChanges();
            }

            return(catalog);
        }
        public bool TryReorderCatalogValues <TCatalog>(int catalogValueId, int orderDirection) where TCatalog : CatalogBase, new()
        {
            using (var repositoriesContainer = new InnostarRepositoriesContainer())
            {
                var catalog       = repositoriesContainer.CatalogsRepository <TCatalog>().GetCatalogValue(catalogValueId);
                var catalogValues = repositoriesContainer.CatalogsRepository <TCatalog>().GetCatalogValues();

                OrderableModel neighbor;
                var            isSuccessFully = false;

                if (catalog.TryReOrder(catalogValues, out neighbor, orderDirection))
                {
                    repositoriesContainer.CatalogsRepository <TCatalog>().Save((TCatalog)neighbor);
                    repositoriesContainer.CatalogsRepository <TCatalog>().Save((TCatalog)catalog);
                    repositoriesContainer.ApplyChanges();

                    isSuccessFully = true;
                }

                return(isSuccessFully);
            }
        }
        public void DeleteCatalog <TCatalog>(int catalogValueId) where TCatalog : CatalogBase, new()
        {
            ProcessMethod(() =>
            {
                using (var repositoriesContainer = new InnostarRepositoriesContainer())
                {
                    repositoriesContainer.CatalogsRepository <TCatalog>().Delete(new TCatalog
                    {
                        Id = catalogValueId
                    });

                    repositoriesContainer.ApplyChanges();
                }
            });
        }