コード例 #1
0
        /// <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);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Maps the asynchronous.
        /// </summary>
        /// <param name="visitorEntity">The visitor entities.</param>
        /// <returns>Return instance of visitor.</returns>
        private static Visitor MapAsync(Entities.Visitor visitorEntity)
        {
            var visitor = new Visitor();

            if (visitorEntity != null)
            {
                visitor.VisitorId = visitorEntity.VisitorId;
                visitor.PersonalDetail = visitorEntity.PersonalDetail;
                visitor.VisitorTypeId = visitorEntity.VisitorTypeId;
                visitor.SecurityPhotoAddress = visitorEntity.SecurityPhotoAddress;
                visitor.VisitorInfo = new AdditionalInfo();
                visitor.VisitorInfo.CompanyName = visitorEntity.CompanyName;

                visitor.PersonalDetail = visitor.PersonalDetail ?? new PersonalDetail();
                visitor.PersonalDetail.DepartmentId = visitorEntity.PersonalDetail.DepartmentId;

                var passportDetail = visitorEntity.Identifications.FirstOrDefault(a => a.DocumentTypeId.Equals(ApplicationSetting.DocumentTypeId, StringComparison.OrdinalIgnoreCase));
                if (passportDetail != null)
                {
                    visitor.PersonalDetail.DocumentNumber = passportDetail.Number;
                    visitor.PersonalDetail.DocumentTypeId = passportDetail.DocumentTypeId;
                }
                else
                {
                    var identificationDetail = visitorEntity.Identifications.FirstOrDefault();
                    if (identificationDetail != null)
                    {
                        visitor.PersonalDetail.DocumentNumber = identificationDetail.Number;
                        visitor.PersonalDetail.DocumentTypeId = identificationDetail.DocumentTypeId;
                    }
                }

                if (visitorEntity.VisitorAccessCards.Count > 0)
                {
                    visitor.AssignVisitorAccessCard(visitorEntity.VisitorAccessCards);
                }

                if (visitorEntity.Visits.Count > 0)
                {
                    var visit = visitorEntity.Visits.FirstOrDefault();
                    visitor.VisitorInfo.VisitPurpose = visit != null ? visit.VisitPurposeId : null;
                }

                if (visitorEntity.Phones.Count > 0)
                {
                    var phone = visitorEntity.Phones.FirstOrDefault();
                    if (phone != null)
                    {
                        visitor.VisitorInfo.ContactNumber = phone.AreaCode + "-" + phone.Number;
                    }
                }
            }

            return visitor;
        }