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 JsonResult AddWPUser(WPUserAddModel model)
        {
            var result = new JsonObject();

            try
            {
                using (var db = new SQLServerProxy())
                {
                    var wordPressBL = new WordPressBL(db._wplocalEntities);
                    wordPressBL.InsertWPUser(model.LoginID, model.LastName, model.FirstName, model.Email);

                    db.Dispose();
                }
                result.SetResult(true);
            }
            catch (Exception)
            {
                result.AddError("errorMessage", "サーバーエラーが発生しました。");
            }

            return(Json(result, "text/json", Encoding.UTF8, JsonRequestBehavior.DenyGet));
        }
Exemple #3
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));
        }