Example #1
0
        /// <summary>
        /// 取消关注
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="caseid"></param>
        /// <returns></returns>
        public int removeFollow(string username, int caseid)
        {
            FollowCaseService dbfollow = new FollowCaseService();
            UserInfo          dbuser   = new UserInfo();
            string            userid   = dbuser.GetUseByName(username).Id;
            var followlist             = dbfollow.LoadEntities(t => t.caseid == caseid && t.userid == userid);

            if (followlist.Count() > 0)
            {
                var follow       = followlist.FirstOrDefault();
                var removeResult = dbfollow.DeleteEntity(follow);
                if (removeResult)
                {
                    return(dbfollow.LoadEntities(t => t.caseid == caseid).Count());//删除成功
                }
                else
                {
                    return(-1);//删除关注失败
                }
            }
            else
            {
                return(-2);//没有关注不能取消关注
            }
        }
Example #2
0
        /// <summary>
        /// 添加关注
        /// </summary>
        /// <param name="userid"></param>
        /// <param name="caseid"></param>
        /// <returns></returns>
        public int addFollow(string username, int caseid)
        {
            FollowCaseService dbfollow = new FollowCaseService();
            UserInfo          dbuser   = new UserInfo();
            string            userid   = dbuser.GetUseByName(username).Id;
            var followlist             = dbfollow.LoadEntities(t => t.caseid == caseid && t.userid == userid);

            if (followlist.Count() > 0)
            {
                return(-1);//不能重复关注
            }
            else
            {
                var addresult = dbfollow.AddEntity(new Models.M_FollowCase {
                    userid = userid, caseid = caseid
                });
                if (addresult.id != 0)
                {
                    return(dbfollow.LoadEntities(t => t.caseid == caseid).Count());
                }
                else
                {
                    return(-2);//上传数据库失败
                }
            }
        }
Example #3
0
        /// <summary>
        /// 返回个人主页数据
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public HomePerson userPage(string userid)
        {
            CaseService       dbcase    = new CaseService();
            FollowCaseService dbfollow  = new FollowCaseService();
            InvolveService    dbinvolve = new InvolveService();
            M_JiangliUser     user      = GetUserById(userid);

            if (userid == null)
            {
                return(null);
            }
            //关注
            var follow = dbfollow.LoadEntities(t => t.userid == userid);
            //参与
            var involve = dbinvolve.LoadEntities(t => t.UserID == userid);
            //已发布
            var publishlist = dbcase.LoadEntities(t => t.StateOfCase == WholeSituation.CaseState.PUBLISH && t.PublisherId == userid);
            //已完成
            var finishlist = dbcase.LoadEntities(t => t.StateOfCase == WholeSituation.CaseState.FINISH && t.PublisherId == userid);
            //参与的案件列表
            List <IQueryable <M_Case> > participatelist = new List <IQueryable <M_Case> >();
            //关注的案件列表
            List <IQueryable <M_Case> > followlist = new List <IQueryable <M_Case> >();

            //所有已关注案件
            if (follow.Count() != 0)
            {
                foreach (var followitem in follow)
                {
                    IQueryable <M_Case> caseitem = dbcase.LoadEntities(t => t.ID == followitem.caseid);
                    followlist.Add(caseitem);
                }
            }
            //所有参与案件
            if (involve.Count() != 0)
            {
                foreach (var involveitem in involve)
                {
                    IQueryable <M_Case> caseitem = dbcase.LoadEntities(t => t.ID == involveitem.CaseId);
                    participatelist.Add(caseitem);
                }
            }
            return(new HomePerson
            {
                userid = userid,
                username = user.UserName,
                hobby = user.Hobby,
                headimg = user.Avatar_url,
                weight = user.Weight,
                publishlist = publishlist,
                finishlist = finishlist,
                followlist = followlist,
                participatelist = participatelist,
            });
        }
Example #4
0
 /// <summary>
 /// 将Case原始模型转换成微信所需的格式
 /// </summary>
 /// <param name="c"></param>
 /// <returns></returns>
 private BasicCaseViewModel _getBasicCase(M_Case c)
 {
     return(new BasicCaseViewModel()
     {
         id = c.ID,
         cover = "",
         description = c.StatementOfCase,
         numberOfComment = dbcomment.LoadEntities(t => t.CaseId == c.ID),
         numberOfJoin = dbpart.LoadEntities(t => t.CaseId == c.ID),
         numberOfFollow = dbfollow.LoadEntities(t => t.caseid == c.ID),
         start_at = c.DateOfBegin.ToShortDateString(),
         state = c.StateOfCase,
         title = c.Title,
     });
 }
