/// <summary>
 /// Maps the visitors.
 /// </summary>
 /// <param name="visitor">The visitor.</param>
 /// <param name="alerts">The alerts.</param>
 /// <param name="personAlerts">The person alerts.</param>
 /// <param name="alertTypeList">The alert Type Master List.</param>
 internal static void MapVisitors(Visitor visitor, ListResult<DataAccess.Entities.Alert> alerts, ListResult<DataAccess.Entities.PersonAlert> personAlerts, ListResult<DataAccess.Entities.AlertType> alertTypeList)
 {
     var alertCollection = AlertMapper.MapCollection(alerts.Items, personAlerts.Items, visitor.VisitorId, alertTypeList);
     if (alertCollection != null && alertCollection.Count > 0)
     {
         visitor.HasAlert = true;
         visitor.AssignAlerts(alertCollection);
     }
 }
Example #2
0
 /// <summary>
 /// Visitors the mapper.
 /// </summary>
 /// <param name="visitorCollection">The visitor.</param>
 /// <param name="visitor">The p.</param>
 public static void VisitorMapper(VisitorCollection visitorCollection, PersonBase visitor)
 {
     var visitorMember = new Visitor();
     if (visitor != null && visitorCollection != null)
     {
         visitorMember.VisitorId = visitor.PersonId;
         visitorMember.PersonalDetail = visitor.PersonalDetail;
         visitorMember.Photo = visitor.Photo;
         visitorMember.SecurityPhotoAddress = visitor.SecurityPhotoAddress;
         visitorMember.IsOnboard = visitor.IsOnboard;
         visitorMember.AreAllMessagesGotAcknowledged = visitor.AreAllMessagesGotAcknowledged;
         visitorMember.LastDateTime = visitor.LastDateTime;
         visitorMember.LastEvent = visitor.LastEvent;
         visitorMember.HasAlert = visitor.HasAlert;
         visitorMember.HasMessage = visitor.HasMessage;
         visitorMember.CardNumber = visitor.CardNumber;
         visitorMember.AssignAlerts(visitor.Alerts);
         visitorMember.AssignMessages(visitor.Messages);
         visitorMember.AllowOnboardAlert = visitor.AllowOnboardAlert;
         visitorCollection.Add(visitorMember);
     }
 }
        /// <summary>
        /// Maps the visitor data.
        /// </summary>
        /// <param name="visitor">The visitor.</param>
        /// <param name="persons">The persons.</param>
        /// <param name="eventType">Type of the event.</param>
        private static void MapVisitorData(Visitor visitor, Person persons, NotificationEventType eventType)
        {
            var selectedPerson = RetrieveSelectedPerson();
            Visitor retrievedVisitor = persons.Visitors.FirstOrDefault();

            if (visitor != null)
            {
                if (eventType == NotificationEventType.PersonData)
                {
                    visitor.PersonalDetail.FirstName = retrievedVisitor.PersonalDetail.FirstName;
                    visitor.PersonalDetail.LastName = retrievedVisitor.PersonalDetail.LastName;
                    visitor.PersonalDetail.Gender = retrievedVisitor.PersonalDetail.Gender;
                    visitor.PersonalDetail.Age = retrievedVisitor.PersonalDetail.Age;
                    visitor.PersonalDetail.Birthdate = retrievedVisitor.PersonalDetail.Birthdate;
                    visitor.SecurityPhotoAddress = retrievedVisitor.SecurityPhotoAddress;
                    visitor.PersonalDetail.Country = RetriveCountry(retrievedVisitor.PersonalDetail);
                    if (visitor.PersonalDetail.Country != null)
                    {
                        visitor.PersonalDetail.Country.Name = retrievedVisitor.PersonalDetail.Country.Name;
                    }

                    visitor.PersonalDetail.DocumentType = retrievedVisitor.PersonalDetail.DocumentType;
                    visitor.PersonalDetail.DocumentNumber = retrievedVisitor.PersonalDetail.DocumentNumber;
                    visitor.PersonalDetail.Title = retrievedVisitor.PersonalDetail.Title;
                    visitor.PersonalDetail.DepartmentPOC = retrievedVisitor.PersonalDetail.DepartmentPOC;
                    visitor.VisitorType = retrievedVisitor.VisitorType;

                    if (visitor.VisitorInfo == null)
                    {
                        visitor.VisitorInfo = new VisitorInfo();
                    }

                    visitor.VisitorInfo.VisitPurpose = retrievedVisitor.VisitorInfo.VisitPurpose;
                    visitor.AssignVisitorAccessCard(retrievedVisitor.VisitorAccessCards);
                    visitor.VisitorInfo.CompanyName = retrievedVisitor.VisitorInfo.CompanyName;
                    visitor.PersonalDetail.DepartmentName = retrievedVisitor.PersonalDetail.DepartmentName;
                    visitor.VisitorInfo.ContactNumber = retrievedVisitor.VisitorInfo.ContactNumber;
                    visitor.VisitorInfo.CompanyContactNumber = retrievedVisitor.VisitorInfo.CompanyContactNumber;
                }
                else if (eventType == NotificationEventType.BoardingStatus)
                {
                    visitor.IsOnboard = retrievedVisitor.IsOnboard;
                    visitor.LastEvent = retrievedVisitor.LastEvent;
                    visitor.LastDateTime = retrievedVisitor.LastDateTime;

                    if (visitor.VisitorId.Equals(selectedPerson.PersonId, StringComparison.OrdinalIgnoreCase))
                    {
                        selectedPerson.IsOnboard = retrievedVisitor.IsOnboard;
                        selectedPerson.LastEvent = retrievedVisitor.LastEvent;
                        selectedPerson.LastDateTime = retrievedVisitor.LastDateTime;
                    }
                }
                else if (eventType == NotificationEventType.Alert)
                {
                    visitor.HasAlert = retrievedVisitor.HasAlert;
                    visitor.AssignAlerts(retrievedVisitor.Alerts);

                    selectedPerson.HasAlert = retrievedVisitor.HasAlert;
                    selectedPerson.AssignAlerts(retrievedVisitor.Alerts);
                    Messenger.Instance.Notify(MessengerMessage.NotifyPersonAlert, selectedPerson);
                    Messenger.Instance.Notify(MessengerMessage.NotifyAlertDetails, selectedPerson);
                }
                else if (eventType == NotificationEventType.Message)
                {
                    var messageAcknowledge = retrievedVisitor.Messages.All(m => m.StatusId.Equals(CommonConstants.MessageAcknowledgeStatusId));
                    visitor.AreAllMessagesGotAcknowledged = messageAcknowledge;
                    visitor.AssignMessages(retrievedVisitor.Messages);

                    selectedPerson.AreAllMessagesGotAcknowledged = messageAcknowledge;
                    selectedPerson.AssignPersonMessages(retrievedVisitor.Messages);
                    Messenger.Instance.Notify(MessengerMessage.NotifyPersonMessage, selectedPerson);
                    Messenger.Instance.Notify(MessengerMessage.NotifyMessageDetails, selectedPerson);
                }
            }
        }