Esempio n. 1
0
        public ActionResult LatestImageGalleryPerYear()
        {
            Sitecore.Data.Items.Item             datasourceItem = RenderingContext.Current.Rendering.Item;
            Sitecore.Data.Fields.DatasourceField dsf            = datasourceItem.Fields[Sitecore.Feature.Library.Templates.LatestGalleryPerYearMBM.Fields.DataSource];

            string _Year = datasourceItem.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year] != null ? datasourceItem.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year].ToString() : "2019";
            PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>();

            try
            {
                IEnumerable <Data.Items.Item> items = this.Repository.GetGallery(dsf.TargetItem).Where(x => x.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year] != null && x.Fields[Sitecore.Feature.Library.Templates.BaseField.Fields._year].Value == _Year);

                if (items != null && items.Count() > 0)
                {
                    listItems.Data = items.Take(4);
                }
                listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID;
            }
            catch (Exception ex)
            {
                return(ErrorWebservice(new JavaScriptSerializer().Serialize(new ReturnErrorData
                {
                    responseCode = "550",
                    descErrorCode = ex.Message.ToString()
                })));
            }

            return(View("~/Views/MBM/MBMLatestImagePerYear.cshtml", listItems));
        }
Esempio n. 2
0
        public ActionResult LatestNews()
        {
            PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>();

            try
            {
                Sitecore.Data.Items.Item             datasourceItem = RenderingContext.Current.Rendering.Item;
                Sitecore.Data.Fields.DatasourceField dsf            = datasourceItem.Fields[Sitecore.Feature.Library.Templates.LatestArticleMBM.Fields.DataSource];

                IEnumerable <Data.Items.Item> items = this.Repository.GetArticle(dsf.TargetItem);

                if (items != null && items.Count() > 0)
                {
                    listItems.Data = items.Take(3);
                }
                listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID;
            }
            catch (Exception ex)
            {
                return(ErrorWebservice(new JavaScriptSerializer().Serialize(new ReturnErrorData
                {
                    responseCode = "550",
                    descErrorCode = ex.Message.ToString()
                })));
            }

            return(View("~/Views/MBM/MBMLatestArticle.cshtml", listItems));
        }
Esempio n. 3
0
        public ActionResult LatestNews()
        {
            PagedData <Data.Items.Item> listItems = new PagedData <Data.Items.Item>();

            try
            {
                Sitecore.Data.Items.Item             datasourceItem = RenderingContext.Current.Rendering.Item;
                Sitecore.Data.Fields.DatasourceField dsf            = datasourceItem.Fields[Sitecore.Feature.Library.Templates.LatestArticleMBM.Fields.DataSource];

                IEnumerable <Data.Items.Item> items = this.Repository.GetArticle(dsf.TargetItem);

                if (items != null && items.Count() > 0)
                {
                    listItems.Data = items.Take(3);
                }
                listItems.DataSourceID = RenderingContext.Current.Rendering.Item.ID;
            }
            catch (Exception) { }

            return(View("~/Views/MBM/MBMLatestArticle.cshtml", listItems));
        }