Ejemplo n.º 1
0
        public ActionResult Index(string lang)
        {
            SinglePage model = new SinglePage();

            ISlidersRepository slidersRepository = DependencyResolver.Current.GetService <ISlidersRepository>();

            model.Sliders = slidersRepository.GetList().ToList();

            IArticleRepository articleRepository = DependencyResolver.Current.GetService <IArticleRepository>();

            model.About = articleRepository.GetList().Where(x => x.ArticleCategory == ArticleCategory.About).ToList();

            IProductCategoriesRepository productCategoryRepository = DependencyResolver.Current.GetService <IProductCategoriesRepository>();

            model.ProductCategories = productCategoryRepository.GetList().Take(3).ToList();

            IPortfoliosRepository portfolioRepository = DependencyResolver.Current.GetService <IPortfoliosRepository>();

            model.Portfolios = portfolioRepository.GetList().Take(5).ToList();

            IContactsRepository contactRepository = DependencyResolver.Current.GetService <IContactsRepository>();

            model.Contacts = contactRepository.GetList().ToList();

            return(View(model));
        }
Ejemplo n.º 2
0
        public virtual JsonResult GetEntityList(string table, string field)
        {
            Table t = (Table)Enum.Parse(typeof(Table), table);
            Field f = (Field)Enum.Parse(typeof(Field), field);

            if (t == Table.Articles)
            {
                IArticleRepository repository = DependencyResolver.Current.GetService <IArticleRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
                if (f == Field.Description)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, Name = x.Description }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Certificates)
            {
                ICertificatesRepository repository = DependencyResolver.Current.GetService <ICertificatesRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Contacts)
            {
                IContactsRepository repository = DependencyResolver.Current.GetService <IContactsRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
                if (f == Field.Description)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, Name = x.Description }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Images)
            {
                IImagesRepository repository = DependencyResolver.Current.GetService <IImagesRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Languages)
            {
                ILanguagesRepository repository = DependencyResolver.Current.GetService <ILanguagesRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.PortfolioDetails)
            {
                IPortfolioDetailsRepository repository = DependencyResolver.Current.GetService <IPortfolioDetailsRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Portfolios)
            {
                IPortfoliosRepository repository = DependencyResolver.Current.GetService <IPortfoliosRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
                if (f == Field.Description)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, Name = x.Description }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.ProductCategories)
            {
                IProductCategoriesRepository repository = DependencyResolver.Current.GetService <IProductCategoriesRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
                if (f == Field.Description)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, Name = x.Description }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Products)
            {
                IProductsRepository repository = DependencyResolver.Current.GetService <IProductsRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
                if (f == Field.Description)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, Name = x.Description }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Quotes)
            {
                IQuotesRepository repository = DependencyResolver.Current.GetService <IQuotesRepository>();
                if (f == Field.Description)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, Name = x.Description }), JsonRequestBehavior.AllowGet));
                }
            }
            if (t == Table.Sliders)
            {
                ISlidersRepository repository = DependencyResolver.Current.GetService <ISlidersRepository>();
                if (f == Field.Name)
                {
                    return(Json(repository.GetList().Select(x => new { x.Id, x.Name }), JsonRequestBehavior.AllowGet));
                }
            }

            return(Json("", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public static List <Portfolio> GetPortfolios()
        {
            IPortfoliosRepository repository = DependencyResolver.Current.GetService <IPortfoliosRepository>();

            return(repository.GetList().ToList());
        }