/// <summary> /// Maps the message data from service. /// </summary> /// <param name="message">The message.</param> /// <returns>Message data</returns> private static Entities.AlertType MapMessageDataFromService(Message message) { Entities.AlertType messageData = null; if (message != null) { messageData = new Entities.AlertType { AddedBy = message.AddedBy, AddedDate = message.AddedDate.GetValueOrDefault(), Description = message.Description, DueDate = message.DueDate, ExpiryDate = message.ExpiryDate, MessageFrom = message.MessageFrom, AlertTypeId = message.MessageId, IsTemplate = false, IsMessage = true, IsSoundEnable = message.IsSoundEnable }; foreach (var personMessage in message.PersonMessages) { var personMessageData = new Entities.Alert { AlertTypeId = personMessage.MessageId, PersonId = personMessage.PersonId, PersonTypeId = personMessage.PersonTypeId, ShipId = personMessage.ShipId, StatusId = personMessage.StatusId, VoyageId = personMessage.VoyageId, PersonAlertId = personMessage.PersonMessageId }; messageData.Alerts.Add(personMessageData); } } return messageData; }
/// <summary> /// Maps the alert data from service. /// </summary> /// <param name="alert">The alert.</param> /// <returns>Alert data</returns> private static Entities.AlertType MapAlertDataFromService(Entities.PersonNotification.Alert alert) { Entities.AlertType alertData = null; if (alert != null) { alertData = new Entities.AlertType { AddedBy = alert.AddedBy, AddedDate = alert.AddedDate, AlertTypeId = alert.AlertId, IsTemplate = false, IsMessage = false, TypeId = alert.AlertTypeId, Description = alert.Description, DueDate = alert.DueDate, ExpiryDate = alert.ExpiryDate, IsOverride = alert.IsOverride, IsSoundEnable = alert.IsSoundEnable, ModifiedBy = alert.LastModifiedBy, DepartmentId = alert.DepartmentId }; if (alert.PersonAlerts != null) { foreach (var personAlert in alert.PersonAlerts) { var personAlertsData = new Entities.Alert { AlertTypeId = personAlert.AlertId, PersonId = personAlert.PersonId, PersonTypeId = personAlert.PersonTypeId, ShipId = personAlert.ShipId, StatusId = personAlert.StatusId, VoyageId = personAlert.VoyageId, PersonAlertId = personAlert.PersonAlertId }; alertData.Alerts.Add(personAlertsData); } } } return alertData; }
/// <summary> /// Maps the alert data from database. /// </summary> /// <param name="alertData">The alert data.</param> /// <returns> /// Alert type list /// </returns> private static ListResult<Entities.AlertType> MapAlertDataListFromService(ListResult<Entities.PersonNotification.Alert> alertData) { var result = new ListResult<Entities.AlertType>(); var alerts = new AlertTypeCollection(); foreach (var alert in alertData.Items) { Entities.AlertType alertTypeData = new Entities.AlertType(); alertTypeData.AlertTypeId = alert.AlertId; alertTypeData.AddedBy = alert.AddedBy; alertTypeData.AddedDate = alert.AddedDate; alertTypeData.Description = alert.Description; alertTypeData.DueDate = alert.DueDate; alertTypeData.ExpiryDate = alert.ExpiryDate; alertTypeData.IsOverride = alert.IsOverride; alertTypeData.IsSoundEnable = alert.IsSoundEnable; alertTypeData.ModifiedBy = alert.LastModifiedBy; alertTypeData.IsMessage = false; alertTypeData.IsTemplate = false; alertTypeData.DepartmentId = alert.DepartmentId; foreach (var applicationIds in alert.AlertTargetApplications) { alertTypeData.ApplicationId = applicationIds.ApplicationId; } alertTypeData.TypeId = alert.AlertTypeId; foreach (var personAlerts in alert.PersonAlerts) { Entities.Alert personAlert = new Entities.Alert(); personAlert.PersonId = personAlerts.PersonId; personAlert.PersonTypeId = personAlerts.PersonTypeId; personAlert.ShipId = personAlerts.ShipId; personAlert.VoyageId = personAlerts.VoyageId; personAlert.StatusId = personAlerts.StatusId; personAlert.AlertTypeId = personAlerts.AlertId; personAlert.PersonAlertId = personAlerts.PersonAlertId; alertTypeData.Alerts.Add(personAlert); } alerts.Add(alertTypeData); } result.AssignItems(alerts); return result; }
/// <summary> /// Maps the message data from service. /// </summary> /// <param name="messageData">The message data.</param> /// <returns>Alert type list</returns> private static ListResult<Entities.AlertType> MapMessageDataListFromService(ListResult<Message> messageData) { var result = new ListResult<Entities.AlertType>(); var messages = new AlertTypeCollection(); foreach (var message in messageData.Items) { var messagesData = new Entities.AlertType(); messagesData.AddedBy = message.AddedBy; messagesData.AddedDate = message.AddedDate.GetValueOrDefault(); messagesData.Description = message.Description; messagesData.DueDate = message.DueDate; messagesData.ExpiryDate = message.ExpiryDate; messagesData.ModifiedBy = message.LastModifiedBy; messagesData.AlertTypeId = message.MessageId; messagesData.MessageFrom = message.MessageFrom; messagesData.IsMessage = true; messagesData.IsTemplate = false; messagesData.IsSoundEnable = message.IsSoundEnable; foreach (var personMessages in message.PersonMessages) { var personMessage = new Entities.Alert(); personMessage.PersonId = personMessages.PersonId; personMessage.PersonTypeId = personMessages.PersonTypeId; personMessage.ShipId = personMessages.ShipId; personMessage.VoyageId = personMessages.VoyageId; personMessage.StatusId = personMessages.StatusId; personMessage.AlertTypeId = personMessages.MessageId; personMessage.PersonAlertId = personMessages.PersonMessageId; messagesData.Alerts.Add(personMessage); } messages.Add(messagesData); } result.AssignItems(messages); return result; }
/// <summary> /// Maps the message data list. /// </summary> /// <param name="messageData">The list result.</param> /// <param name="alerts">The alerts.</param> /// <returns>alert and messages data</returns> private static ListResult<Entities.AlertType> MapMessageDataList(ListResult<Message> messageData, ListResult<Entities.AlertType> alerts) { foreach (var message in messageData.Items) { var messagesData = new Entities.AlertType(); messagesData.AddedBy = message.AddedBy; messagesData.AddedDate = message.AddedDate.GetValueOrDefault(); messagesData.Description = message.Description; messagesData.DueDate = message.DueDate; messagesData.ExpiryDate = message.ExpiryDate; messagesData.ModifiedBy = message.LastModifiedBy; messagesData.AlertTypeId = message.MessageId; messagesData.MessageFrom = message.MessageFrom; messagesData.IsMessage = true; messagesData.IsTemplate = false; messagesData.IsSoundEnable = message.IsSoundEnable; foreach (var personMessages in message.PersonMessages) { var personMessage = new Entities.Alert(); personMessage.PersonId = personMessages.PersonId; personMessage.PersonTypeId = personMessages.PersonTypeId; personMessage.ShipId = personMessages.ShipId; personMessage.VoyageId = personMessages.VoyageId; personMessage.StatusId = personMessages.StatusId; personMessage.AlertTypeId = personMessages.MessageId; personMessage.PersonAlertId = personMessages.PersonMessageId; messagesData.Alerts.Add(personMessage); } alerts.Items.Add(messagesData); } return alerts; }