...
Code Block |
---|
<appSettings> <add key="MtoaWebServiceUrl" value="https://wwwappstest.tc.gc.ca****/Saf-Sec-Sur/13/MTAPI-PLATFORM-TEST/api/" /> <add key="MtoaWebServiceApiKey" value="--- YOUR API KEY ---" /> <add key="MtoaWebServiceJwt" value="--- YOUR JWT ---" /> </appSettings> |
...
Code Block | ||
---|---|---|
| ||
@model RTMR.Web.Portal.Models.ServiceTitleBarViewModel <header> <h2 class="app-name-submenu"><img src="~/Content/Images/file.svg" class="iconImg" alt="" /> @Model.Title</h2> </header> @if (Model.TitleBarButtons!=null &&Model.TitleBarButtons.Any()) { <hr class="home-hr" /> <div class="row"> @foreach (var menuBar in Model.TitleBarButtons) { <div class="col-md-4"> <a href="@menuBar.Link" class="@Html.Raw(menuBar.IsPrimary ? "btn btn-primary" : "btn btn-default active") btn-lg btn-block">@menuBar.Text</a> </div> } </div> } |
...
Add to view
Inside your view add the following line:
...
In your view model add the following property:
Code Block | ||
---|---|---|
| ||
public ServiceTitleBarViewModel ServiceTitleBar { get; set; } |
...
Inside your controller you can set the view models ServiceTitleBar property to set the Title, TitleBarButtons with associated text and links.
...
Figure 3.4‑13 - Add to view
...
In your view model add the following property:
Code Block | ||
---|---|---|
| ||
public WizardViewModel Wizard |
...
Add WizardStepState
In your Models folder add an Enum called WizardStepState.
Code Block | ||
---|---|---|
| ||
public enum WizardStepState {
NotAccessed,
Completed,
Incomplete,
InProgress,
Inapplicable,
Summary
}
|
Add WizardStepViewModel
In your Models folder add a new view model called WizardStepViewModel.
...
b) Above partial view renders 5 Star Rating Bar in your Survey Feedback, as shown below:
The default state | Mouse Over State |
In your controller create a POST action
...
At present partial-view (_ratings.cshtml) mentioned above, expects a “Resource” file, however as per your need you may copy following resource strings to different CSS file, in that case make sure to change above mentioned partial-view to use resource file of your choice.
Resource.resx |
... Stars {0} Stars OneStar 1 Star ... |
French Translation for tooltip:
Resource. fr-CA.resx |
... Stars {0} Étoiles OneStar 1 Étoile ... |
In case you want to get the feedback in a middle of your view you only need following
...
Code Block |
---|
@Html.Partial("_rating", new string[] {"rating", Model.Rating.ToString()}) |
...
If you want a feedback in a Dialog then inside your view add the following
...
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 ModelsDisplay notices on service website
Add the two view modelscode to retrieve notices of the user.
Code Block | ||
---|---|---|
| ||
public classList<int> OutageNoticeViewModelserviceIds {= List<int> serviceIds = new List<int>{ <user's service publicid>, 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); } } 6 }; //6: MyTC Account //Get notices of the services var userNotices = await _noticeManager.GetByServiceId(serviceIds); |
Modify the view to load the notices
Example:
...
1.1.1 Application user properties
...
1.1.3.1 Business Object
Invoice
Property | Description |
public int Id { get; set; } | Invoice id. |
public int ServiceRequestId { get; set; } | Service request id associated to the invoice. |
public string Number { set; get; } | Number associated to the invoice. |
public string PaymentReferenceNumber { get; set; } | Payment reference number associated to the invoice. |
public decimal? Amount { get; set; } | Amount for the invoice. |
public DateTime? Date { get; set; } | Date of the invoice. |
1.1.3.2 Manager
InvoiceManager
Property | Description |
Task<Invoice> Add(Invoice invoice); | Adds a new invoice. |
Task<Invoice> Update(Invoice invoice); | Updates an existing invoice. |
Task<ICollection<Invoice>> GetByServiceRequest(int serviceRequestId); | Searches invoices based on a service request id. |
Task<Invoice> GetByNumber(string number); | Searches for an invoice based on a number. |
Task<Invoice> GetByPaymentReference(string reference); | Searches for an invoice based on payment reference number. |
...
1.1.3.3 InvoiceManager.Add(Invoice) Method
...
Used to get or set the values of a file attachment.
Property | Description |
public int Id { get; set; } | File attachment id. |
public int ServiceRequestId { get; set; } | Service request id associated to the attachment. |
public string Name { get; set; } | File attachment name. |
public string Content Type { get; set; } | File content type (example “image/jpeg”). |
public int? Size { get; set; } | File attachment size. |
Public byte[] Data {get; set;} | File data. |
1.1.4.2 FileAttachmentManager.Upload(FileAttachment) Method
Uploads a new file attachment to the database.
Code Block | ||
---|---|---|
| ||
public async Task<FileAttachment> Upload(FileAttachment fileAttachment) |
How to create a new file attachment. The file attachment id isn’t required, since it gets generated automatically.const int serviceRequestId = 41;
const string contentType =
Code Block | ||
---|---|---|
| ||
const int serviceRequestId = 41; const string contentType = "image/jpeg"; |
...
byte[] |
...
bytes = byte array const string filename = "images.jpg"; |
...
{
...
var fileAttachment = new FileAttachment { ContentType = contentType, Data = bytes, Name = filename, ServiceRequestId = serviceRequestId, Size = bytes.Length }; var newAttachment = await _attachmentManager.Upload(fileAttachment); |
1.1.4.3 Parameters
FileAttachment (FileAttachment)
Business object used to get/set the values.
...
In this example a file attachment is removed by using its id. The id must be valid.
Code Block | ||
---|---|---|
| ||
await MtoaApi.FileAttachmentApi.Remove(newAttachment.Id); |
1.1.4.15 Parameters
Id (int)
The service request id.
...
All files are scanned for viruses using the OSWAT MetaDefender version 45.1.2. For more information see this document.
...