Beispiel #1
0
 private AlertViewModel GetAlertViewModel(AlertType?alertType)
 {
     return(new AlertViewModel
     {
         Alerts = alertType != null?alertManager.Get((AlertType)alertType) : alertManager.Get()
     });
 }
 /// NOTE: if the alert has a category you must pass the category for this to work
 /// properly as a key. I.e. if the alert has a category and you pass only the ID, and you
 /// compare this to another AlertKey that has both the category and the same ID, it will not consider them equal.
 public AlertKey(AlertType?alertType, AlertCategory?alertCategory)
 {
     // if there is a category, ignore the alerttype.
     if (alertCategory != null)
     {
         _alertCategory = alertCategory;
         _alertType     = null;
     }
     else
     {
         _alertCategory = null;
         _alertType     = alertType;
     }
 }
Beispiel #3
0
        /// <summary>
        /// Update an alert.
        /// </summary>
        /// <param name="alertId">The alert identifier.</param>
        /// <param name="type">The type.</param>
        /// <param name="emailTo">The email to.</param>
        /// <param name="frequency">The frequency.</param>
        /// <param name="percentage">The percentage.</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns>
        /// The <see cref="Alert" />.
        /// </returns>
        public async Task <Alert> UpdateAsync(long alertId, AlertType?type, string emailTo = null, Frequency?frequency = null, int?percentage = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            var endpoint = string.Format("{0}/{1}", _endpoint, alertId);
            var data     = CreateJObjectForAlert(type, emailTo, frequency, percentage);
            var response = await _client.PatchAsync(endpoint, data, cancellationToken).ConfigureAwait(false);

            response.EnsureSuccess();

            var responseContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

            var alert = JObject.Parse(responseContent).ToObject <Alert>();

            return(alert);
        }
        public JsonResult SaveStatus(int id, int statusId, int?reason)
        {
            int franchiseId;

            try
            {
                using (var db = GetAuditedContext())
                {
                    var job = db.tbl_Job.Single(j => j.JobID == id);
                    franchiseId = job.FranchiseID;

                    job.StatusID       = statusId;
                    job.CancelReasonID = reason.GetValueOrDefault();
                    db.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                while (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }

                return(Json(new { Success = false, msg = "Error saving status: " + ex.Message }));
            }

            AlertType?type = null;

            switch (statusId)
            {
            case 10:
                type = AlertType.CallRescheduled;
                break;

            case 12:
                type = AlertType.CustomerCancellation;
                break;
            }

            if (type.HasValue)
            {
                AbstractBusinessService.Create <AlertEngine>(UserInfo.UserKey).SendAlert(type.Value, franchiseId);
            }

            return(Json(new { Success = true, msg = "Success" }));
        }
Beispiel #5
0
        private static JObject CreateJObjectForAlert(AlertType?type, string emailTo = null, Frequency?frequency = null, int?percentage = null)
        {
            var result = new JObject();

            if (type.HasValue)
            {
                result.Add("type", JToken.Parse(JsonConvert.SerializeObject(type)).ToString());
            }
            if (!string.IsNullOrEmpty(emailTo))
            {
                result.Add("email_to", emailTo);
            }
            if (frequency.HasValue)
            {
                result.Add("frequency", JToken.Parse(JsonConvert.SerializeObject(frequency)).ToString());
            }
            if (percentage.HasValue)
            {
                result.Add("percentage", percentage.Value);
            }
            return(result);
        }
        public static ICollection <Alert> GetAlerts(this TempDataDictionary tempData, AlertType?type = null)
        {
            if (!tempData.ContainsKey(AlertsKey))
            {
                tempData[AlertsKey] = new List <Alert>();
            }

            var alerts = (ICollection <Alert>)tempData[AlertsKey];

            if (type.HasValue)
            {
                alerts = alerts.Where(a => a.Type == type.Value).ToList();
            }

            return(alerts);
        }
Beispiel #7
0
 public AlertKey(AlertType?alertType, AlertCategory?alertCategory)
 {
     AlertCategory = alertCategory;
     AlertType     = alertType;
 }
 public void PopulateDefaultValues()
 {
     AlertType = Alert.AlertType.Error;
 }
Beispiel #9
0
 IList <MemberSearchAlert> ISearchAlertsRepository.GetMemberSearchAlerts(IEnumerable <Guid> memberSearchIds, AlertType?alertType)
 {
     using (var dc = CreateContext().AsReadOnly())
     {
         return(alertType.HasValue
             ? GetFilteredMemberSearchAlerts(dc, new SplitList <Guid>(memberSearchIds).ToString(), alertType.Value)
                .ToList()
             : GetMemberSearchAlertsSubset(dc, new SplitList <Guid>(memberSearchIds).ToString()).
                ToList());
     }
 }
Beispiel #10
0
 IList <MemberSearchAlert> IMemberSearchAlertsQuery.GetMemberSearchAlerts(IEnumerable <Guid> searchIds, AlertType?alertType)
 {
     return(_repository.GetMemberSearchAlerts(searchIds, alertType));
 }
Beispiel #11
0
 IList <MemberSearchAlert> IMemberSearchAlertsQuery.GetMemberSearchAlerts(Guid searchId, AlertType?alertType)
 {
     return(_repository.GetMemberSearchAlerts(new [] { searchId }, alertType));
 }
Beispiel #12
0
 public ActionResult List(AlertType?alertType)
 {
     return(PartialView(GetAlertViewModel(alertType)));
 }
Beispiel #13
0
 public ActionResult Index(AlertType?alertType)
 {
     return(View(GetAlertViewModel(alertType)));
 }