コード例 #1
0
        public ActionResult CreateComment(Comment model)
        {
            try
            {
                //产生评论
                var id = CheckValid();
                var name = GetUserNameById(id);
                var com = new Comment
                {
                    ActionTime = DateTime.Now,
                    Content = model.Content,
                    TopicId = model.TopicId,
                    ReplyId = model.ReplyId,
                    UserId = id,
                    UserName = name
                };
                LoveDb.Add(com);

                //加入消息?
                var topic = LoveDb.One((Topic t) => t.Id == model.TopicId);
                if (topic != null)
                {
                    if (topic.UserId != id)//回复这个话题不是楼主本人  就通知楼主。
                    {
                        var msg = new Message
                        {
                            ActionTime = DateTime.Now,
                            Content =
                                string.Format(
                                    "<a href='/User/Index?id={0}'>{1}</a>回复了你的话题:<a href='/Interactive/Detail?topicId={2}'>{3}</a>"
                                    , id, name, topic.Id, topic.Title),
                            FromUserId = 1,
                            FromUserName = "******",
                            IsReaded = false,
                            MegType = MegType.System,
                            StateId = topic.Id,
                            StateType = StateType.Topic,
                            ToUserId = topic.UserId,
                        };
                        LoveDb.Add(msg);
                    }

                    if (com.ReplyId != 0)
                    {
                        var recom = LoveDb.One((Comment c) => c.Id == com.ReplyId);
                        if (recom != null)
                        {
                            var msg = new Message
                            {
                                ActionTime = DateTime.Now,
                                Content =
                                    string.Format(
                                        "<a href='/User/Index?id={0}'>{1}</a>回复了你的,话题:<a href='/Interactive/Detail?topicId={2}'>{3}</a>"
                                        , id, name, topic.Id, topic.Title),
                                FromUserId = 1,
                                FromUserName = "******",
                                IsReaded = false,
                                MegType = MegType.System,
                                StateId = recom.Id,
                                StateType = StateType.Comment,
                                ToUserId = recom.UserId,
                            };
                            LoveDb.Add(msg);
                        }
                    }

                }

                return Json(1);
            }
            catch (Exception)
            {

                return Json(0);
            }
        }
コード例 #2
0
        public JsonResult EnjoyTopic(int topicid)
        {
            var id = CheckValid();
            var name = GetUserNameById(id);
            var topic = LoveDb.One((Topic t) => t.Id == topicid);
            if (topic != null)
            {
                if (id==topic.UserId)
                {
                    return Json(0);
                }

            var love = LoveDb.One((EnjoyTopic m) => m.TopicId == topicid && m.UserId == id);

            if (love != null)//存在 就删除
            {
                LoveDb.Delete<EnjoyTopic>(love.Id);
                var msg1 =
                    LoveDb.One(
                        (Message m) =>
                            m.StateType == StateType.Topic && m.StateId == topicid && m.Content.Contains(name));
                if (msg1 != null)
                {
                    LoveDb.Delete<Message>(msg1.Id);
                }

                return Json(0);//已经取消喜欢
            }

            love = new EnjoyTopic
            {
                TopicId = topicid,
                UserId = id,
                ActionTime = DateTime.Now,
                IsRead = false,
            };
            LoveDb.Add(love);

            //系统消息通知下

                var msg = new Message
                {
                    ActionTime = DateTime.Now,
                    Content =
                        string.Format(
                            "<a href='/User/Index?id={0}'>{1}</a>喜欢了你的话题:<a href='/Interactive/Detail?topicId={2}'>{3}</a>"
                            , id,name , topicid, topic.Title),
                    FromUserId = 1,
                    FromUserName = "******",
                    IsReaded = false,
                    MegType = MegType.System,
                    StateId = topicid,
                    StateType = StateType.Topic,
                    ToUserId = topic.UserId,
                };
                LoveDb.Add(msg);
                return Json(1);
            }
            return Json(0);
        }