Example #5
0
        public WxCaseDetailViewModel _getCaseDetailById(int id)
        {
            BasicUserViewModel respondent = new BasicUserViewModel();
            M_Case             caseinfo   = dbcase.LoadEntities(t => t.ID == id).FirstOrDefault();
            var parts = dbpart.LoadEntities(t => t.CaseId == id);

            if (caseinfo.RespondentId != null)
            {
                respondent = dbuser.GetBasicUserById(caseinfo.RespondentId);
            }
            else
            {
                respondent = new BasicUserViewModel()
                {
                    nickname = caseinfo.Respondent,
                }
            };
            var owner = dbuser.GetBasicUserById(caseinfo.PublisherId);

            return(new WxCaseDetailViewModel()
            {
                user = owner,
                basic = new BasicCaseViewModel()
                {
                    description = caseinfo.StatementOfCase,
                    id = caseinfo.ID,
                    numberOfComment = dbcomment.LoadEntities(t => t.CaseId == id),
                    title = caseinfo.Title,
                    start_at = caseinfo.DateOfBegin.ToShortDateString(),
                    state = caseinfo.StateOfCase,
                    numberOfJoin = dbpart.LoadEntities(t => t.CaseId == id),
                    numberOfFollow = dbfollow.LoadEntities(t => t.caseid == id),
                    otherPay1 = caseinfo.OtherPay1,
                    otherPay2 = caseinfo.OtherPay2,
                    otherPay3 = caseinfo.OtherPay3,
                },
                imageSrc = caseinfo.Photo,
                involves = PartInfo.Current.GetPartsByCaseId(id),
                respondent = respondent,
                respondentturnone = caseinfo.TrunOneComplainByRespondent ?? "",
                respondentturntwo = caseinfo.TrunTwoComplainByRespondent ?? "",
                userturnone = caseinfo.TrunOneComplainByComplainant ?? "",
                userturntwo = caseinfo.TrunTwoComplainByComplainant ?? "",
                condition = caseinfo.Condition,
                orginalpay = caseinfo.originalpay,
            });
        }
    }
Example #6
0
        /// <summary>
        /// 公众获取案件信息
        /// </summary>
        /// <param name="caseid"></param>
        /// <returns></returns>
        public dynamic PublicCase(int caseid)
        {
            //通过caseid获取 用户 裁决 评论
            CaseService       dbcase    = new CaseService();
            InvolveService    dbinvolve = new InvolveService();
            CommentService    dbcomment = new CommentService();
            UserInfo          dbuser    = new UserInfo();
            FollowCaseService dbfollow  = new FollowCaseService();
            var casetemp = dbcase.LoadEntities(t => t.ID == caseid);

            if (casetemp == null)
            {
                return(null);
            }
            var caseitem = casetemp.FirstOrDefault();

            if (caseitem.StateOfCase != WholeSituation.CaseState.PUBLISH && caseitem.StateOfCase != WholeSituation.CaseState.FINISH)
            {
                return(null);
            }
            else
            {
                var follow = dbfollow.LoadEntities(t => t.caseid == caseitem.ID);
                //评论信息
                var            verdict = dbinvolve.LoadEntities(t => t.CaseId == caseitem.ID);
                var            comment = dbcomment.LoadEntities(t => t.CaseId == caseitem.ID).OrderByDescending(t => t.Date);;
                publiccaseitem result  = new publiccaseitem
                {
                    publishid      = caseitem.PublisherId,
                    publishname    = caseitem.Publisher,
                    userhead       = dbuser.GetUserById(caseitem.PublisherId) == null?"": dbuser.GetUserById(caseitem.PublisherId).Avatar_url,
                    respondentid   = caseitem.RespondentId,
                    respondentname = caseitem.Respondent,
                    respondenthead = dbuser.GetUserById(caseitem.RespondentId) == null?"": dbuser.GetUserById(caseitem.PublisherId).Avatar_url,
                    casestate      = caseitem.StateOfCase,
                    publishdata    = caseitem.DateOfBegin,
                    follow         = follow,
                    verdict        = verdict,
                    comment        = comment,
                    caseid         = caseitem.ID,
                    casetitle      = caseitem.Title,
                    casecontent    = caseitem.StatementOfCase,
                    caseinfo       = caseitem,
                };
                return(result);
            }
        }
Example #7
0
        public List <HomeCase> HomeCaseList()
        {
            //var adduser = dbUser.AddUser();
            //dbCase.AddEntity(new Models.M_Case { Title="添加测试案件",StatementOfCase="测试案件的一些声明信息",StateOfCase= WholeSituation.CaseState.PUBLISH ,PublisherId=adduser.Id});
            //需要通过案件获取 用户 关注 评论 裁决
            var caselist = dbCase.LoadEntities(t => t.StateOfCase == WholeSituation.CaseState.PUBLISH);
            var count    = caselist == null?0:caselist.Count();

            if (count == 0)
            {
                return(null);
            }
            List <HomeCase> result = new List <HomeCase>();

            foreach (var caseitem in caselist)
            {
                var user = dbUser.GetUserById(caseitem.PublisherId);
                if (user != null)
                {
                    var followList = dbFollow.LoadEntities(t => t.caseid == caseitem.ID);
                    //评论信息
                    var      comment  = dbComment.LoadEntities(t => t.CaseId == caseitem.ID);
                    var      involve  = dbInvolve.LoadEntities(t => t.CaseId == caseitem.ID);
                    HomeCase casetemp = new HomeCase
                    {
                        publishid   = user.Id,
                        publishname = user.UserName,
                        caseid      = caseitem.ID,
                        casetitle   = caseitem.Title,
                        casecontent = caseitem.StatementOfCase,
                        followlist  = followList,
                        commentlist = comment,
                        involvelist = involve,
                        publicdate  = caseitem.DateOfBegin,
                    };
                    result.Add(casetemp);
                }
            }
            return(result);
        }