예제 #1
0
        /// <summary>
        /// 用户心得数据
        /// </summary>
        /// <returns></returns>
        public JsonResult TalkOfUserData()
        {
            int pageSize   = int.Parse(Request["pageSize"] ?? "5");
            int pageIndex  = int.Parse(Request["pageIndex"] ?? "1");
            int UserInfoId = Convert.ToInt32(Request["userInfoId"]);

            if (UserInfoId != LoginUser.UserInfoID)
            {
                var PageData = TalksService.GetPageEntities(pageSize, pageIndex, out int total, u => u.UserInfoID == UserInfoId && u.Status == delNormal, u => u.CreateTime, false).AsQueryable();
                var data     = LoadImagePath(PageData);
                if (data.Count > 0)
                {
                    return(Json(new { msg = "success", data }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
                }
            }
            else
            {
                var PageData = TalksService.GetPageEntities(pageSize, pageIndex, out int total, u => u.UserInfoID == UserInfoId, u => u.CreateTime, false).AsQueryable();
                var data     = LoadImagePath(PageData);
                if (data.Count > 0)
                {
                    return(Json(new { msg = "success", data }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
예제 #2
0
        public ActionResult GetTalkByUserId()
        {
            int pageSize  = int.Parse(Request["limit"] ?? "5");
            int offset    = int.Parse(Request["offset"] ?? "0");
            int pageIndex = (offset / pageSize) + 1;

            if (String.IsNullOrEmpty(Request["userId"]))
            {
                return(Json(new { total = 0, rows = "" }, JsonRequestBehavior.AllowGet));
            }
            int userId   = Convert.ToInt32(Request["userId"]);
            var pageData = TalksService.GetPageEntities(pageSize, pageIndex, out int total, u => u.UserInfoID == userId && u.Status == delNormal, u => u.CreateTime, false).Select(n => new { n.TalkID, n.UserInfo.UserInfoShowName, n.TalkImagePath, n.TalkFavorsNum, n.TalkContent, n.Status, n.CreateTime, n.ModfiedOn }).ToList();

            var data = new { total = total, rows = pageData };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
예제 #3
0
        public ActionResult GetTalksOfAuditing()
        {
            int pageSize  = int.Parse(Request["limit"] ?? "5");
            int offset    = int.Parse(Request["offset"] ?? "0");
            int pageIndex = (offset / pageSize) + 1;

            if (LoginOrganize.OrganizeInfoManageId != null)
            {
                var pageData = TalksService.GetPageEntities(pageSize, pageIndex, out int total, t => t.Status == delAuditing && t.OrganizeInfoID == LoginOrganize.OrganizeInfoID && t.UserInfoID != null, u => u.TalkID, true).Select(t => new { t.TalkID, t.UserInfoID, t.UserInfo.UserInfoShowName, t.UserInfo.UserInfoLoginId, t.OrganizeInfoID, t.OrganizeInfo.OrganizeInfoShowName, t.ModfiedOn, t.TalkContent, t.Status }).AsQueryable();
                var data     = new { total = total, rows = pageData.ToList() };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var pageData = TalksService.GetPageEntities(pageSize, pageIndex, out int total, t => t.Status == delAuditing && t.UserInfoID != null, u => u.TalkID, true).Select(t => new { t.TalkID, t.UserInfo.UserInfoLoginId, t.UserInfoID, t.UserInfo.UserInfoShowName, t.OrganizeInfoID, t.OrganizeInfo.OrganizeInfoShowName, t.ModfiedOn, t.TalkContent, t.Status }).AsQueryable();
                var data     = new { total = total, rows = pageData.ToList() };
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
        }
예제 #4
0
        public ActionResult TalkDetail(int id)
        {
            Talks         talks     = TalksService.GetEntities(u => u.TalkID == id).FirstOrDefault();
            List <String> imageList = new List <string>();

            if (talks.TalkImagePath != null)
            {
                var files = Directory.GetFiles(Request.MapPath(talks.TalkImagePath));
                foreach (var file in files)
                {
                    int i = file.LastIndexOf("\\");
                    imageList.Add(file.Substring(i + 1));
                }
            }
            ViewBag.ImgPath = talks.TalkImagePath;
            ViewBag.Images  = imageList;
            ViewBag.Content = talks.TalkContent;
            return(View());
        }
예제 #5
0
 public ActionResult Create(Talks talks)
 {
     if (talks.TalkContent.Length > 300 || talks.TalkContent.Length < 6)
     {
         return(Content("fail"));
     }
     talks.UserInfoID     = LoginUser.UserInfoID;
     talks.TalkFavorsNum  = 0;
     talks.CreateTime     = DateTime.Now;
     talks.ModfiedOn      = DateTime.Now;
     talks.Status         = delAuditing;
     talks.OrganizeInfoID = LoginUser.OrganizeInfoID;
     if (TalksService.AddTalks(talks))
     {
         return(Content("success"));
     }
     else
     {
         return(Content("fail"));
     }
 }
예제 #6
0
        public ActionResult Delete()
        {
            //if (string.IsNullOrEmpty(ids))
            //{
            //    return Content("Please Select!");
            //}
            //string[] strIds = Request["ids"].Split(',');
            //List<int> idList = new List<int>();
            //foreach (var strId in strIds)
            //{
            //    idList.Add(int.Parse(strId));
            //}
            //if (TalksService.DeleteListByLogical(idList))
            //{
            //    return Content("ok");
            //}
            //else
            //{
            //    return Content("error");
            //}
            int   tId   = Convert.ToInt32(Request["ids"]);
            Talks talks = TalksService.GetEntities(u => u.TalkID == tId).FirstOrDefault();

            if (talks == null)
            {
                return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                talks.Status = delDeleted;
                if (TalksService.Update(talks))
                {
                    return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { msg = "fail" }, JsonRequestBehavior.AllowGet));
                }
            }
        }
예제 #7
0
        public ActionResult EditOfList(String ids)
        {
            if (string.IsNullOrEmpty(ids))
            {
                return(Content("null"));
            }
            string[]   strIds = Request["ids"].Split(',');
            List <int> idList = new List <int>();

            foreach (var strId in strIds)
            {
                idList.Add(int.Parse(strId));
            }
            if (TalksService.NormalListByULS(idList))
            {
                return(Content("success"));
            }
            else
            {
                return(Content("fail"));
            }
        }
예제 #8
0
        public ActionResult DeleteOfList(String ids)
        {
            if (string.IsNullOrEmpty(ids))
            {
                return(Content("Please Select!"));
            }
            string[]   strIds = Request["ids"].Split(',');
            List <int> idList = new List <int>();

            foreach (var strId in strIds)
            {
                idList.Add(int.Parse(strId));
            }
            if (TalksService.InvalidListByULS(idList))
            {
                return(Content("ok"));
            }
            else
            {
                return(Content("error"));
            }
        }
예제 #9
0
        public ActionResult GetAllTalks()
        {
            int            pageSize       = int.Parse(Request["limit"] ?? "5");
            int            offset         = int.Parse(Request["offset"] ?? "0");
            int            pageIndex      = (offset / pageSize) + 1;
            TalkQueryParam talkQueryParam = new TalkQueryParam();

            if (!string.IsNullOrEmpty(Request["filter"]))
            {
                talkQueryParam = Newtonsoft.Json.JsonConvert.DeserializeObject <TalkQueryParam>(Request["filter"]);
            }
            talkQueryParam.PageSize  = pageSize;
            talkQueryParam.PageIndex = pageIndex;
            if (LoginOrganize.OrganizeInfoManageId != null)
            {
                talkQueryParam.OrganizeInfoID = LoginOrganize.OrganizeInfoID;
                talkQueryParam.isSuper        = false;
            }
            else
            {
                talkQueryParam.isSuper = true;
            }
            talkQueryParam.Total = 0;

            var pageData = TalksService.LoadPageData(talkQueryParam).Select(u => new
            {
                u.TalkID,
                u.UserInfo.UserInfoShowName,
                u.OrganizeInfo.OrganizeInfoShowName,
                u.TalkFavorsNum,
                u.CreateTime,
                u.Status,
                u.UserInfo.UserInfoLoginId
            }).AsQueryable();
            var data = new { total = talkQueryParam.Total, rows = pageData.ToList() };

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
예제 #10
0
 public TalksController()
 {
     this._service = new TalksService();
 }
예제 #11
0
 public TalksController(TalksService service)
 {
     this.service = service;
 }
예제 #12
0
        public JsonResult GetListData()
        {
            int pageSize  = int.Parse(Request["pageSize"] ?? "5");
            int pageIndex = int.Parse(Request["pageIndex"] ?? "1");
            var PageData  = TalksService.GetPageEntities(pageSize, pageIndex, out int total, u => u.Status == delNormal, u => u.CreateTime, false).AsQueryable();

            if (PageData.Count() > 0)
            {
                List <TalkViewModel> list = new List <TalkViewModel>();
                foreach (var data in PageData)
                {
                    TalkViewModel talk = new TalkViewModel();
                    talk.TalkID = data.TalkID;

                    talk.TalkFavorsNum = (int)data.TalkFavorsNum;
                    talk.CreateTime    = (DateTime)data.CreateTime;
                    if (data.UserInfo != null)
                    {
                        talk.ShowName = data.UserInfo.UserInfoShowName;
                        talk.Icon     = data.UserInfo.UserInfoIcon;
                    }
                    else
                    {
                        talk.ShowName = data.OrganizeInfo.OrganizeInfoShowName;
                        talk.Icon     = data.OrganizeInfo.OrganizeInfoIcon;
                    }
                    talk.TalkContent = data.TalkContent;

                    if (data.TalkImagePath != null)
                    {
                        try
                        {
                            var           files    = Directory.GetFiles(Request.MapPath(data.TalkImagePath));
                            List <String> pathlist = new List <String>();
                            foreach (var file in files)
                            {
                                int i = file.LastIndexOf("\\");
                                pathlist.Add(data.TalkImagePath + file.Substring(i + 1));
                            }
                            talk.ImagePath = pathlist;
                        }
                        catch (Exception)
                        {
                        }
                    }
                    talk.UserInfoId = (int)data.UserInfoID;
                    if (LoginUser != null)
                    {
                        talk.Favors = FavorsService.GetEntities(u => u.TalkID == talk.TalkID && u.UserInfoID == LoginUser.UserInfoID).Count() > 0;
                    }
                    else
                    {
                        talk.Favors = false;
                    }
                    list.Add(talk);
                }
                return(Json(new { msg = "success", data = list }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { msg = "fail" }));
            }
        }