public static AircraftRegistration ToEntity(this AircraftRegistrationViewModel model)
        {
            if (model == null)
            {
                return(null);
            }

            AircraftRegistration entity = new AircraftRegistration
            {
                Id                              = model.Id,
                AircraftId                      = model.AircraftId,
                ActNumber                       = model.ActNumber,
                RegistrationNumber              = model.RegistrationNumber,
                RegistrationDate                = model.RegistrationDate.HasValue ? DateTime.SpecifyKind(model.RegistrationDate.Value, DateTimeKind.Utc) : model.RegistrationDate,
                RegistrationMark                = model.RegistrationMark,
                IsLastRegistration              = model.IsLastRegistration,
                RegistrationStatusIsActive      = model.RegistrationStatusIsActive,
                RegistrationStatusCode          = model.RegistrationStatusCode,
                RegistrationStatusName          = model.RegistrationStatusName,
                RegistrationDocumentNumber      = model.RegistrationDocumentNumber,
                RegistrationDocumentDate        = model.RegistrationDocumentDate.HasValue ? DateTime.SpecifyKind(model.RegistrationDocumentDate.Value, DateTimeKind.Utc) : model.RegistrationDocumentDate,
                RegistrationDocumentDescription = model.RegistrationDocumentDescription,
                DeregistrationDate              = model.DeregistrationDate.HasValue ? DateTime.SpecifyKind(model.DeregistrationDate.Value, DateTimeKind.Utc) : model.DeregistrationDate,
                DeregistrationReason            = model.DeregistrationReason,
                DeregistrationDescription       = model.DeregistrationDescription,
                DeregistrationCountryCode       = model.DeregistrationCountryCode,
                DeregistrationCountryName       = model.DeregistrationCountryName,
                LeasingDocumentNumber           = model.LeasingDocumentNumber,
                LeasingDocumentDate             = model.LeasingDocumentDate.HasValue ? DateTime.SpecifyKind(model.LeasingDocumentDate.Value, DateTimeKind.Utc) : model.LeasingDocumentDate,
                LeasingEndDate                  = model.LeasingEndDate.HasValue ? DateTime.SpecifyKind(model.LeasingEndDate.Value, DateTimeKind.Utc) : model.LeasingEndDate,
                LeasingAgreement                = model.LeasingAgreement,
                LeasingLessorPersonIdentifier   = model.LeasingLessorPersonIdentifier,
                LeasingLessorPersonNames        = model.LeasingLessorPersonNames,
                LeasingLessorEntityIdentifier   = model.LeasingLessorEntityIdentifier,
                LeasingLessorEntityName         = model.LeasingLessorEntityName,

                AircraftRegistrationOperatorEntity = (model.OperatorEntities != null && model.OperatorEntities.Any()) ?
                                                     model.OperatorEntities.Select(op => op.ToEntity()).ToList() : null,

                AircraftRegistrationOperatorPerson = (model.OperatorPeople != null && model.OperatorPeople.Any()) ?
                                                     model.OperatorPeople.Select(op => op.ToEntity()).ToList() : null,

                AircraftRegistrationOwnerEntity = (model.OwnerEntities != null && model.OwnerEntities.Any()) ?
                                                  model.OwnerEntities.Select(op => op.ToEntity()).ToList() : null,

                AircraftRegistrationOwnerPerson = (model.OwnerPeople != null && model.OwnerPeople.Any()) ?
                                                  model.OwnerPeople.Select(op => op.ToEntity()).ToList() : null,
            };

            return(entity);
        }
        public static AircraftRegistrationViewModel ToViewModel(this AircraftRegistration entity)
        {
            if (entity == null)
            {
                return(null);
            }

            AircraftRegistrationViewModel model = new AircraftRegistrationViewModel
            {
                Id                              = entity.Id,
                AircraftId                      = entity.AircraftId,
                ActNumber                       = entity.ActNumber,
                RegistrationNumber              = entity.RegistrationNumber,
                RegistrationDate                = entity.RegistrationDate.HasValue ? DateTime.SpecifyKind(entity.RegistrationDate.Value, DateTimeKind.Utc) : entity.RegistrationDate,
                RegistrationMark                = entity.RegistrationMark,
                IsLastRegistration              = entity.IsLastRegistration,
                RegistrationStatusIsActive      = entity.RegistrationStatusIsActive,
                RegistrationStatusCode          = entity.RegistrationStatusCode,
                RegistrationStatusName          = entity.RegistrationStatusName,
                RegistrationDocumentNumber      = entity.RegistrationDocumentNumber,
                RegistrationDocumentDate        = entity.RegistrationDocumentDate.HasValue ? DateTime.SpecifyKind(entity.RegistrationDocumentDate.Value, DateTimeKind.Utc) : entity.RegistrationDocumentDate,
                RegistrationDocumentDescription = entity.RegistrationDocumentDescription,
                DeregistrationDate              = entity.DeregistrationDate.HasValue ? DateTime.SpecifyKind(entity.DeregistrationDate.Value, DateTimeKind.Utc) : entity.DeregistrationDate,
                DeregistrationReason            = entity.DeregistrationReason,
                DeregistrationDescription       = entity.DeregistrationDescription,
                DeregistrationCountryCode       = entity.DeregistrationCountryCode,
                DeregistrationCountryName       = entity.DeregistrationCountryName,
                LeasingDocumentNumber           = entity.LeasingDocumentNumber,
                LeasingDocumentDate             = entity.LeasingDocumentDate.HasValue ? DateTime.SpecifyKind(entity.LeasingDocumentDate.Value, DateTimeKind.Utc) : entity.LeasingDocumentDate,
                LeasingEndDate                  = entity.LeasingEndDate.HasValue ? DateTime.SpecifyKind(entity.LeasingEndDate.Value, DateTimeKind.Utc) : entity.LeasingEndDate,
                LeasingAgreement                = entity.LeasingAgreement,
                LeasingLessorPersonIdentifier   = entity.LeasingLessorPersonIdentifier,
                LeasingLessorPersonNames        = entity.LeasingLessorPersonNames,
                LeasingLessorEntityIdentifier   = entity.LeasingLessorEntityIdentifier,
                LeasingLessorEntityName         = entity.LeasingLessorEntityName,

                OperatorEntities = entity.AircraftRegistrationOperatorEntity
                                   .Select(op => op.ToViewModel()).ToList(),

                OperatorPeople = entity.AircraftRegistrationOperatorPerson
                                 .Select(op => op.ToViewModel()).ToList(),

                OwnerEntities = entity.AircraftRegistrationOwnerEntity
                                .Select(op => op.ToViewModel()).ToList(),

                OwnerPeople = entity.AircraftRegistrationOwnerPerson
                              .Select(op => op.ToViewModel()).ToList(),
            };

            return(model);
        }