Exemple #1
0
        public List <get_all_site_Result> PostAdminSite([FromBody] Admin admin)
        {
            List <get_all_site_Result> gSites = new List <get_all_site_Result>();
            Authorization auth   = new Authorization(admin.email);
            var           result = auth.service.Management.Profiles.List("~all", "~all");

            try
            {
                var sites = result.Execute();
                Dictionary <string, get_all_site_Result> dbSites = new Dictionary <string, get_all_site_Result>();
                using (var data = new digimarketEntities1().get_all_site())
                {
                    dbSites = data.ToDictionary(t => t.site_url, t => t);
                }
                foreach (var site in sites.Items)
                {
                    if (!dbSites.ContainsKey(site.WebsiteUrl))
                    {
                        gSites.Add(new get_all_site_Result()
                        {
                            site_url = site.WebsiteUrl, site_name = site.Name, ga_id = site.Id, custom = false
                        });
                    }
                }
            }catch (Exception e)
            {
            }


            return(gSites);
        }