private void Comment(string[] args) { if (args.Length < 2) { PrintError(NotEnoughParametersError); return; } if (!IsAutorize()) { PrintError(NotAutorizedError); return; } int topicId; if (Int32.TryParse(args[1], out topicId)) { var comment = new BllComment { Text = ReadString("Text"), Sender = me, Topic = new BllTopic { Id = topicId }, }; commentService.AddComment(comment); Topic(new string[] { null, topicId.ToString() }); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; int id = Convert.ToInt32(context.Request["pId"]); int pageSize = Convert.ToInt32(context.Request["pSize"]); int pageIndex = Convert.ToInt32(context.Request["pIndex"]); int totalCount = new BllComment().SelectRowCount(id); int pageCount = 1; var list = new BllComment().SelectCommentInfo(pageSize, pageIndex, id); if (totalCount % pageSize > 0) { pageCount = totalCount / pageSize + 1; } else { pageCount = totalCount / pageSize; } CommentListPageCount view = new CommentListPageCount(); view.List = list; view.PageCount = pageCount; string str = new JavaScriptSerializer().Serialize(view); context.Response.Write(str); }
/// <summary> /// Update comment /// </summary> /// <param name="e">Updated comment entity</param> /// <exception cref="ArgumentNullException"></exception> public async Task Update(BllComment e) { if (e == null) { throw new ArgumentNullException(nameof(e)); } await context.CommentsRepository.Update(e.ToDalCommentary()); }
public static CommentViewModel ToCommentViewModel(this BllComment comment) { return(new CommentViewModel() { Id = comment.Id, Text = comment.Text, Author = comment.Author.ToAuthor() }); }
public ActionResult MarkCommentAsGood(int id) { BllComment comment = commentService.GetComment(id); bool isCanMark = comment.Topic.Author.Id == userService.GetUser(User.Identity.Name).Id; isCanMark |= User.IsInRole("Admin") || User.IsInRole("Moderator"); comment.IsAnswer = isCanMark; commentService.UpdateComment(comment); return(RedirectToAction("Topic", "Home", new { Id = comment.Topic.Id })); }
public ActionResult Comment(AddEditCommentModel comment) { if (ModelState.IsValid) { BllComment bllComment = comment.ToBllComment(); bllComment.Sender = userService.GetUser(User.Identity.Name); commentService.AddComment(bllComment); } return(RedirectToAction("Topic", "Home", new { id = comment.TopicId })); }
public static DalComment ToDal(this BllComment comment) { return(new DalComment { Id = comment.Id, Content = comment.Content, PostId = comment.PostId, UserId = comment.UserId }); }
public static AddEditCommentModel ToAddEditCommentModel(this BllComment bllComment) { return(new AddEditCommentModel { Id = bllComment.Id, Text = bllComment.Text, TopicId = bllComment.Topic.Id, IsAnswer = bllComment.IsAnswer, }); }
public static DalComment ToDalComment(this BllComment bllComment) { return(new DalComment() { Id = bllComment.Id, Description = bllComment.Description, DateOfSending = bllComment.DateOfSending, PhotoId = bllComment.PhotoId, UserId = bllComment.UserId }); }
public static CommentViewModel ToMvcComment(this BllComment bllComment) { return(new CommentViewModel() { Id = bllComment.Id, Description = bllComment.Description, DateOfSending = bllComment.DateOfSending, PhotoId = bllComment.PhotoId, UserId = bllComment.UserId }); }
public static DalCommentary ToDalCommentary(this BllComment comment) { return(new DalCommentary() { Id = comment.Id, Date = comment.Date, Text = comment.Text, Lot = comment.Lot, User = comment.User }); }
public static DalComment ToDalComment(this BllComment comment) { return(new DalComment() { Id = comment.CommentId, CreationDate = comment.CreationDate, Text = comment.Text, Author = comment.Author?.ToDalUser(), Article = comment.Article?.ToDalArticle() }); }
public static CommentViewModel ToViewModel(this BllComment comment, BllUser user) { return(new CommentViewModel() { Content = comment.Content, Id = comment.Id, PostId = comment.PostId, FirstName = user.FirstName, LastName = user.LastName, UserId = user.Id }); }
public static CommentModel ToCommentModel(this BllComment bllComment) { return(new CommentModel { Id = bllComment.Id, Text = bllComment.Text, Date = bllComment.Date, IsAnswer = bllComment.IsAnswer, Status = bllComment.Status.Name, Sender = bllComment.Sender?.ToShortUserModel(), }); }
public ActionResult GetRawComment() { BllComment comment = commentService.GetRawComment(); if (comment != null) { return(RedirectToAction("EditComment", new { id = comment.Id })); } else { return(View("Info", (object)"All comments are processed.")); } }
private ActionResult ChangeCommentState(AddEditCommentModel comment, StatusEnum status) { if (ModelState.IsValid) { BllComment bllComment = comment.ToBllComment(); bllComment.Status = new BllStatus { Id = (int)status }; commentService.UpdateComment(bllComment); return(RedirectToAction("Topic", "Home", new { id = comment.TopicId })); } return(View("EditComment", comment)); }
public static Comment ToMvcComment(this BllComment comment, IUserService userService) { Task <BllUser> task = Task.Run(() => userService.GetById(comment.User)); task.Wait(); return(new Comment() { Id = comment.Id, UserId = comment.User, PubDate = comment.Date, Text = comment.Text, UserName = task.Result.Login, LotId = comment.Lot }); }
public static DalComment ToDalComment(this BllComment bllComment) { return(new DalComment { Id = bllComment.Id, Text = bllComment.Text, Date = bllComment.Date, IsAnswer = bllComment.IsAnswer, Topic = new DalTopic() { Id = bllComment.Topic.Id }, Sender = bllComment.Sender.ToDalUser(), Status = bllComment.Status.ToDalStatus() }); }
public void AddComment(BllComment comment) { comment.Date = DateTime.Now; comment.Status = new BllStatus() { Id = 1 }; try { commentRepository.Add(comment.ToDalComment()); } catch (InvalidOperationException e) { logger.Warn(e.Message); throw; } }
public ActionResult Add(CommentViewModel comment) { if (ModelState.IsValid) { var bllComment = new BllComment() { CreationDate = DateTime.Now, Text = comment.Text, Author = userService.GetUserEntity(comment.AuthorEmail), Article = articleService.GetArticle(comment.ArticleId) }; commentService.CreateComment(bllComment); } if (Request.IsAjaxRequest()) { return(Index(comment.ArticleId)); } return(RedirectToAction("Details", "Article", new { id = comment.ArticleId })); }
protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { //获取前台的comm方法名 string name = e.CommandName; //存储model值 ModelComment model = new ModelComment() { commentid = Convert.ToInt32(e.CommandArgument) }; //判断方法名来进行相对的操作 if (name == "delete") { //执行删除(软删除,将值隐藏) int num = BllComment.delete(model); if (num > 0) { Response.Write("<script>alert('删除成功');location.href='Comment.aspx'</script>"); } } }
protected void Button1_Click(object sender, EventArgs e) { if (TextBox1.Text == "") { Response.Write("<script>alert('请评价')</script>"); } //if (TextBox2.Text=="") //{ // Response.Write("<script>alert('请输入卖家商品id')</script>"); //} //var qq = Session["Product"] as ModelSproduct; ModelComment ins = new ModelComment() { commentcontent = TextBox1.Text, commenttime = TextBox2.Text //Sproductid=Convert.ToInt32(TextBox2.Text) }; if (BllComment.insert(ins) > 0) { Response.Write("<script>alert('添加成功');location.href='Comment.aspx'</script>"); } }
public void UpdateComment(BllComment comment) { DalComment dalComment = commentRepository.First(c => c.Id == comment.Id); dalComment.IsAnswer = comment.IsAnswer; dalComment.Text = comment.Text; dalComment.Status.Id = comment.Status.Id; dalComment.Topic.IsAnswered = dalComment.IsAnswer; topicRepository.Update(dalComment.Topic); try { topicRepository.Update(dalComment.Topic); commentRepository.Update(dalComment); } catch (InvalidOperationException e) { logger.Warn(e.Message); throw; } }
/// <summary> /// Add comment /// </summary> /// <param name="text">Comment text</param> /// <param name="userName">User login</param> /// <param name="lotId">Id of the lot</param> /// <returns>Id of added comment</returns> public async Task <int> PostComment(string text, string userName, int lotId) { if (string.IsNullOrEmpty(text)) { throw new ArgumentNullException(nameof(text)); } if (string.IsNullOrEmpty(userName)) { throw new ArgumentNullException(nameof(userName)); } var user = (await context.UserStore.FindByNameAsync(userName)).ToBllUser(); var comment = new BllComment() { Date = DateTime.Now, Lot = lotId, Text = text, User = user.Id }; return(await context.CommentsRepository.Create(comment.ToDalCommentary())); }
async Task IService <BllComment, int> .Delete(BllComment e) { await Delete(e.Id); }
async Task <int> IService <BllComment, int> .Create(BllComment e) { string userName = (await context.UserStore.FindByIdAsync(e.User)).UserName; return(await PostComment(e.Text, userName, e.Lot)); }
public void AddComment(BllComment comment) { commentRepository.Insert(comment.ToDalComment()); }
public void CreateComment(BllComment comment) { commentRepository.Create(comment.ToDalComment()); uow.Commit(); }
public void DeleteComment(BllComment comment) { commentRepository.Delete(comment.ToDalComment()); uow.Commit(); }
public void Delete(BllComment entity) { repository.Delete(entity.ToDal()); unitOfWork.Commit(); }