コード例 #3
0
ファイル: AdminController.cs プロジェクト: hxhlb/FindLover
        /// <summary>
        /// 处理举报
        /// </summary>
        /// <param name="reportId"></param>
        /// <returns></returns>
        public ActionResult DealReport(int reportId)
        {
            // 设置为done
            var report = LoveDb.One((Report r) => r.Id == reportId);
            if (report == null || report.IsDone)
            {
                return null;
            }
            LoveDb.DoneReport(reportId);
            //发给举报人 说信息已经处理 如果已经处理或者不存在就返回
            var id = CheckValid();
            var msg = new Message
            {
                ActionTime = DateTime.Now,
                Content = string.Format("你在{0}举报{1}的信息,管理员已经处理,谢谢你的监督!", report.ActionTime, report.ReportedUserName),
                FromUserId = id,
                FromUserName = "******",
                IsReaded = false,
                ToUserId = report.UserId,
                MegType = MegType.System,
                StateType = StateType.None,
            };
            LoveDb.Add(msg);

            //记录管理员 处理的情况
            var log = new ReportLog
            {
                ActionTime = DateTime.Now,
                AdminId = id,
                ReportId = reportId,

            };
            LoveDb.Add(log);

            return Json("1");
        }
コード例 #4
0
ファイル: AdminController.cs プロジェクト: hxhlb/FindLover
        /// <summary>
        /// 解封
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public JsonResult UnForbidUser(int userid)
        {
            if (LoveDb.One((User e) => e.UserId == userid).Enable == 1)
            {
                return Json(0);//已经被封禁过
            }

            LoveDb.UnForbidUser(userid);
            //通知此人
            var msg = new Message
            {
                ActionTime = DateTime.Now,
                Content = string.Format("你的账户已经解封,祝你愉快。"),
                FromUserId = CheckValid(),
                FromUserName = "******",
                IsReaded = false,
                ToUserId = userid,
                MegType = MegType.System,
                StateType = StateType.None,
            };
            LoveDb.Add(msg);

            Logger.Trace(GetUserNameById(userid) + "被管理员:" + GetUserNameById(CheckValid()) + "解封");
            return Json(1);//操作成功
        }
コード例 #5
0
ファイル: AdminController.cs プロジェクト: hxhlb/FindLover
        /// <summary>
        /// 封号
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public JsonResult ForbidUser(int userid)
        {
            if (LoveDb.One((User e) => e.UserId == userid).Enable == 0)
            {
                return Json(0);//已经被封禁过
            }

            LoveDb.ForbidUser(userid);
            //通知此人
            var msg = new Message
            {
                ActionTime = DateTime.Now,
                Content = string.Format("由于你的非法操作和举报信息,你的号已经被系统封禁,该账户功能会被大量削弱!如有问题请联系管理员"),
                FromUserId = CheckValid(),
                FromUserName = "******",
                IsReaded = false,
                ToUserId = userid,
                MegType = MegType.System,
                StateType = StateType.None,
            };
            LoveDb.Add(msg);

            Logger.Trace(GetUserNameById(userid) + "被管理员:" + GetUserNameById(CheckValid()) + "封号");

            return Json(1);//操作成功
        }
コード例 #6
0
ファイル: MessageController.cs プロジェクト: hxhlb/FindLover
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="toid"></param>
        /// <param name="content"></param>
        /// <param name="type">msgtype 0为私信,1为系统消息</param>
        /// <param name="statetype">statetype</param>
        /// <param name="stateid">stateid</param>
        /// <returns></returns>
        public JsonResult SendMessage(int toid, string content, int type, int statetype, int stateid)
        {
            var id = CheckValid();
            var name =GetUserNameById(id);
            Message msg;
            if (type == 0)
            {
                msg = new Message
                {
                    ToUserId = toid,
                    FromUserId = id,
                    FromUserName = name,
                    Content = content,
                    IsReaded = false,
                    MegType = MegType.Private,
                    ActionTime = DateTime.Now,
                    StateId = stateid,//表示是状态 纯私信 图片
                    StateType = (StateType)statetype
                };
                //try
                //{
                //  //  var user1 = LoveDb.One((User u) => u.UserId == toid);
                //  //  SystemSendMail(user1.Email, "意中人_私信", string.Format("{0}给你发私信了快去看看吧,<a href='http://cnwj6iapc006:81/Message/CheckPrivateMessage'>查看私信</a>", user1.UserName));
                //}
                //catch
                //{

                //}
            }
            else
            {
                msg = new Message
                {
                    ToUserId = toid,
                    FromUserId = id,
                    FromUserName = "******",
                    Content = content,
                    IsReaded = false,
                    MegType = MegType.System,
                    ActionTime = DateTime.Now,
                };
            }

            LoveDb.Add(msg);
            return Json(msg);
        }