public async Task RetrievePortManningTest()
        {
            var portManningSearchParameter = new PortManningSearchParameters { DepartmentIds = "1", ShipId = "1", PageNumber = 1, MaxResults = 10, Parts = "$all" };
            var portManningResult = new ListResult<PortManning>();
            var portManning = new PortManning { AddedDate = DateTime.Now, AtAnchor = "true", EmergencyStation = "ES", ImportStatus = "Success", InPort = "true", IPMPositionId = "1", IsAtAnchor = true, IsInPort = true, PortArrivalDate = DateTime.Now, PortId = "1", PositionName = "Deck", PositionNumber = "1", Role = "Deck Officer", SafetyNumbers = "1,2", SafetyPositionDetailId = "1", SafetyRoleId = "1", ShipId = "5" };
            portManning.PortManningPosition.Add(new PortManningPosition { AssignedDate = DateTime.Now, DepartmentId = "1", IPMPositionId = "1", IPMSafetyPositionDetailId = "1", LastIPMDate = DateTime.Now, PortId = "1", SafetyNumber = "1", SafetyRoleId = "1" });
            portManning.PortManningPositionDepartment.Add(new PortManningPositionDepartment { DepartmentId = "1", IPMPositionDepartmentId = "1", IPMPositionId = "1" });
            portManningResult.Items.Add(portManning);
            var crewResult = new ListResult<Entities.Crewmember>();
            var crew = new Entities.Crewmember { PersonalDetail = new PersonalDetail { FirstName = "John", LastName = "Doe" }, EmployeeNo = "101", DepartmentId = "1" };
            crew.SafetyDuties.Add(new SafetyDuty { SafetyRoleId = "1" });
            crewResult.Items.Add(crew);

            this.shipRepository.Setup(mock => mock.RetrievePortManning(It.IsAny<PortManningSearchParameters>())).Returns(Task.FromResult(portManningResult));
            this.crewRepository.Setup(mock => mock.RetrieveCrewmembers(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int?>(), It.IsAny<int?>(), It.IsAny<string>())).Returns(Task.FromResult(crewResult));
            var result = await this.portManningData.RetrievePortManning(new PortManningSearchParameters());
            Assert.IsNotNull(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Retrieves the port manning.
        /// </summary>
        /// <param name="portManningSearchParameters">The port manning search parameters.</param>
        /// <returns>
        /// The list of portManning.
        /// </returns>
        public async Task<ListResult<PortManning>> RetrievePortManning(PortManningSearchParameters portManningSearchParameters)
        {
            var portManning = await this.shipRepository.RetrievePortManning(portManningSearchParameters);
            
            var safetyRoleIds = string.Empty;
            foreach (var port in portManning.Items)
            {
                foreach (var position in port.PortManningPosition)
                {
                    if (!string.IsNullOrEmpty(position.SafetyRoleId) && !safetyRoleIds.Split(',').Contains(position.SafetyRoleId))
                    {
                        safetyRoleIds += position.SafetyRoleId + ",";
                    }
                }
            }

            if (!string.IsNullOrEmpty(safetyRoleIds))
            {
                var crewDetails = await this.crewRepository.RetrieveCrewmembers(null, null, null, null, null, null, null, null, safetyRoleIds, 1, int.MaxValue, CrewMembersParts);

                if (crewDetails != null && crewDetails.Items.Count > 0)
                {
                    foreach (var port in portManning.Items)
                    {
                        foreach (var position in port.PortManningPosition)
                        {
                            if (!string.IsNullOrEmpty(position.SafetyRoleId))
                            {
                                var crewMember = crewDetails.Items.FirstOrDefault(crew => crew.SafetyDuties.Any(safetyDuty => safetyDuty.SafetyRoleId == position.SafetyRoleId));
                                if (crewMember != null)
                                {
                                    position.CrewmemberLastName = crewMember.PersonalDetail.LastName;
                                    position.CrewmemberFirstName = crewMember.PersonalDetail.FirstName;
                                    position.EmployeeNo = crewMember.EmployeeNo;
                                    position.DepartmentId = crewMember.DepartmentId;
                                }
                            }
                        }
                    }
                }
            }

            return portManning;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Retrieves the port manning.
 /// </summary>
 /// <param name="portManningSearchParameters">The port manning search parameters.</param>
 /// <returns>
 /// The list of portManning.
 /// </returns>
 public async Task<ListResult<PortManning>> RetrievePortManning(PortManningSearchParameters portManningSearchParameters)
 {
     return await this.portManningData.RetrievePortManning(portManningSearchParameters);
 }
 /// <summary>
 /// Retrieves the port manning.
 /// </summary>
 /// <param name="portManningSearchParameters">The port manning search parameters.</param>
 /// <returns>
 /// The list of portManning.
 /// </returns>
 public async Task<ListResult<PortManning>> RetrievePortManning(PortManningSearchParameters portManningSearchParameters)
 {
     var portManningDetail = await this.portManningClient.RetrievePortManningListAsync(shipId: portManningSearchParameters.ShipId, portId: portManningSearchParameters.PortId, portArrivalDate: portManningSearchParameters.PortArrivalDate, departmentIds: portManningSearchParameters.DepartmentIds, parts: portManningSearchParameters.Parts, pageNumber: portManningSearchParameters.PageNumber, maxResults: portManningSearchParameters.MaxResults, orderBy: portManningSearchParameters.OrderBy, isSafetyRoleAssignment: "true");
     return !string.IsNullOrEmpty(portManningDetail) ? JsonConvert.DeserializeObject<ListResult<PortManning>>(portManningDetail) : default(ListResult<PortManning>);
 }