public CosmosDB.Models.Application ToServiceModel()
        {
            var application = new CosmosDB.Models.Application();

            // ID and State are ignored, readonly
            application.ApplicationId   = this.ApplicationId != null ? new Guid(this.ApplicationId) : Guid.Empty;
            application.ApplicationUri  = this.ApplicationUri;
            application.ApplicationName = this.ApplicationName;
            application.ApplicationType = (Types.ApplicationType) this.ApplicationType;
            if (this.ApplicationNames != null)
            {
                var applicationNames = new List <CosmosDB.Models.ApplicationName>();
                foreach (var applicationNameModel in this.ApplicationNames)
                {
                    applicationNames.Add(applicationNameModel.ToServiceModel());
                }
                application.ApplicationNames = applicationNames.ToArray();
            }
            application.ProductUri    = this.ProductUri;
            application.DiscoveryUrls = this.DiscoveryUrls != null?this.DiscoveryUrls.ToArray() : null;

            application.ServerCapabilities  = this.ServerCapabilities;
            application.GatewayServerUri    = this.GatewayServerUri;
            application.DiscoveryProfileUri = this.DiscoveryProfileUri;
            return(application);
        }
        public ApplicationRecordApiModel(CosmosDB.Models.Application application)
        {
            this.ApplicationId   = application.ApplicationId != Guid.Empty ? application.ApplicationId.ToString() : null;
            this.ID              = application.ID;
            this.State           = (ApplicationState)application.ApplicationState;
            this.ApplicationUri  = application.ApplicationUri;
            this.ApplicationName = application.ApplicationName;
            this.ApplicationType = (ApplicationType)application.ApplicationType;
            var applicationNames = new List <ApplicationNameApiModel>();

            foreach (var applicationName in application.ApplicationNames)
            {
                var applicationNameModel = new ApplicationNameApiModel(applicationName);
                applicationNames.Add(applicationNameModel);
            }
            this.ApplicationNames    = applicationNames;
            this.ProductUri          = application.ProductUri;
            this.DiscoveryUrls       = application.DiscoveryUrls;
            this.ServerCapabilities  = application.ServerCapabilities;
            this.GatewayServerUri    = application.GatewayServerUri;
            this.DiscoveryProfileUri = application.DiscoveryProfileUri;
        }