private void Map(ElasticApplication from, Application to)
 {
     to.DaysToKeepLogs = from.DaysToKeepLogs;
     to.IsExcluded     = from.IsExcluded;
     to.IsHidden       = from.IsHidden;
     to.Name           = from.Name;
     to.Path           = from.Path;
 }
        public async Task AddOrUpdateAppAsync(Application app)
        {
            if (app == null || app.Path == null)
            {
                throw new ArgumentException("app is null or app.Path is null");
            }
            if (string.IsNullOrEmpty(app.Name))
            {
                // if name is not provided we need to assign a default one
                app.Name = Path.GetFileName(app.Path.TrimEnd(Path.DirectorySeparatorChar));
            }

            var eapp = new ElasticApplication();

            Map(app, eapp);
            await eclient.IndexAsync <ElasticApplication>(eapp, ind => ind.Index(AppConfIndexName));
        }
 private void Map(Application from, ElasticApplication to, string[] properties = null)
 {
     to.Id   = BitConverter.ToString(MD5.Create().ComputeHash(Encoding.UTF8.GetBytes(from.Path))).Replace("-", string.Empty);
     to.Path = from.Path;
     if (properties == null || properties.Contains("Name", StringComparer.OrdinalIgnoreCase))
     {
         to.Name = from.Name;
     }
     if (properties == null || properties.Contains("DaysToKeepLogs", StringComparer.OrdinalIgnoreCase))
     {
         to.DaysToKeepLogs = from.DaysToKeepLogs;
     }
     if (properties == null || properties.Contains("IsExcluded", StringComparer.OrdinalIgnoreCase))
     {
         to.IsExcluded = from.IsExcluded;
     }
     if (properties == null || properties.Contains("IsHidden", StringComparer.OrdinalIgnoreCase))
     {
         to.IsHidden = from.IsHidden;
     }
 }