private List <GoodsCommentView> GetViewList(List <GoodsComment> list) { var newList = new List <GoodsCommentView>(); if (list.Any()) { list.ForEach(e => { GoodsCommentView view = new GoodsCommentView() { Comment = e.Comment, CreateBy = e.CreateBy, CreateTime = e.CreateTime, DescScore = e.DescScore, GoodsId = e.GoodsId, Id = e.Id, UpdateBy = e.UpdateBy, UpdateTime = e.UpdateTime, WlScore = e.WlScore, ImgList = _goodsCommentImgRepository.FindBy(g => g.GCId == e.Id).ToList() }; newList.Add(view); }); } return(newList); }
/// <summary> /// 添加商品评论 /// </summary> /// <param name="model"></param> /// <returns></returns> public IActionResult AddComment(GoodsCommentView model) { var userId = CurrentUser.Id; GoodsComment goodsComment = new GoodsComment() { Comment = model.Comment, CreateBy = userId, CreateTime = model.CreateTime, DescScore = model.DescScore, GoodsId = model.GoodsId, UpdateBy = userId, UpdateTime = model.UpdateTime, WlScore = model.WlScore }; var bo = _goodsCommentRepository.AddComment(goodsComment, model.ImgList); if (bo) { return(JsonOk("")); } else { return(JsonError()); } }