Esempio n. 1
0
        /// <summary>
        /// Converts a HighlightAlertDTO object to the icon portal HighlightAlert object
        /// </summary>
        /// <param name="dto">The HighlightAlertDTO object to convert</param>
        /// <returns>A populated HighlightAlert object</returns>
        public static HighlightAlert GetHighlightAlertFromDTO(HighlightAlertDTO dto)
        {
            HighlightAlert lHighlightAlert = new HighlightAlert();

            lHighlightAlert.DateSent              = Convert.ToDateTime(dto.timeStampUtc.ToString());
            lHighlightAlert.Folder                = dto.folder.ToString().Replace("?", ">>");
            lHighlightAlert.Location              = dto.locationName.ToString();
            lHighlightAlert.WatchName             = dto.watchName.ToString();
            lHighlightAlert.WatchTypeName         = dto.watchTypeName.ToString();
            lHighlightAlert.Problem               = dto.problem.ToString();
            lHighlightAlert.AlertSummary          = dto.alertSummary.ToString();
            lHighlightAlert.Description           = dto.stabilityIssueDescription.ToString();
            lHighlightAlert.ReferenceText         = dto.referenceText.ToString();
            lHighlightAlert.LinkUrl               = dto.linkUrl.ToString();
            lHighlightAlert.SiteLinksUp           = Convert.ToInt32(dto.siteLinksUp);
            lHighlightAlert.HasStabilityIssue     = Convert.ToBoolean(dto.hasStabilityIssue);
            lHighlightAlert.IsBroadbandSpeedAlert = Convert.ToBoolean(dto.isBroadbandSpeedAlert);
            lHighlightAlert.IsWirelessAccessPoint = Convert.ToBoolean(dto.isWirelessAccessPoint);

            return(lHighlightAlert);
        }
Esempio n. 2
0
 public ActionResult Post([FromBody] HighlightAlertDTO alertDTO)
 {
     logger.LogInformation("The Post call of the web hook controller");
     try {
         if (alertDTO != null)
         {
             HighlightAlert highlightAlert = DTOConvert.GetHighlightAlertFromDTO(alertDTO);
             logger.LogInformation("The Post call of the web hook controller contains alert: {alert}", JsonConvert.SerializeObject(highlightAlert));
             var id = _HighlightDB.CreateEmailAlert(highlightAlert);
             logger.LogInformation("Created new highlight alert with Id: {id}", id);
             return(StatusCode(204));
         }
         else
         {
             return(StatusCode(400));
         }
     }
     catch (System.Exception ex)
     {
         logger.LogCritical("The POST method of the web hook contoller produced the following error: {err}", ex.Message);
         throw ex;
     }
 }