Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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>

...

Figure 3.4‑13 -  Add to view 

...

In your view model add the following property:

...

b)    Above partial view renders 5 Star Rating Bar in your Survey Feedback, as shown below:

 

The default state

Mouse Over State

Image ModifiedImage Modified

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
languagec#
@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
languagec#
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 modelsthe code to retrieve notices of the user.

Code Block
languagec#
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
languagehtml
@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
languagec#
[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

...

All files are scanned for viruses using the OSWAT MetaDefender version 45.1.2. For more information see this document.

...