public ActionResult SaveHouseScore(HouseEvaluateView model)
        {
            string status = "fail";
            string msg    = "评论失败!";
            var    order  = OperateContext.Current.BLLSession.IOrderInfoBLL.GetListBy(h => h.ID == model.ID).FirstOrDefault();

            if (order == null)
            {
                status = "fail";
                msg    = "未查询到订单信息!";
                return(OperateContext.Current.RedirectAjax(status, msg, null, null));
            }
            order.IsEvaluate = true;
            OperateContext.Current.BLLSession.IOrderInfoBLL.Modify(order, "IsEvaluate");
            var averageScore = (model.CleanScore + model.LocationScore + model.EnvironmentScore + model.ServiceScore + model.PerformanceScore) / 5;
            var house        = OperateContext.Current.BLLSession.IHouseInfoBLL.GetListBy(h => h.ID == order.HouseInfoID).FirstOrDefault();

            if (house != null)
            {
                //
                //var houseEvaluates = OperateContext.Current.BLLSession.IHouseEvaluateBLL.GetListBy(h => h.HouseInfoID == house.ID).ToList();
                //if(houseEvaluates.Count > 0)
                //{

                //}
                house.EvaluateNum      += 1;
                house.EvaluateAvgScore += averageScore;
                OperateContext.Current.BLLSession.IHouseInfoBLL.Modify(house, "EvaluateNum", "EvaluateAvgScore");
            }
            HouseEvaluate evaluate = new HouseEvaluate();

            evaluate.HouseInfoID      = order.HouseInfoID;
            evaluate.UserInfoID       = order.UserInfoID;
            evaluate.UserPhone        = order.UserPhone;
            evaluate.CleanScore       = model.CleanScore;
            evaluate.LocationScore    = model.LocationScore;
            evaluate.EnvironmentScore = model.EnvironmentScore;
            evaluate.ServiceScore     = model.ServiceScore;
            evaluate.PerformanceScore = model.PerformanceScore;
            evaluate.AverageScore     = averageScore;
            evaluate.EvaluateContent  = model.Comments;
            evaluate.State            = 0;
            evaluate.HouseTitle       = order.HouseTitle;
            evaluate.Username         = order.Username;
            evaluate.CreateTime       = DateTime.Now;
            var userInfo = OperateContext.Current.BLLSession.IUserInfoBLL.GetListBy(h => h.ID == order.UserInfoID).FirstOrDefault();

            if (userInfo != null)
            {
                evaluate.UserImg = userInfo.Img;
            }
            var result = OperateContext.Current.BLLSession.IHouseEvaluateBLL.Add(evaluate);

            if (result > 0)
            {
                status = "ok";
                msg    = "评论成功!";
            }
            return(OperateContext.Current.RedirectAjax(status, msg, null, null));
        }
        public ActionResult HouseCommentView(long id)
        {
            HouseEvaluate ev    = null;
            var           order = OperateContext.Current.BLLSession.IOrderInfoBLL.GetListBy(m => m.ID == id).FirstOrDefault();

            if (order != null)
            {
                ev = OperateContext.Current.BLLSession.IHouseEvaluateBLL.GetListBy(h => h.HouseInfoID == order.HouseInfoID && h.UserInfoID == order.UserInfoID, h => h.CreateTime, false).FirstOrDefault();
            }
            if (ev == null)
            {
                ev = new HouseEvaluate();
            }
            if (order == null)
            {
                order = new OrderInfo();
            }
            ViewBag.Order = order;
            return(View(ev));
        }
        public ActionResult DelEvaluateByID(long id)
        {
            string status = "fail";
            string msg    = "删除失败!";

            HouseEvaluate houseEvaluate = OperateContext.Current.BLLSession.IHouseEvaluateBLL.GetListBy(m => m.ID == id).FirstOrDefault();

            if (houseEvaluate != null)
            {
                houseEvaluate.State = -1;
                int result = OperateContext.Current.BLLSession.IHouseEvaluateBLL.Modify(houseEvaluate);

                if (result == 1)
                {
                    status = "ok";
                    msg    = "删除成功!";
                }
            }

            return(OperateContext.Current.RedirectAjax(status, msg, null, null));
        }