Пример #1
0
        public JsonResult UpdateContent(EditContentModel model)
        {
            JsonModel jm = new JsonModel();

            try
            {
                ISocialCircleBLL socialCircleBLL = BLLFactory <ISocialCircleBLL> .GetBLL("SocialCircleBLL");

                var sc = socialCircleBLL.GetEntity(s => s.Id == model.Id);
                if (sc != null)
                {
                    //修改名称
                    sc.Content = model.Content;
                    socialCircleBLL.Update(sc);
                }
                else
                {
                    jm.Msg = "圈子已不存在";
                }
            }
            catch
            {
                jm.Msg = "请求发生异常";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public JsonResult UpdateImg(int id, string Img)
        {
            JsonModel jm = new JsonModel();

            try
            {
                ISocialCircleBLL socialCircleBLL = BLLFactory <ISocialCircleBLL> .GetBLL("SocialCircleBLL");

                var sc = socialCircleBLL.GetEntity(s => s.Id == id);
                if (sc != null)
                {
                    if (!string.IsNullOrEmpty(Img))
                    {
                        string oldImgPath = sc.HeadImgPath;

                        //头像路径保存
                        sc.HeadImgPath = GetMultimedia(ConstantParam.SOCIAL_CIRCLE_HEAD_DIR, Img);
                        socialCircleBLL.Update(sc);

                        //删除旧头像
                        if (!string.IsNullOrEmpty(oldImgPath))
                        {
                            FileInfo f = new FileInfo(Server.MapPath(oldImgPath));
                            if (f.Exists)
                            {
                                f.Delete();
                            }
                        }
                    }
                }
                else
                {
                    jm.Msg = "圈子已不存在";
                }
            }
            catch
            {
                jm.Msg = "请求发生异常";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }