private OffhireManagementSystemEntity mapOffhireDataToOffhireSystemEntity(OffhireService.OffhireData offhireData, long companyId)
        {
            var location = activityLocationRepository.First(l => l.Code == offhireData.Location);
            if (location == null)
            {
                //It must be logged that the specified location was not found.
                return null;
            }

            var vessleInCompany = vesselDomainService.GetVesselInCompany(companyId, offhireData.VesselCode);

            if (vessleInCompany == null)
            {
                //It must be logged that the specified VesselCode In Company was not found.
                return null;
            }

            var entity = new OffhireManagementSystemEntity()
                        {
                            VesselInCompany = vessleInCompany,
                            Location = location,
                            StartDateTime = offhireData.StartDateTime,
                            EndDateTime = offhireData.EndDateTime,
                            HasVoucher = offhireData.HasVoucher,
                            ReferenceNumber = offhireData.ReferenceNumber
                        };

            entity.OffhireDetails = new List<OffhireManagementSystemEntityDetail>();

            foreach (var offhireDataItem in offhireData.OffhireDetails)
            {
                var entityDetail = mapOffhireDataDetailToOffhireManagementSystemEntityDetail(offhireDataItem, companyId, vessleInCompany);

                if (entityDetail == null)
                {
                    //It must be logged that the offhireDataItem could not be mapped.

                    return null;
                }

                entity.OffhireDetails.Add(entityDetail);
            }

            return entity;
        }
 //================================================================================
 private OffhirePreparedData convertToPreparedData(Company introducer, OffhireManagementSystemEntity finalizedOffhire)
 {
     return new OffhirePreparedData()
            {
                ReferenceNumber = finalizedOffhire.ReferenceNumber,
                StartDateTime = finalizedOffhire.StartDateTime,
                EndDateTime = finalizedOffhire.EndDateTime,
                Introducer = introducer,
                HasVoucher = finalizedOffhire.HasVoucher,
                Location = finalizedOffhire.Location,
                VesselInCompany = finalizedOffhire.VesselInCompany,
                Voyage = voyageDomianService.GetVoyageContainingDuration(introducer, finalizedOffhire.StartDateTime, finalizedOffhire.EndDateTime),
                OffhireDetails = finalizedOffhire.OffhireDetails.Select(convertDetailToPreparedDataDetail).ToList()
            };
 }