/// <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;
        }
Beispiel #2
0
        /// <summary>
        /// Maps the asynchronous.
        /// </summary>
        /// <param name="guestEntity">The guest entities.</param>
        /// <returns>Return instance of Guest.</returns>
        private static Guest MapAsync(Entities.Guest guestEntity)
        {
            var guest = new Guest();

            if (guestEntity != null)
            {
                guest.GuestId = guestEntity.GuestId;
                guest.GuestReservationId = guestEntity.GuestReservationId;
                guest.PersonalDetail = guestEntity.PersonalDetail;
                guest.CruiseDetail = guest.CruiseDetail ?? new GuestCruiseDetail();
                if (guestEntity.ReservationDetail != null)
                {
                    guest.CruiseDetail.IsPrimary = guestEntity.ReservationDetail.IsPrimary;
                    guest.CruiseDetail.LoyaltyLevelTypeId = guestEntity.ReservationDetail.LoyaltyLevelTypeId;
                    guest.CruiseDetail.ReservationId = guestEntity.ReservationDetail.ReservationId;
                    guest.CruiseDetail.ReservationNumber = guestEntity.ReservationDetail.ReservationNumber;
                    guest.CruiseDetail.ReservationStatusId = guestEntity.ReservationDetail.ReservationStatusId;
                    guest.CruiseDetail.Stateroom = guestEntity.ReservationDetail.StateroomId;
                    guest.CruiseDetail.EmbarkDate = guestEntity.ReservationDetail.ReservationFromDate;
                    guest.CruiseDetail.DebarkDate = guestEntity.ReservationDetail.ReservationToDate;
                    guest.CruiseDetail.VoyageId = guestEntity.ReservationDetail.VoyageId;
                    guest.CruiseDetail.CanDebarkAlone = guest.PersonalDetail != null && guest.PersonalDetail.Age.HasValue && guest.PersonalDetail.Age.Value >= ApplicationSetting.MaximumChildAge;
                }

                guest.PersonalDetail = guest.PersonalDetail ?? new PersonalDetail();

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

                var mediaItem = guestEntity.MediaItems.FirstOrDefault(a => a.MediaTypeId.Equals(ApplicationSetting.MediaTypeId, StringComparison.OrdinalIgnoreCase));
                guest.SecurityPhotoAddress = mediaItem != null ? mediaItem.MediaItemAddress : null;

                if (guestEntity.Folios.Count > 0)
                {
                    guest.AssignFolios(guestEntity.Folios);
                }
            }

            return guest;
        }
Beispiel #3
0
        /// <summary>
        /// retrieves brand detail
        /// </summary>
        /// <param name="brand">brand attribute</param>
        /// <returns>Brand entity</returns>
        private static Brand MapAsync(Entities.Brand brand)
        {
            var brandData = new Brand();
            if (brand != null)
            {
                brandData.BrandId = brand.BrandId;
                brandData.Name = brand.Name;
                var mediaItem = brand.MediaItems.FirstOrDefault();
                if (mediaItem != null)
                {
                    brandData.MediaItemAddress = mediaItem.MediaItemAddress;
                }
            }

            return brandData;
        }
