...
Code Block | ||
---|---|---|
| ||
@section scripts { <script> 'use strict'; $(document).ready(function () { // following section use to highlight border surronding to star container $('.star-rating__input').focus(function () { $(this).closest('.ratingContainer').addClass('ratingContainerFocus'); }); $('.star-rating__input').blur(function () { $(this).closest('.ratingContainer').removeClass('ratingContainerFocus'); }); }); </script> } |
1.1.1 Adding Outage the Notices menu
Under Views -> MainNavigation, open Index.cshtml.
...
Code Block | ||
---|---|---|
| ||
public ActionResult Index() { var vm = new MainNavigationBarViewModel { HomePageUrl = GetHomePageUrl().ToString(), ServicePageUrl = GetServicesPageUrl().ToString(), ServiceRequestsPageUrl = GetServiceRequestPageUrl().ToString(), NoticesPageUrl = GetNoticesPageUrl().ToString() }; return View(vm); } |
Outage Notice View Models
Add the two view modelsDisplay notices on service website
Add the code to retrieve notices of the user and load it to the view
Code Block | ||
---|---|---|
| ||
public classList<int> OutageNoticeViewModelserviceIds {= List<int> serviceIds = public string Header { get; set; } public string Text { get; set; } public IEnumerable<string> AffectedServices { get; set; } } public class OutageNoticesViewModel { public List<OutageNoticeViewModel> OutageNotices { get; set; } public ServiceMenuBarViewModel ServiceTitleBar { get; set; } } |
Create a new view.
Code Block | ||
---|---|---|
| ||
@model Models.OutageNoticesViewModel
@section ServiceTitleBar
{
@Html.Partial("_ServiceTitleBar", Model.ServiceTitleBar)
}
<div class="container">
<div class="row">
<h2>@Html.Raw(Resource.UpcomingOutages)</h2>
<p>@Html.Raw(Resource.TechnicalSupport)</p>
<hr style="border: #AF3C43 1px solid;" />
@if (Model.OutageNotices.Any())
{
<p>@Html.Raw(Resource.PlannedOutages)</p>
foreach (var m in Model.OutageNotices)
{
<section class="alert alert-warning">
<div>
<h3>@Html.Raw(m.Header)</h3>
<p>@Html.Raw(m.Body)</p>
<h4>@Resource.AffectedServices</h4>
<ul>
@foreach (var service in m.AffectedServices)
{
<li>@service</li>
}
</ul>
</div>
</section>
}
}
else
{
<p>@Html.Raw(Resource.NoOutages)</p>
}
</div>
</div> |
OutageNoticeController
Create a new controller called OutageNoticeController.
Add the following code.
Code Block | ||
---|---|---|
| ||
[UrlRouteController(Name = "OutageNoticeControllerRoute")] public class OutageNoticeController : PortalBaseController { private readonly IOutageNoticeManager _outageNoticeManager; private readonly IServiceCatalog _serviceCatalog; // GET: Notices public OutageNoticeController(IUserManager userManager, ILogger<OutageNoticeController> logger, ICache cache, IServiceSettingManager serviceSettingManager, IOutageNoticeManager outageNoticeManager, IServiceCatalog serviceCatalog) : base(userManager, logger, cache, serviceSettingManager) { _outageNoticeManager = outageNoticeManager; _serviceCatalog = serviceCatalog; } [UrlRouteEng(Path = "Notices")] [UrlRouteFra(Path = "Avis")] public async Task<ActionResult> Index() { var userOutageNotices = await _outageNoticeManager.GetByUserId(CurrentUser.Id); var services = await _serviceCatalog.GetAll(); var outageNotices = userOutageNotices.Select(outageNotice => new { ServiceNames = services.Where(serviceInfo => outageNotice.Services.Any(serviceId => serviceId == serviceInfo.Id)), Header = Utility.IsEnglish() ? outageNotice.EnglishHeaderText : outageNotice.FrenchHeaderText, Body = Utility.IsEnglish() ? outageNotice.EnglishBodyText : outageNotice.FrenchBodyText }) .Select(service => new OutageNoticeViewModel { Body = service.Body, Header = service.Header, AffectedServices = service.ServiceNames.Select(serviceInfo => Utility.IsEnglish() ? serviceInfo.FriendlyNameEn : serviceInfo.FriendlyNameFr) }); var viewModel = new OutageNoticesViewModel { ServiceTitleBar = CreateServiceTitleButtons(Resources.Resource.Notices, "bell"), OutageNotices = outageNotices }; return View(viewModel); } } new List<int>{ <user's service id>, 6 }; //6: MyTC Account //Get notices of the services var userNotices = await _noticeManager.GetByServiceId(serviceIds); |
Load it to view
Example:
...
1.1.1 Application user properties
...