public JsonResult XihuanPinglun(int DianzanRen, int DakaBiji, int DakaRen, int Kongjian, int ProductBook, int Peibanshi, int DzPinglun, int Pinglunren, bool status)
        {
            DianzanPinglun dianzan = new DianzanPinglun();

            dianzan.Dianzan     = status;
            dianzan.DakaRen     = DakaRen;
            dianzan.Kongjian    = Kongjian;
            dianzan.ProductBook = ProductBook;
            dianzan.Peibanshi   = Peibanshi;
            dianzan.DzPinglun   = DzPinglun;
            dianzan.Pinglunren  = Pinglunren;
            dianzan.DianzanRen  = DianzanRen;
            dianzan.DakaBiji    = DakaBiji;
            dianzan.CreateTime  = System.DateTime.Now;

            Message msg = new Message();

            try
            {
                var dianzan_pinglun = unitOfWork._dianzanPinglunsRepository.Get(filter: u => u.DzPinglun == DzPinglun && u.DianzanRen == DianzanRen);

                if (dianzan_pinglun.Count() > 0)
                {
                    DianzanPinglun _dianzan = dianzan_pinglun.First();
                    _dianzan.Dianzan    = dianzan.Dianzan;
                    _dianzan.CreateTime = System.DateTime.Now;
                    unitOfWork._dianzanPinglunsRepository.Update(_dianzan);
                }
                else
                {
                    dianzan.CreateTime = System.DateTime.Now;
                    unitOfWork._dianzanPinglunsRepository.Insert(dianzan);
                }
                unitOfWork.Save();

                msg.MessageStatus = "true";
                msg.MessageInfo   = "点赞成功";
            }
            catch
            {
                msg.MessageStatus = "false";
                msg.MessageInfo   = "点赞失败";
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public JsonResult XihuanPinglun(int Dianzanren, int BijiZuozhe, int Dushuying, int Shumu, int Peiduren, int DZPinglun, int Pinglunren, bool status)
        {
            DianzanPinglun dianzan = new DianzanPinglun();

            dianzan.Dianzan    = status;
            dianzan.Dianzanren = Dianzanren;
            dianzan.BijiZuozhe = BijiZuozhe;
            dianzan.Dushuying  = Dushuying;
            dianzan.Shumu      = Shumu;
            dianzan.Peiduren   = Peiduren;
            dianzan.DZPinglun  = DZPinglun;
            dianzan.Pinglunren = Pinglunren;
            dianzan.Dianzanren = Dianzanren;
            dianzan.CreateTime = System.DateTime.Now;

            Message msg = new Message();

            try
            {
                var dianzan_pinglun = unitOfWork.dianzanPinglunsRepository.Get(filter: u => u.DZPinglun == DZPinglun && u.Dianzanren == Dianzanren);

                if (dianzan_pinglun.Count() > 0)
                {
                    DianzanPinglun _dianzan = dianzan_pinglun.First();
                    _dianzan.Dianzan    = dianzan.Dianzan;
                    _dianzan.CreateTime = System.DateTime.Now;
                    unitOfWork.dianzanPinglunsRepository.Update(_dianzan);
                }
                else
                {
                    dianzan.CreateTime = System.DateTime.Now;
                    unitOfWork.dianzanPinglunsRepository.Insert(dianzan);
                }
                unitOfWork.Save();

                msg.MessageStatus = "true";
                msg.MessageInfo   = "点赞成功";
            }
            catch
            {
                msg.MessageStatus = "false";
                msg.MessageInfo   = "点赞失败";
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }