Beispiel #1
0
        public async new Task <ActionResult> Index()
        {
            var user             = (UserDefinition)Serenity.Authorization.UserDefinition;
            var instagramAccount = "";

            using (var connection = SqlConnections.NewByKey("Default"))
                using (var uow = new UnitOfWork(connection))
                {
                    var tenant = uow.Connection.TryById <TenantsRow>(user.TenantId);
                    instagramAccount = tenant.InstagramAccount;
                }

            var url = string.Format("https://www.instagram.com/" + instagramAccount + "/?__a=1");

            var syncClient = new WebClient();
            var content    = syncClient.DownloadString(url);

            // Create the Json serializer and parse the response
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(Instagram.RootObject));

            Instagram.RootObject instagramData = null;
            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content)))
            {
                // deserialize the JSON object using the WeatherData type.
                instagramData = (Instagram.RootObject)serializer.ReadObject(ms);
            }

            return(View(MVC.Views.Common.Profile.ProfilePage, instagramData));
        }
Beispiel #2
0
        public async new Task <ActionResult> Index()
        {
            var host      = Request.Url.Host.Replace("www", "");
            var index     = host.IndexOf(".");
            var subdomain = host.Substring(0, index);

            var user             = (UserDefinition)Serenity.Authorization.UserDefinition;
            var t                = TenantsRow.Fields;
            var instagramAccount = "";

            using (var c = SqlConnections.NewByKey("Default"))
            {
                instagramAccount = c.Query <string>(
                    new SqlQuery()
                    .From(t)
                    .Select(t.InstagramAccount)
                    .Where(
                        new Criteria("[Domain]") == subdomain))
                                   .FirstOrDefault();
            }

            if (instagramAccount != "")
            {
                var url = string.Format("https://www.instagram.com/" + instagramAccount + "/?__a=1");

                var syncClient = new WebClient();
                var content    = syncClient.DownloadString(url);

                // Create the Json serializer and parse the response
                DataContractJsonSerializer serializer    = new DataContractJsonSerializer(typeof(Instagram.RootObject));
                Instagram.RootObject       instagramData = null;
                using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(content)))
                {
                    // deserialize the JSON object using the WeatherData type.
                    instagramData = (Instagram.RootObject)serializer.ReadObject(ms);
                }

                return(View(MVC.Views.Common.Store.StorePage, instagramData));
            }
            else
            {
                return(View(MVC.Views.Common.Store.StorePage));
            }
        }