Ejemplo n.º 1
0
        public JsonResult BlogsContent(string content)
        {
            var form = Request.Form;
            var data = JsonConvert.SerializeObject(
                new
            {
                blogsId  = form["blogsId"],
                title    = form["title"],
                content  = content,
                category = form["category"],
                tips     = form["tips"],
                date     = form["date"]
            });
            var result = SignApiPostExtension.PostAsyc <string>("http://localhost:13292/Api/Blogs/SaveBlogs", data, ConfigManagerExtension.AppId);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="email"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public JsonResult LoginView(string email, string password)
        {
            var data = JsonConvert.SerializeObject(new { email = email, passWord = password });
            //var name = SignApiPostExtension.Post<string>("http://localhost:13292/Api/User/UserLogin", data, ConfigManagerExtension.AppId);
            var Dto = SignApiPostExtension.PostAsyc <List <string> >("http://localhost:13292/Api/User/UserLogin", data, ConfigManagerExtension.AppId);

            if (Dto.Count != 0)
            {
                Session["username"] = Dto[0].ToString();
                TempData["Id"]      = Dto[1].ToString();
                return(Json(new { info = "登录成功!", Id = Dto[1].ToString() }, JsonRequestBehavior.DenyGet));
            }
            else
            {
                return(Json(new { info = "登录失败!" }, JsonRequestBehavior.DenyGet));
            }
        }
Ejemplo n.º 3
0
        public JsonResult FileInput()
        {
            string Path = Server.MapPath("~/Images");
            HttpFileCollectionBase files = Request.Files;
            NameValueCollection    param = Request.Form;
            string Folder = DateTime.Now.ToString("yyyy-MM-dd");
            //保存文件的绝对路劲
            string Road = Path + @"\" + Folder + @"\";
            //保存在数据库的映射路劲
            string SqlMapPath = @"~/Images/" + Folder + @"/";
            //文件名称
            string FileName = string.Empty;
            //数据库的完整路径
            string SqlTotalPath = string.Empty;

            if (!Directory.Exists(Road))
            {
                Directory.CreateDirectory(Road);
            }
            //遍历文件
            if (files.Count > 0 && files != null)
            {
                for (int i = 0; i < files.Count; i++)
                {
                    FileName = files[i].FileName;
                    files[i].SaveAs(Road + FileName);
                }
            }
            SqlTotalPath = SqlMapPath + FileName;
            string data = JsonConvert.SerializeObject(
                new
            {
                imgId   = param["UserId"],
                imgName = FileName,
                imgUrl  = SqlTotalPath
            });
            string result = SignApiPostExtension.PostAsyc <string>("http://localhost:13292/Api/ImgFiles/SaveFileToSql", data, ConfigManagerExtension.AppId);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }