Created
July 12, 2016 16:08
-
-
Save ivaneftimov/41b385db3353960b201cf514ad48c4cf to your computer and use it in GitHub Desktop.
Resource class for the BreakingNews widget
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SitefinityWebapp\Mvc\Controllers\BreakingNewsController.cs | |
| using SitefinityWebApp.Localization; | |
| using SitefinityWebApp.Mvc.Models; | |
| using SitefinityWebApp.Wrappers; | |
| using System.Linq; | |
| using System.Web.Mvc; | |
| using Telerik.Sitefinity.Frontend.Mvc.Infrastructure.Controllers.Attributes; | |
| using Telerik.Sitefinity.Modules.News; | |
| using Telerik.Sitefinity.Mvc; | |
| namespace SitefinityWebApp.Mvc.Controllers | |
| { | |
| [Localization(typeof(BreakingNewsResources))] | |
| [ControllerToolboxItem(Title = "Breaking News", Name = "BreakingNews", SectionName = "CustomMvcWidgets")] | |
| public class BreakingNewsController : Controller | |
| { | |
| public BreakingNewsController(INewsManagerWrapper newsManager) | |
| { | |
| this.newsManager = newsManager.GetManager(); | |
| } | |
| public string Date { get; set; } | |
| public string Message { get; set; } | |
| public string BreakingNewsMessage { get; set; } | |
| public string SelectedItem { get; set; } | |
| public ActionResult Index() | |
| { | |
| var firstNewsItem = this.newsManager.GetNewsItems().FirstOrDefault(); | |
| BreakingNewsModel model = new BreakingNewsModel(); | |
| model.Message = firstNewsItem.Title; | |
| return View(model); | |
| } | |
| private NewsManager newsManager; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SitefinityWebApp\Localization\BreakingNewsResources.cs | |
| using Telerik.Sitefinity.Localization; | |
| namespace SitefinityWebApp.Localization | |
| { | |
| public class BreakingNewsResources : Resource | |
| { | |
| [ResourceEntry("StaticMessage", Value = "This is the static message", Description = "Static message on the BreakingNews view.", LastModified = "2016/07/12")] | |
| public string StaticMessage { get; set; } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @* SitefinityWebapp\Mvc\Views\BreakingNews\Index.cshtml *@ | |
| @model SitefinityWebApp.Mvc.Models.BreakingNewsModel | |
| @using Telerik.Sitefinity.Frontend.Mvc.Helpers | |
| <p> | |
| @Html.Resource("StaticMessage") | |
| </p> | |
| <marquee> | |
| @Html.Raw(Model.Message) | |
| </marquee> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment