/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="alertTypeId">The alertType identifier.</param> /// <param name="alert">The alert.</param> /// <returns> /// Task containing nothing /// </returns> public async Task UpdateAsync(string alertTypeId, Alert alert) { var alertTypes = new Entities.AlertTypeCollection(); alert.AlertId = alertTypeId; alertTypes.Add(AlertMapper.MapAlertDetails(alert)); await this.alertRepository.UpdateAsync(alertTypeId, alertTypes); }
/// <summary> /// Retrieves the person alerts. /// </summary> /// <param name="personSearchParameter">The person search parameter.</param> /// <param name="personIds">The person ids.</param> /// <returns> /// The alerts. /// </returns> private async Task<ListResult<Entities.AlertType>> RetrievePersonAlerts(PersonSearchParameter personSearchParameter, string personIds) { var isMessage = false; var isAlert = false; if (personSearchParameter.IsMessageCount != null && Convert.ToBoolean(personSearchParameter.IsMessageCount, CultureInfo.CurrentCulture)) { isMessage = true; } if (personSearchParameter.IsAlertCount != null && Convert.ToBoolean(personSearchParameter.IsAlertCount, CultureInfo.CurrentCulture)) { isAlert = true; } var alertSearchParameter = new AlertListRequestSearchParameters { ApplicationId = Convert.ToString(this.applicationSettings.ApplicationId, CultureInfo.CurrentCulture), PersonIds = personIds, IsMessage = isMessage, IsAlert = isAlert, IsExpiredAlert = false }; if (string.IsNullOrWhiteSpace(personSearchParameter.ShipTime)) { var shipTimeTask = await this.shipTimeRepository.GetByIdAsync(this.applicationSettings.ShipId, null); alertSearchParameter.ShipTime = string.IsNullOrWhiteSpace(shipTimeTask) ? DateTime.Now : DateTime.UtcNow.AddMinutes(Convert.ToDouble(shipTimeTask)); } else { alertSearchParameter.ShipTime = DateTime.Parse(personSearchParameter.ShipTime, CultureInfo.InvariantCulture); } var result = new ListResult<Entities.AlertType>(); var alertTemplate = new Entities.AlertTypeCollection(); var alertDetails = await this.RetrieveAlertDetails(alertSearchParameter); foreach (var alert in alertDetails.Items) { if ((alert.ExpiryDate.HasValue && alert.ExpiryDate.Value > alertSearchParameter.ShipTime) || !alert.ExpiryDate.HasValue) { var active = alert.Alerts.Any(personAlert => personAlert.StatusId == "1"); if (active) { alertTemplate.Add(alert); } } } result.AssignItems(alertTemplate); return result; }
/// <summary> /// Create new alert /// </summary> /// <param name="alert">alert details</param> /// <returns> /// Task containing id for the created alert /// </returns> public async Task<string> CreateAsync(Alert alert) { var objAlertTypes = new Entities.AlertTypeCollection(); objAlertTypes.Add(AlertMapper.MapAlertDetails(alert)); return await this.alertRepository.CreateAsync(objAlertTypes); }