public Models.Comment DeleteComment(int id) { try { var result = new Models.Comment(); IContent doc = ApplicationContext.Services.ContentService.GetById(id); if (doc.Descendants().Any(x => x.ContentType.Alias == "CommentItem")) { foreach (IContent child in doc.Descendants().Where(x => x.ContentType.Alias == "CommentItem")) { ApplicationContext.Services.ContentService.Delete(child, umbraco.helper.GetCurrentUmbracoUser().Id); } } if (doc != null) { ApplicationContext.Services.ContentService.Delete(doc, umbraco.helper.GetCurrentUmbracoUser().Id); result.Name = "~deleted~"; } else { result.Name = "~notfound~"; } return(result); } catch (Exception e) { return(null); } }
/// <summary> /// Saves the comment. /// </summary> /// <param name="pageId">The unique page id</param> /// <param name="model">The comment model</param> public async Task SaveComment(Guid pageId, Models.Comment model) { var comment = await _db.PageComments .FirstOrDefaultAsync(c => c.Id == model.Id); if (comment == null) { comment = new PageComment { Id = model.Id }; await _db.PageComments.AddAsync(comment); } comment.UserId = model.UserId; comment.PageId = pageId; comment.Author = model.Author; comment.Email = model.Email; comment.Url = model.Url; comment.IsApproved = model.IsApproved; comment.Body = model.Body; comment.Created = model.Created; await _db.SaveChangesAsync(); }
public async Task <ActionResult <Models.Comment> > PostComment(Models.Comment comment) { await _context.Create(comment); await _context.SaveChangesAsync(); return(CreatedAtAction(nameof(GetComment), new { id = comment.id }, comment)); }
// GET: Comment public ActionResult Index() { var Comment = new Models.Comment(); Comment.Subject = "Buen Producto"; Comment.HtmlSubject = "El producto es <i> muy bueno </i>"; return(View(Comment)); }
public async Task <Models.Comment> PostComment(Models.Comment comment) { UriBuilder builder = new UriBuilder(AppSettings.CommentsEndpoint); string uri = builder.ToString(); var token = await _loginService.GetOAuthToken(); return(await _requestService.PostAsync <Models.Comment, Models.Comment>(uri, comment, token)); }
public ActionResult UnLikeComment(int id) { Models.Comment_Like likeComment = database.Comment_Like.SingleOrDefault(p => p.comment_id == id); Models.Comment theComment = database.Comments.SingleOrDefault(p => p.comment_id == id); database.Comment_Like.Remove(likeComment); database.SaveChanges(); return(RedirectToAction("Index", new { id = theComment.picture_id })); }
public void AddTest() { Models.Comment c = new Models.Comment() { Title = "test" }; bool result = DataHelper.Add <Models.Comment>(c); Assert.IsTrue(result, "数据库添加失败"); }
Models.Comment ICommentRepository1.Add(Models.Comment item) { if (item == null) { throw new ArgumentNullException("item"); } //Code to save record into database db.Comments.Add(item); db.SaveChanges(); return(item); }
public void Add(string productId, string text, string publisherId) { var comment = new Models.Comment { Text = text, Date = DateTime.Now, Publisher = _userDal.GetUser(publisherId) }; _productDal.AddComment(int.Parse(productId), comment); }
//AJAX POST: /Home/addComment public ActionResult addComment(Models.Comment c) { //set the Date Created property of the comment c.DateCreated = DateTime.Now; //add it to the database db.Comments.Add(c); //save the changes db.SaveChanges(); //return the comment view return(PartialView("comment", c)); }
public IActionResult AddComment(int blogPostId, int userId, string content) { Comment comment = new Models.Comment(); comment.BlogPostId = blogPostId; comment.UserId = userId; comment.Content = content; _dataContext.Comments.Add(comment); _dataContext.SaveChanges(); return(RedirectToAction("Index")); }
public Comment(Models.Comment orig, int indentLevel, int score, bool deleted, string authorUsername) { ID = orig.ID; Body = orig.Body; Author = authorUsername; Score = score; IndentLevel = indentLevel; Deleted = deleted; PuzzleID = orig.PuzzleID; DatePosted = orig.DatePostedUtc.ToString("yyyy-MM-dd HH:mm:ss") + " (UTC)"; }
public ActionResult AddComment(Models.Comment commentToAdd) { //make sure the comment is fully filled out commentToAdd.DateCreated = DateTime.Now; //add the comment to the database db.Comments.Add(commentToAdd); db.SaveChanges(); //return RedirectToAction("Index", "Home"); return(PartialView("Comment", commentToAdd)); }
public Comment(Models.Comment comment) { this.Id = comment.Id; this.UserId = comment.UserId; this.GameId = comment.GameId; this.RequestId = comment.RequestId; this.PlayId = comment.PlayId; this.UserOpinionId = comment.UserOpinionId; this.Date = comment.Date; this.CommentDetail = comment.CommentDetail; this.UserName = comment.User.Name; }
private Models.Comment BindMemberInfo(Models.Comment comment) { var member = _memberService.FindMemberById(comment.MemberId); if (member != null) { comment.MemberName = member.NickName; comment.MemberPhone = member.PhoneNumber; } return(comment); }
public ActionResult AddComment(int id, [Bind(Include = "CommentId,UserId,ProductId,CommentDate,CommentContent,IsVisible")] Comment comment) { if (comment != null && comment.CommentContent != null && comment.CommentContent != "") { Comment Comment = new Models.Comment(User.Identity.Name, id, comment.CommentContent); CommentDb.Comments.Add(Comment); CommentDb.SaveChanges(); } return RedirectToAction("Details", "Products", new { id = id }); }
public ActionResult AddComment(Models.Comment commentToAdd) { //make sure the comment is fully filled out commentToAdd.Date = DateTime.Now; //add the comment to data base db.Comments.Add(commentToAdd); db.SaveChanges(); //for now, until we ajax it, we will kick the user back to the indes return(RedirectToAction("Index", "Home")); }
public ActionResult AddComment(Models.Comment commentToAdd) { commentToAdd.DateCreate = DateTime.Now; //add comment to db db.Comments.Add(commentToAdd); db.SaveChanges(); //replace with AJAX //return RedirectToAction("Index", "Home"); return(PartialView("Comment", commentToAdd)); }
public ActionResult AddComment(Models.Comment commentToAdd) { //Make sure comment is fully filled out commentToAdd.DateCreated = DateTime.Now; //Add comment to database db.Comments.Add(commentToAdd); db.SaveChanges(); //Replace with AJAX!!!!!!!!!!!!!!!! return(RedirectToAction("Index", "Home")); }
public Comment(Models.Comment model) { Id = model.Id; Text = model.Text; CreatedAt = model.CreatedAt; LastModified = model.LastModified; if (model.Author != null) { Author = new Views.User(model.Author); } }
public IActionResult DisplayFullBlogPost() { Comment comment = new Models.Comment(); comment.BlogPostId = Convert.ToInt32(Request.Form["BlogPostId"]); comment.UserId = Convert.ToInt32(HttpContext.Session.GetString("UserId")); comment.Content = Request.Form["Comment.Content"]; _assign1Context.Comment.Add(comment); _assign1Context.SaveChanges(); return(RedirectToAction("Index")); }
public void Add(string productId, string text, string publisherId, double rating) { double newRating = rating < 0 ? 0 : rating > 10 ? 10 : rating; var comment = new Models.Comment { Text = text, Date = DateTime.Now, Publisher = _userDal.GetUser(publisherId), Rating = newRating }; _productDal.AddComment(int.Parse(productId), comment); }
private CommentDTO CommentDTOFromModel(Models.Comment comment) { var c = new CommentDTO(comment.CommentId, comment.Score, comment.Text, comment.CreatedDate); if (comment.Author != null) { c.Author = AuthorDTOFromModel(comment.Author); } return(c); }
public ActionResult UnlikeComment(int id) { int personId = Int32.Parse(Session["person_id"].ToString()); Models.Comment_like theCommentLike = db.Comment_like.SingleOrDefault(c => c.person_id == personId && c.comment_id == id); Models.Comment thePerson = db.Comments.SingleOrDefault(c => c.comment_id == theCommentLike.comment_id); db.Comment_like.Remove(theCommentLike); db.SaveChanges(); return(RedirectToAction("Index", new { id = thePerson.picture_id })); }
public Models.Comment Create(Models.Comment newComment) { newComment.CreatedOn = DateTime.Now; newComment.ModifiedOn = DateTime.Now; if (repoComment.Create(newComment)) { //to be sure to get the complete object from DB Comment c = this.repoComment.GetById(newComment.Id); this.servActivity.LogCommentCreation(c); } return(newComment); }
public static bool Pass(byte action, Models.Comment Comment, string accessor = null) { try { if (action == RestfulAction.Create) { if (!string.IsNullOrEmpty(accessor) && (new Models.AccountMembershipService()).Exist(accessor)) { return(true); } else { return(false); } } else if (action == RestfulAction.Read) { return(true); } else if (action == RestfulAction.Update) { if (!string.IsNullOrEmpty(accessor) && Comment.Creator == accessor) { return(true); } else { return(false); } } else if (action == RestfulAction.Delete) { if (!string.IsNullOrEmpty(accessor) && Comment.Creator == accessor) { return(true); } else { return(false); } } else { return(false); } } catch { return(false); } }
public async Task <IActionResult> OnGetAsync() { if (string.IsNullOrEmpty(CommentGuid)) { return(RedirectToPage("/Courses/Index")); } else { // Message by redirect if (TempData.ContainsKey("Success")) { ModelState.AddModelError("Success", TempData["Success"].ToString()); } if (TempData.ContainsKey("Error")) { ModelState.AddModelError("Error", TempData["Success"].ToString()); } // Repositorys var classRepository = new Repositorys.ClassRepository(appSettings.ConnectionStrings.DefaultConnection); var commentRepository = new Repositorys.CommentRepository(appSettings.ConnectionStrings.DefaultConnection); var comments = (await commentRepository.Select(comment: new Models.Comment() { Guid = CommentGuid })).ToList(); if (comments.Count <= 0) { Comment = new Models.Comment(); ModelState.AddModelError("Error", "此評論不存在或已被移除"); } else { Comment = comments.FirstOrDefault(); IsCreator = Comment.Creator.Equals( JsonConvert.DeserializeObject <Models.Student>( User.Claims.First(claim => claim.Type == "Information").Value).Username); var classes = (await classRepository.Select(@class: new Models.Class() { Guid = Comment.ClassGuid })).ToList(); if (classes.Count <= 0) { ModelState.AddModelError("Error", $"查無評論 { Comment.Guid } 之課程資訊"); } Class = classes.FirstOrDefault(); } return(Page()); } }
private void DeleteCommentAndChild(Models.Comment comment, CommentDbContext dbContext) { if (comment != null) { var childs = dbContext.Comments.Where(c => c.ParentId == comment.Id).ToList(); foreach (var child in childs) { DeleteCommentAndChild(child, dbContext); } dbContext.Comments.Remove(comment); _storageFileService.DisassociateFile(comment.Id, CommentModule.Key); } }
public ActionResult Comment(int id, string name, string email, string body) { Post post = GetPost(id); Comment comment = new Models.Comment(); comment.Post = post; comment.DateTime = DateTime.Now; comment.Name = name; comment.Email = email; comment.Body = body; db.Comments.Add(comment); db.SaveChanges(); return(RedirectToAction("Details", new { id = id })); }
public ActionResult AddComment(Models.Comment commentToAdd) { //make sure the comment is fully filled out commentToAdd.DateCreated = DateTime.Now; //add the comment db.Comments.Add(commentToAdd); //save cahnges db.SaveChanges(); //for now until we ajax it we'll kick the user back to the index //return RedirectToAction("Index", "Home"); //ajax'd the post so we will return a partail view return(PartialView("Comment", commentToAdd)); }
public void Comment(string comment, int game_id) { Models.GameShopContext gameShopContext = new Models.GameShopContext(); if (Session["user"] != null) { var comm = new Models.Comment(); comm.game_id = game_id; string username = Session["user"].ToString(); comm.user_id = gameShopContext.Users.Single(x => x.username == username).id; comm.comment1 = comment; gameShopContext.Comments.Add(comm); gameShopContext.SaveChanges(); } }
public ActionResult Comment(int id, FormCollection values) { //making a new comment var comments = new Models.Comment(); comments.ArticalID = id; comments.CommentCreator = values["author"]; comments.CommentBody = values["body"]; comments.CommentDate = DateTime.Now; comments.CommentRating = 0; //add comment to the database db.Comments.Add(comments); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult AddComment(int id, FormCollection values) { //Making a new comment var comment = new Models.Comment(); comment.PostID = id; comment.CommentAuthor = values["author"]; comment.CommentBody = values["body"]; comment.CommetedOn = DateTime.Now; comment.CommentRespect = 0; //Add the comment to the database db.Comments.Add(comment); db.SaveChanges(); //Return to index return RedirectToAction("Index"); }
public ActionResult AddComment(int id, FormCollection values) { //making a new commment. //values aRE PASSED IN BY THE FFORMCOLLECTION. var comment = new Models.Comment(); comment.BlogID = id; comment.Author = values["Author"]; comment.Body = values["comment"]; comment.PostedOn = DateTime.Now; comment.Likes = 0; //add comment to the database db.Comments.Add(comment); db.SaveChanges(); //return to index page return PartialView("Comment", comment); }
public ActionResult AddComment(int id, FormCollection values) { //Making a new comment var comment = new Models.Comment(); comment.PostID = id; //comment.CommentAuthor = values["author"]; comment.CommentText = values["body"]; comment.CommentedOn = DateTime.Now; comment.CommentLikes = 0; //Add the comment to the database db.Comments.Add(comment); db.SaveChanges(); //Return to index //Get the post return PartialView("Comment", comment); }
//добавление комментария public String addComment(int id, String text) { try { if (id == null) return "0"; Models.Comment comment = new Models.Comment(); if (text != "" && this.CheckAuth() == "1") { comment.doAddComment(Convert.ToInt32(Session["user_id"]), id, text); return text; } return "1"; } catch { return "0"; } }
public ActionResult CommentAdd(string comment, int fid, int is_top, string username, string avatar) { Models.Comment com = new Models.Comment(); com.Content = comment; com.UId = ViewBag.User.Uid; com.FId = fid; com.Replytime = DateTime.Now; XBBS.DataProvider.ForumDataProvider.AddComment(com); var js = new { content = comment, fid = fid, uid = com.UId, replytime = DateTime.Now, username = username, avatar = avatar, layer = XBBS.DataProvider.ForumDataProvider.TotalComment(fid) }; return Json(js); }
private CommentsModel GetModel(Int32 parentId, Common.CommentType type) { CommentsModel model = new CommentsModel(); model.Comments = new List<Models.Comment>(); try { List<CommentUnion> comments = _commentService.GetComments(SessionData.customer.id, parentId, type); foreach (CommentUnion comment in comments) { Models.Comment comm = new Models.Comment(); comm.id = comment.id; comm.ParentId = comment.ParentId; comm.CommentText = comment.CommentText; comm.Selected = comment.Selected; model.Comments.Add(comm); } } catch (Exception ex) { base.Log(ex); } finally { } return model; }
//вывод отдельно взятого товара public String getItem(int id) { try { if (id == null) return ""; Models.Item it = new Models.Item(); Models.Comment cm = new Models.Comment(); String result = it.getItem(id); result = result + "<br>" + cm.getComment(id); return result; } catch { return "Товар не найден!"; } }
public ActionResult view(int id) { Models.Item it = new Models.Item(); Models.Comment cm = new Models.Comment(); ViewData["Message"] = it.getItem(id); ViewData["Comments"] = cm.getComment(id); return View("Item"); }