示例#1
0
        /// <summary>
        /// 增加一个不感兴趣的人
        /// </summary>
        /// <param name="userid"></param>
        /// <returns>1表示添加成功0表示取消</returns>
        public JsonResult AddDisLike(int userid)
        {
            var id = CheckValid();
            var love = PrivateDb.One((DisLove m) => m.DisLoveId == userid && m.UserId == id);
            if (love != null)//存在 就删除
            {
                PrivateDb.Delete<DisLove>(love.Id);
                return Json(0);//已经取消喜欢
            }

            love = new DisLove
            {
                DisLoveId = userid,
                UserId = id,
                ActionTime = DateTime.Now,
            };
            PrivateDb.Add(love);
            return Json(1);
        }
示例#2
0
        /// <summary>
        /// 添加举报信息
        /// </summary>
        /// <param name="reportedId">被举报者Id</param>
        /// <param name="reportedName">被举报者姓名</param>
        /// <param name="description">描述</param>
        /// <param name="isReport">是否举报 因为拉黑优先</param>
        /// <param name="relateId">相关Id</param>
        /// <param name="reportType">举报类型(是举报人 还是举报私信 状态这些)</param>
        /// <param name="messageType">举报信息类型(举报信息是色情 骚扰还是什么)</param>
        /// <returns></returns>
        public JsonResult ReportDeal(int reportedId, string reportedName, string description, bool isReport, int relateId, string reportType, string messageType)
        {
            var id = CheckValid();
            var name = GetUserNameById(id);

            //重复举报判断
            if (PrivateDb.One(r => r.ReportType == GetReportType(reportType) && r.RelateId == relateId) != null)
            {
                return Json("2");
            }

            //处理拉黑。 取消两者的喜欢关系。加入黑名单 黑名单还么有创建 - -!
            //取消喜欢关系 是多个
            if (reportedId != id && GetSex(id) != GetSex(reportedId))
            {
                var loveone = PrivateDb.MyLoveAll().Where(n => (n.UserId == id && n.LoverId == reportedId) || (n.LoverId == id && n.UserId == reportedId));
                foreach (var myLove in loveone)
                {
                    PrivateDb.Delete<MyLove>(myLove.Id);
                }
                //加入黑名单
                var dislike = PrivateDb.DisLoveAll().SingleOrDefault(n => (n.UserId == id && n.DisLoveId == reportedId));
                if (dislike == null)
                {
                    dislike = new DisLove
                    {
                        ActionTime = DateTime.Now,
                        DisLoveId = reportedId,
                        UserId = id,
                    };
                    PrivateDb.Add(dislike);
                }
            }

            //举报处理
            if (isReport)
            {
                var report = new Report
                {
                    ActionTime = DateTime.Now,
                    Description = description,
                    RelateId = relateId,
                    ReportedUserId = reportedId,
                    ReportedUserName = reportedName,
                    UserId = id,
                    UserName = name,
                    ReportType = GetReportType(reportType),
                    MessageType = GetMessageType(messageType)
                };

                PrivateDb.Add(report);
            }

            SystemSendMail(DefaultAdminMailAdress, "信息举报", "有举报,速度处理");
            //信息,mail 通知管理员。
            return Json("1");//1 成功 2表示举报过
        }