Exemplo n.º 1
0
        public ActionResult Create(ShopCommentViewModel commentViewModel)
        {
            if (ModelState.IsValid)
            {
                ShopComment comment = new ShopComment()
                {
                    Id        = commentViewModel.CommentId,
                    ShopId    = commentViewModel.ShopId,
                    Comment   = commentViewModel.Comment,
                    CreatedAt = DateTime.Now,
                    IsActive  = true,
                    UserId    = WebSecurity.CurrentUserId
                };

                try
                {
                    _shopCommentRepository.Save(comment);
                }
                catch (DataException)
                {
                    TempData["error"] = ProjectConfiguration.Get.DataErrorMessage;
                }

                return(RedirectToAction("Details", "Shop", new { Id = comment.ShopId }));
            }
            else
            {
                TempData["Comment"] = commentViewModel.Comment;
                return(RedirectToAction("Details", "Shop", new { Id = commentViewModel.ShopId }));
            }
        }
        public ActionResult _AddShopComment(ShopCommentModel comment)//int shopID, string title, string comment, string userName)
        {
            if (comment != null)
            {
                ShopComment c = new ShopComment();
                c.ShopID   = comment.ShopID;
                c.UserName = comment.UserName;
                c.Text     = comment.Text;
                c.Title    = comment.Title;

                ShoppingService.AddShopComment(c);
                return(PartialView("_ShopComment", comment));
            }
            return(Content(string.Empty));
        }
Exemplo n.º 3
0
        public void Enrich(IHalResponseBuilder halResponseBuilder, ShopComment shopComment, string shopId)
        {
            if (halResponseBuilder == null)
            {
                throw new ArgumentNullException(nameof(halResponseBuilder));
            }

            if (shopComment == null)
            {
                throw new ArgumentNullException(nameof(shopComment));
            }

            halResponseBuilder.AddEmbedded(e => e.AddObject(_responseBuilder.GetShopComment(shopComment),
                                                            (l) => l.AddOtherItem("shop", new Dtos.Link("/" + Constants.RouteNames.Shops + "/" + shopId))));
        }
Exemplo n.º 4
0
        public static int AddShopComment(ShopComment item)
        {
            string spName = "cudo_createshopcomment";

            SqlParameter[] paramvalues = new SqlParameter[]
            {
                new SqlParameter("@shopid", item.ShopId),
                new SqlParameter("@userid", item.UserId),
                new SqlParameter("@username", item.UserName),
                new SqlParameter("@point", item.TotalPoint),
                new SqlParameter("@tastepoint", item.TastePoint),
                new SqlParameter("@milieupoint", item.MilieuPoint),
                new SqlParameter("@servicepoint", item.ServicePoint),
                new SqlParameter("@commentcontent", item.CommentContent)
            };
            return(SqlHelper.ExecuteNonQuery(SqlHelper.ConnectionString, CommandType.StoredProcedure, spName, paramvalues));
        }
        public static ShopComment AddShopComment(ShopComment commen, int ParentID = 0, Guid UserID = new Guid())
        {
            var c = new ShopComment();

            if (UserID == Guid.Empty && LS.isHaveID())
            {
                UserID = LS.CurrentUser.ID;
            }
            c.UserID     = UserID;
            c.ParentID   = ParentID;
            c.ShopID     = commen.ShopID;
            c.Text       = commen.Text;
            c.Title      = commen.Title;
            c.UserName   = commen.UserName;
            c.CreateTime = DateTime.Now;
            LS.CurrentEntityContext.ShopComments.Add(c);
            LS.CurrentEntityContext.SaveChanges();
            return(c);
        }
Exemplo n.º 6
0
        public async Task Handle(AddShopCommentCommand message)
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            var record = await _shopRepository.Get(message.ShopId);

            if (record == null)
            {
                return;
            }

            var shopComment = new ShopComment
            {
                Id             = message.Id,
                Content        = message.Content,
                Score          = message.Score,
                Subject        = message.Subject,
                CreateDateTime = message.CreateDateTime,
                UpdateDateTime = message.UpdateDateTime
            };

            record.AddComment(shopComment);
            await _shopRepository.Update(record);

            _eventPublisher.Publish(new ShopCommentAddedEvent
            {
                Id             = message.Id,
                ShopId         = message.ShopId,
                Content        = message.Content,
                Score          = message.Score,
                Subject        = message.Subject,
                CreateDateTime = message.CreateDateTime,
                UpdateDateTime = message.UpdateDateTime,
                AverageScore   = record.AverageScore,
                NbComments     = record.Comments == null ? 0 : record.Comments.Count(),
                CommonId       = message.CommonId
            });
        }
Exemplo n.º 7
0
        public static ShopComment GetShopComment(int id)
        {
            ShopComment item   = new ShopComment();
            string      spName = "cudo_getshopcommentbyid";

            SqlParameter[] paramvalues = new SqlParameter[]
            {
                new SqlParameter("@id", id)
            };
            SqlDataReader dataReader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.StoredProcedure, spName, paramvalues);

            try
            {
                if (dataReader.Read())
                {
                    item.Id             = id;
                    item.ShopId         = Convert.ToInt32(dataReader["shopid"]);
                    item.UserId         = Convert.ToInt32(dataReader["userid"]);
                    item.UserName       = dataReader["username"].ToString();
                    item.TotalPoint     = Convert.ToInt32(dataReader["point"]);
                    item.TastePoint     = Convert.ToInt32(dataReader["tastepoint"]);
                    item.MilieuPoint    = Convert.ToInt32(dataReader["milieupoint"]);
                    item.ServicePoint   = Convert.ToInt32(dataReader["servicepoint"]);
                    item.CommentContent = dataReader["commentcontent"].ToString();
                    item.CheckStatus    = Convert.ToInt32(dataReader["checkstatus"]);
                    item.AddTime        = Convert.ToDateTime(dataReader["addtime"]);
                }
            }
            catch
            {
                dataReader.Close();
                dataReader.Dispose();
            }
            finally
            {
                dataReader.Close();
                dataReader.Dispose();
            }
            return(item);
        }