Beispiel #4
0
        /// <summary>
        /// retrieves ship detail
        /// </summary>
        /// <param name="entitiesShip"> entitiesShip attribute</param>
        /// <returns>Return ship entity</returns>
        private static Ship MapAsync(Entities.Ship entitiesShip)
        {
            var ship = new Ship();
            if (entitiesShip != null)
            {
                ship.BrandId = entitiesShip.BrandId;
                ship.Code = entitiesShip.Code;
                ship.Name = entitiesShip.Name;
                ship.ShipId = entitiesShip.ShipId;
                var mediaItem = entitiesShip.MediaItems.FirstOrDefault();
                if (mediaItem != null)
                {
                    ship.MediaItemAddress = mediaItem.MediaItemAddress;
                }
            }

            return ship;
        }
        /// <summary>
        /// retrieves brand detail
        /// </summary>
        /// <param name="voyage">brand attribute</param>
        /// <returns>Brand entity</returns>
        private static Voyage MapAsync(Entities.Voyage voyage)
        {
            var voyageData = new Voyage();
            voyageData.DebarkDate = voyage.DebarkDate;
            voyageData.Name = voyage.Name;
            voyageData.DebarkPortId = voyage.DebarkPortId;
            voyageData.DestinationId = voyage.DestinationId;
            voyageData.EmbarkDate = voyage.EmbarkDate;
            voyageData.EmbarkPortId = voyage.EmbarkPortId;
            voyageData.IsActive = voyage.IsActive;
            voyageData.AssignItineraries(voyage.Itineraries);
            voyageData.Nights = voyage.Nights;
            voyageData.Number = voyage.Number;
            voyageData.ShipId = voyage.ShipId;
            voyageData.VoyageId = voyage.VoyageId;
            var mediaItems = voyage.MediaItems.FirstOrDefault();
            voyageData.MediaItemAddress = mediaItems != null ? mediaItems.MediaItemAddress : string.Empty;

            return voyageData;
        }
        /// <summary>
        /// Maps the asynchronous.
        /// </summary>
        /// <param name="stateroomCategory">The stateroom category.</param>
        /// <param name="entityStateroomCategoryType">Type of the stateroom category.</param>
        /// <returns>
        /// stateroom category
        /// </returns>
        private static StateroomCategory MapAsync(Entities.StateroomCategory stateroomCategory, Entities.StateroomCategoryType entityStateroomCategoryType)
        {
            var stateroomCategoryData = new StateroomCategory();
            if (stateroomCategory != null)
            {
                stateroomCategoryData.StateroomCategoryType = stateroomCategory.StateroomCategoryType;
                stateroomCategoryData.StateroomCategoryTypeId = stateroomCategory.StateroomCategoryTypeId;
                stateroomCategoryData.Category = stateroomCategory.Category;
                stateroomCategoryData.StateroomCategoryId = stateroomCategory.StateroomCategoryId;
                if (entityStateroomCategoryType != null && !string.IsNullOrEmpty(ApplicationSetting.MediaTypeId))
                {
                    var stateroomCategoryType = entityStateroomCategoryType.MediaItems != null ? entityStateroomCategoryType.MediaItems.FirstOrDefault(a => a.MediaTypeId.Equals(ApplicationSetting.MediaTypeId, StringComparison.OrdinalIgnoreCase)) : null;
                    if (stateroomCategoryType != null)
                    {
                        stateroomCategoryData.MediaItemAddress = stateroomCategoryType.MediaItemAddress;
                    }
                }
            }

            return stateroomCategoryData;
        }
        /// <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;
        }
Beispiel #8
0
        /// <summary>
        /// Maps the visitor data.
        /// </summary>
        /// <param name="visitorDetails">Type of the Visitor.</param>
        /// <returns>Visitor detail</returns>
        private static Visitor MapVisitorData(Entities.Visitor visitorDetails)
        {
            var visitor = new Visitor();

            visitor.AddedDate = visitorDetails.AddedDate;
            visitor.LastModifiedDate = visitorDetails.LastModifiedDate;
            visitor.VisitorId = visitorDetails.VisitorId;
            visitor.VisitorTypeId = visitorDetails.VisitorTypeId;
            visitor.SecurityPhotoAddress = visitorDetails.SecurityPhotoAddress;
            visitor.CompanyContactNumber = visitorDetails.CompanyContactNumber;
            visitor.CompanyName = visitorDetails.CompanyName;

            if (visitorDetails.PersonalDetail != null)
            {
                visitor.PersonalDetail = visitorDetails.PersonalDetail;
            }

            if (visitorDetails.Identifications != null)
            {
                foreach (var identification in visitorDetails.Identifications)
                {
                    var objIdentification = new Identification();
                    objIdentification.DocumentTypeId = identification.DocumentTypeId;
                    objIdentification.Number = identification.Number;
                    objIdentification.VisitorId = identification.VisitorId;
                    objIdentification.IdentificationId = identification.IdentificationId;

                    visitor.Identifications.Add(objIdentification);
                }
            }

            if (visitorDetails.Visits != null)
            {
                foreach (var visit in visitorDetails.Visits)
                {
                    var objVisit = new Visit();
                    objVisit.VisitorId = visit.VisitorId;
                    objVisit.LastOffBoardDate = visit.LastOffBoardDate;
                    objVisit.LastOnboardDate = visit.LastOnboardDate;
                    objVisit.ShipId = visit.ShipId;
                    objVisit.StartDate = visit.StartDate;
                    objVisit.EndDate = visit.EndDate;
                    objVisit.VisitPurposeId = visit.VisitPurposeId;
                    objVisit.VisitId = visit.VisitId;

                    visitor.Visits.Add(objVisit);
                }
            }

            return visitor;
        }
 /// <summary>
 /// Updates the asynchronous.
 /// </summary>
 /// <param name="visitorId">The visitor identifier.</param>
 /// <param name="visitor">The visitor.</param>
 /// <returns>
 /// Task containing nothing
 /// </returns>
 public async Task UpdateAsync(string visitorId, Entities.Visitor visitor)
 {
     await this.visitorClient.UpdateVisitorAsync(visitorId, JsonConvert.SerializeObject(visitor));
 }
 /// <summary>
 /// Creates the asynchronous.
 /// </summary>
 /// <param name="visitor">The visitor.</param>
 /// <returns>
 /// Task containing id for the created visitor
 /// </returns>
 public async Task<string> CreateAsync(Entities.Visitor visitor)
 {
     var task = await this.visitorClient.CreateVisitorAsync(JsonConvert.SerializeObject(visitor));
     return task != null ? task : string.Empty;
 }
Beispiel #11
0
        /// <summary>
        /// Maps the alert data.
        /// </summary>
        /// <param name="alertType">Type of the alert.</param>
        /// <param name="shipTime">The ship time.</param>
        /// <returns>
        /// Return Alert
        /// </returns>
        private static Alert MapAlertData(Entities.AlertType alertType, DateTime? shipTime)
        {
            Alert alert = null;
            if (alertType != null)
            {
                alert = new Alert
                {
                    AlertId = alertType.AlertTypeId,
                    Description = alertType.Description,
                    UserName = alertType.AddedBy,
                    ExpiryDate = alertType.ExpiryDate,
                    PersonCount = alertType.Alerts.Count,
                    IsOverride = alertType.IsOverride,
                    AddedDate = alertType.AddedDate,
                    TypeId = Convert.ToInt32(alertType.TypeId, CultureInfo.InvariantCulture),
                    IsMessage = alertType.IsMessage,
                    IsTemplate = alertType.IsTemplate,
                    IsSoundEnable = alertType.IsSoundEnable,
                    StartDate = alertType.DueDate,
                    MessageFrom = alertType.MessageFrom,
                    CrewDepartmentId = alertType.DepartmentId
                };

                bool isActive = false;
                if (shipTime.HasValue)
                {
                    if (!alertType.ExpiryDate.HasValue && alertType.IsMessage)
                    {
                        isActive = true;
                    }
                    else
                    {
                        isActive = shipTime < alertType.ExpiryDate;
                    }
                }

                bool isAnyActive = false;
                foreach (var alertItem in alertType.Alerts)
                {
                    alert.Persons.Add(new Person
                    {
                        PersonId = alertItem.PersonId,
                        PersonTypeId = alertItem.PersonTypeId,
                        StatusId = alertItem.StatusId,
                        PersonAlertId = alertItem.PersonAlertId,
                        VoyageId = alertItem.VoyageId
                    });

                    if (isActive && !isAnyActive && alertItem.StatusId.Equals("1", StringComparison.OrdinalIgnoreCase))
                    {
                        isAnyActive = true;
                    }
                }

                alert.IsActive = isActive && isAnyActive;
            }

            return alert;
        }