Exemple #1
0
        public ActionResult ViewWPUserList()
        {
            WPModel wpmodel = new WPModel();

            using (var db = new SQLServerProxy())
            {
                var wordPressBL = new WordPressBL(db._wplocalEntities);
                wpmodel.UserList = wordPressBL.GetUserList();

                db.Dispose();
            }

            return(PartialView("_wpUserList", wpmodel));
        }
Exemple #2
0
        public ActionResult Index()
        {
            WPModel wpmodel = new WPModel();

            using (var db = new SQLServerProxy())
            {
                try
                {
                    var wordPressBL = new WordPressBL(db._wplocalEntities);
                    wpmodel.UserList = wordPressBL.GetUserList();
                    //ViewBag.wpPostList = wordPressBL.GetPostList();
                    wpmodel.PostList = wordPressBL.GetPostList();
                }
                catch (Exception e)
                {
                    if (e.GetType() == typeof(DbEntityValidationException))
                    {
                        DbEntityValidationException ex = (DbEntityValidationException)e;

                        foreach (var failure in ex.EntityValidationErrors)
                        {
                            foreach (var error in failure.ValidationErrors)
                            {
                                string aa = string.Format("- {0} : {1}", error.PropertyName, error.ErrorMessage);
                            }
                        }
                    }
                }
            }

            // test s

            string response = string.Empty;
            //http://localhost/wordpress/wp-json/posts
            string url        = "http://localhost/wordpress/wp-json/posts";
            object parameters = new
            {
                //cp_user_id = controlPanelUserID,
                //service_id = serviceId
            };

            try
            {
                //response = RestApi.GetApiResponse(url, "text/json", "GET", null);// RestApi.ObjectToJson(parameters)

                string responseResult = string.Empty;

                var httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
                httpWebRequest.ContentType = "text/json";
                httpWebRequest.Method      = "POST";

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        responseResult = streamReader.ReadToEnd();
                    }
                }

                //return JsonConvert.DeserializeObject<ListWPSitesSnapShotContainer>(response);
            }
            catch (Exception ex)
            {
                string error = ex.Message;
                //throw new RestfulAPIExeption(string.Format(
                //        "ErrorSource=({0}), ErrorMessage=({1}), StackTrace=({2})",
                //        ex.Source,
                //        ex.Message,
                //        ex.StackTrace));
            }

            // test e


            return(View(wpmodel));
        }