Exemplo n.º 8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ShopCommentBLL bll   = new ShopCommentBLL();
            UserInfo       uinfo = Session["cudoUser"] as UserInfo;
            ShopComment    item  = new ShopComment();

            item.TotalPoint     = Convert.ToInt32(stars_input.Value);
            item.TastePoint     = Convert.ToInt32(ddltaste.Value);
            item.MilieuPoint    = Convert.ToInt32(ddlmilieu.Value);
            item.ServicePoint   = Convert.ToInt32(ddlservice.Value);
            item.CommentContent = txtcontent.Value;
            item.ShopId         = shopid;
            item.UserId         = uinfo.Id;
            item.UserName       = uinfo.UserName;
            if (bll.AddShopComment(item) > 0)
            {
                Utils.alert("评价成功,感谢您的参与!", "mycommentlist.aspx");
            }
            else
            {
                Utils.alert("评价失败!", "createcomment.aspx?shopid=" + shopid);
            }
        }
Exemplo n.º 9
0
        private static List <ShopComment> GetList(string spName, SqlParameter[] paramvalues)
        {
            List <ShopComment> list       = new List <ShopComment>();
            SqlDataReader      dataReader = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.StoredProcedure, spName, paramvalues);

            try
            {
                while (dataReader.Read())
                {
                    ShopComment item = new ShopComment();
                    item.Id             = Convert.ToInt32(dataReader["id"]);
                    item.ShopId         = Convert.ToInt32(dataReader["shopid"]);
                    item.UserId         = Convert.ToInt32(dataReader["userid"]);
                    item.UserName       = dataReader["username"].ToString();
                    item.TotalPoint     = Convert.ToInt32(dataReader["point"]);
                    item.TastePoint     = Convert.ToInt32(dataReader["tastepoint"]);
                    item.MilieuPoint    = Convert.ToInt32(dataReader["milieupoint"]);
                    item.ServicePoint   = Convert.ToInt32(dataReader["servicepoint"]);
                    item.CommentContent = dataReader["commentcontent"].ToString();
                    item.CheckStatus    = Convert.ToInt32(dataReader["checkstatus"]);
                    item.AddTime        = Convert.ToDateTime(dataReader["addtime"]);
                    item.ShopName       = ShopsDAL.GetShopItem(item.ShopId).ShopName;
                    list.Add(item);
                }
            }
            catch
            {
                dataReader.Close();
                dataReader.Dispose();
            }
            finally
            {
                dataReader.Close();
                dataReader.Dispose();
            }
            return(list);
        }
Exemplo n.º 10
0
        public APIResult Add([FromBody] AddArgsModel args)
        {
            var memberId = GetMemberId();
            var model    = new ShopComment()
            {
                AddTime  = DateTime.Now,
                MemberId = memberId,
                ShopId   = args.ShopId,
                KeyWord  = args.KeyWord,
                Content  = args.Content,
                Grade    = args.Grade
            };

            db.AddTo <ShopComment>(model);
            db.SaveChanges();

            db.Query <ShopCommentPicture>()
            .Where(m => args.PicIds.IndexOf(m.Id) > -1)
            .ToList()
            .ForEach(m => m.ShopCommentId = model.Id);
            db.SaveChanges();

            return(Success(model));
        }
Exemplo n.º 11
0
        public string userComment(String commentMessage)
        {
            ShopComment    item          = new ShopComment();
            ShopCommentBLL bll           = new ShopCommentBLL();
            JObject        commentObject = JObject.Parse(commentMessage);

            item.TotalPoint     = Convert.ToInt32(commentObject["totalPoint"].ToString());
            item.TastePoint     = Convert.ToInt32(commentObject["tastePoint"].ToString());
            item.MilieuPoint    = Convert.ToInt32(commentObject["milieuPoint"].ToString());
            item.ServicePoint   = Convert.ToInt32(commentObject["servicePoint"].ToString());
            item.CommentContent = commentObject["comment"].ToString().Replace("\"", "");
            item.ShopId         = Convert.ToInt32(commentObject["shopId"].ToString());
            item.UserId         = Convert.ToInt32(commentObject["userId"].ToString());
            item.UserName       = commentObject["userName"].ToString().Replace("\"", "");

            if (bll.AddShopComment(item) > 0)
            {
                return("ok");
            }
            else
            {
                return("fail");
            }
        }
Exemplo n.º 12
0
 /// <summary>
 /// 更新数据
 /// </summary>
 /// <param name="model">实体类</param>
 /// <param name="whereString">可选,更新条件</param>
 /// <returns></returns>
 public bool Update(ShopComment model, string whereString = null)
 {
     return(CreateDao().Update(model, whereString));
 }
Exemplo n.º 13
0
 /// <summary>
 /// 新增数据,并返回自增ID
 /// </summary>
 /// <param name="model">实体类</param>
 /// <returns></returns>
 public int InsertIdentity(ShopComment model)
 {
     return(CreateDao().InsertIdentity(model));
 }
Exemplo n.º 14
0
 /// <summary>
 /// 新增数据
 /// </summary>
 /// <param name="model">实体类</param>
 /// <returns></returns>
 public bool Insert(ShopComment model)
 {
     return(CreateDao().Insert(model));
 }
Exemplo n.º 15
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="item"></param>
 /// <returns></returns>
 public int AddShopComment(ShopComment item)
 {
     return(ShopCommentDAL.AddShopComment(item));
 }