public void Init() { _commentManager = new CommentManager(); _newsManager = new NewsManager(); _comment1 = new Comment() { Id = 1, CommentText = "Text 1", Name = "Name 1" }; var news = new News() { Id = 1, Description = "Disc 1", Title = "Test title 1", Date = DateTime.Now, Picture = "/Content/Pictures/oprydning.jpg" }; news.Comments.Add(_comment1); _comment1.News = news; _comment2 = new Comment() { CommentText = "Text 2", Name = "Name 2" }; _comment3 = new Comment() { CommentText = "Text 3", Name = "Name 3", Id = 1 }; }
protected void btnCommit_ServerClick(object sender, EventArgs e) { int id = Convert.ToInt32(Request.QueryString["aid"]); Article article = ArticleManager.GetArticleById(id); string commentContent = Server.HtmlEncode(this.txtComment.Text.ToString()); if (commentContent.Length > 250) { commentContent = commentContent.Substring(0, 250); } Comment comment = new Comment(); comment.Article = article; comment.AuthorName = this.txtCommentName.Text.ToString(); comment.Contents = commentContent; comment.PubDate = DateTime.Now; if (CommentManager.AddComment(comment) != null) { Response.Redirect("article.aspx?aid=" + id); Response.Write("alert(\"恭喜您,评论发表成功!\")"); } else { this.lblErrorComment.Text = "很抱歉,你的评论发表失败,请重新尝试!"; } }
public ActionResult AddComment(Comment comment, String sTitle) { System.Diagnostics.Debug.WriteLine("sesss" + Session["LoggedIn"]); if (Session["LoggedIn"] == null || Session["LoggedIn"].Equals(false) || Session["LoggedIn"].ToString().Length == 0) { TempData["commentAdded"] = "Please Log in."; return(View(comment)); } comment.Writer = UserPersistence.GetUser(Session["userId"].ToString()); comment.CommentId = CommentPersistence.getMaxId() + 1; System.Diagnostics.Debug.WriteLine("***" + sTitle); comment.Service = ServicePersistence.GetService(sTitle); bool?acceptible = false; acceptible = CommentManager.AddNewComment(comment); if ((acceptible != null)) { if (acceptible == true) { TempData["commentAdded"] = "Comment is added successfully."; return(RedirectToAction("Index", "Home")); } else { TempData["commenteAdded"] = "Comment could not be added."; return(View(comment)); } } else { TempData["commentAdded"] = "Comment could not be added."; return(View(comment)); } }
private void SaveClosingComment() { try { Comment commentObj = new Comment(); commentObj.CommentTaskId = taskObj.Id; commentObj.CommentEmployeeName = taskObj.Employee_AssignTo; commentObj.CommentEmployeeId = taskObj.Employee_Id; commentObj.CommentDate = System.DateTime.Now; commentObj.Comments = "This task is colsed by admin :" + taskObj.Employee_AssignTo; CommentManager commentManagerObject = new CommentManager(); commentManagerObject.SaveComment(commentObj); } catch (PrimaryKeyException primaryKeyExceptionObj) { errorLabel.Text = primaryKeyExceptionObj.Message; } catch (SqlException sqlExceptionObj) { errorLabel.Text = sqlExceptionObj.Message; } catch (Exception exceptionObj) { errorLabel.Text = exceptionObj.Message; } }
protected void CheckStatistics() { StatisticsInfo s = StatisticsManager.GetStatistics(); bool update = false; int totalPosts = PostManager.GetPostCount(-1, -1, -1, (int)PostStatus.Published, 0); if (totalPosts != s.PostCount) { s.PostCount = totalPosts; update = true; } int totalComments = CommentManager.GetCommentCount(true); if (totalComments != s.CommentCount) { s.CommentCount = totalComments; update = true; } int totalTags = TagManager.GetTagList().Count; if (totalTags != s.TagCount) { s.TagCount = totalTags; update = true; } if (update == true) { StatisticsManager.UpdateStatistics(); } }
protected void CommentButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(Content.Text.Trim())) { Response.Write("<script>alert('내용을 입력해주세요.');</script>"); } else if (Session["UserID"] == null) { // 로그인 페이지로 Redirect Response.Redirect("/Login.aspx?classification=2&state=" + Request.QueryString["state"] + "&id=" + Request.QueryString["id"]); } else { CommentButton.Enabled = false; CommentManager.AddComment(new Models.Comment { PostID = int.Parse(Request.QueryString["id"]), Content = Content.Text, WriterID = (string)Session["UserID"], CommentAt = DateTime.Now.AddHours(9), Classification = 2 }); CommentButton.Enabled = true; Response.Redirect(Request.RawUrl); } }
public CommentService(IGenericRepository <Comment> commentRepo, UnitOfWork unitOfWork, ArticleContext context, CommentManager commentManager) { this.commentRepo = commentRepo; this.unitOfWork = unitOfWork; this.context = context; this.commentManager = commentManager; }
public ActionResult Partners_getAudio(int id) { var mng = new CommentManager(); string path = mng.GetComment(id).audio; return(File(path, "audio/vnd.wave", "voice_" + id + Path.GetExtension(path))); }
public ActionResult CommentShower(int carId) { Car car = CarManager.GetCar(carId); //Gather the car and assign them to the TempData since we can't use two Models in the View. TempData["carId"] = car.carId; TempData["Brand"] = car.Brand; TempData["Model"] = car.Model; TempData["Owner"] = car.Owner; TempData["YearOfProduction"] = car.YearOfProduction; TempData["km"] = car.km; TempData["Url"] = car.Url; TempData["TransmissionType"] = car.TransmissionType; TempData["Fuel"] = car.Fuel; TempData["TopSpeed"] = car.TopSpeed; TempData["Acceleration"] = car.Acceleration; TempData["UrbanConsumption"] = car.UrbanConsumption; TempData["WheelDrive"] = car.WheelDrive; Comment[] comments = CommentManager.GetCarComments(carId); if (comments == null) { ViewBag.message = "There are no comments for this car."; } return(View(comments)); }
//DataAccessLayer.EntityFramework içerisindeki Repository içerisindeki Note class'ına erişiyoruz //private Repository<Note> repo_note = new Repository<Note>(); /* * //Notları alıp listedik * public List<Note> GetAllNote() * { * return repo_note.List(); * } * * public IQueryable<Note> GetAllNoteQueryable() * { * return repo_note.ListQueryable(); * } */ public override int Delete(Note notes) { //Note ile ilişkili olanların silinmesi gerekir. LikedManager likedManager = new LikedManager(); CommentManager commentManager = new CommentManager(); //En sonda Kategoriyi siliyoruz. //Listeyi ayarlamak için ToList diyoruz. //O notlarla alakalı like silmemiz gerekir. foreach (Liked like in notes.Likes.ToList()) { likedManager.Delete(like); } //O notlarla alakalı yorumların silmemiz gerekir. foreach (Comment comment in notes.Comments.ToList()) { commentManager.Delete(comment); } //en sonda notların siliniyor. return(base.Delete(notes)); }
protected void BindCommentList() { CommentManager manager = new CommentManager(); IList<Comment> comments = manager.GetCommentsByQuestion(this.QuestionID); _TotalCount = comments.Count; rptCommentList.DataSource = comments; rptCommentList.DataBind(); if (_TotalCount > 0) //ltrCommentHeading.Text = "<a href='javascript:void(0);' onclick='ToggleCommentingBox();'>Write your comment here.</a>"; ltrCommentHeading.Text = "<a href='javascript:void(0);' onclick='ToggleCommentingBox();'>Comment</a>"; else { //_CommentListDisplayStyle = "none"; //ltrCommentHeading.Text = "<a href='javascript:void(0);' onclick='ToggleCommentingBox();'>Be the first to comment on this question.</a>"; ltrCommentHeading.Text = "<a href='javascript:void(0);' onclick='ToggleCommentingBox();'>Comment</a>"; } if (_LoggedInUser.Author_ID == 0)//Anonymous User { if (_TotalCount > 0) ltrCommentHeading.Text = "Comments"; else ltrCommentHeading.Text = "Sorry! No comment is availabe for this question."; } }
public string DodajKomentarz(string Comment, int Product) { if (User.Identity.Name == "") { return("SIGNIN"); } if (!ProductManager.CheckProductExistsID(Product)) { return("ERROR"); } if (string.IsNullOrWhiteSpace(Comment) || Comment.Length < 3 || Comment.Length > 500) { return("ERROR"); } bool isAdded = CommentManager.AddComment(User.Identity.Name, Product, Comment); if (isAdded) { return("OK"); } else { return("OK"); } }
public ActionResult MyCommentNotes() { using (CommentManager commentManager = new CommentManager()) { List <SharingViewModel> myCommentNotes = commentManager.ListQueryable().Include(x => x.Owner).Include(x => x.Sharing).Where(x => x.Owner.Id == CurrentSession.shareBookUser.Id && !x.isDelete).Select(x => x.Sharing).Distinct().Include(x => x.Category).Include(x => x.Owner).Select(x => new SharingViewModel() { Category = x.Category, Comments = x.Comments, Likes = x.Likes, Title = x.Title, ImageUrl = x.ImageUrl, ShareContent = x.ShareContent, Owner = x.Owner, ModifiedOn = x.ModifiedOn, CreatedOn = x.CreatedOn, ModifiedBy = x.ModifiedBy, Id = x.Id, CategoryId = x.CategoryId, isDraft = x.isDraft, isDelete = x.isDelete, LikeCount = x.LikeCount, }).OrderByDescending(x => x.ModifiedOn).ToList(); return(View("Index", myCommentNotes)); } }
public override int Delete(Category category) { NoteManager noteManager = new NoteManager(); LikedManager likedManager = new LikedManager(); CommentManager commentManager = new CommentManager(); //Kategori ile bağlantılı notlar silinecek foreach (Note note in category.Notes.ToList()) { //Not ile ilişkili beğeniler silinecek foreach (Liked like in note.Likes.ToList()) { likedManager.Delete(like); } foreach (Comment comment in note.Comments.ToList()) { commentManager.Delete(comment); } noteManager.Delete(note); } return(base.Delete(category)); }
public static List <string> ControlComment(CommentViewModel comment, int recipeId, string commenterId) { List <string> errors = new List <string>(); if (comment.Text == null) { errors.Add("TextMissing"); } else if (comment.Text.Count() < 10 || comment.Text.Count() > 200) { errors.Add("TextWrongLength"); } if (comment.Grade == default(int)) { errors.Add("GradeMissing"); } else if (comment.Grade < 1 || comment.Grade > 5) { errors.Add("GradeWrongValue"); } if (commenterId == "") { errors.Add("CommenterIdMissing"); } else { CommentManager cm = new CommentManager(); if (cm.HasUserAlreadyCommented(commenterId, recipeId)) { errors.Add("CommenterAlreadyCommented"); } } return(errors); }
protected void btnSend_Click(object sender, EventArgs e) { Comment comment = new Comment() { UserId = int.Parse(((Session["user"] as User).Id).ToString()), ProjectId = int.Parse(Request.QueryString["Id"]), Content = this.Comment.Text, SendTime = DateTime.Now.ToString() }; CommentManager commentManager = new CommentManager(); if (this.Comment.Text == "") { Response.Write("<script>alert('请输入内容!');</script>"); return; } else { if (commentManager.Add(comment)) { Response.Write("<script>alert('发表成功');</script>"); this.Comment.Text = ""; Response.Write("<script> window.location.href = document.URL; </script>"); } else { Response.Write("<script>alert('发表失败');</script>"); } } }
private void BindComment() { DataTable dt = CommentManager.allComment(); ListView1.DataSource = dt; ListView1.DataBind(); }
public override int Delete(Category category) { NoteManager noteManager = new NoteManager(); LikedManager likedManager = new LikedManager(); CommentManager commentManager = new CommentManager(); // Kategori ile ilişkili notların silinmesi gerekiyor. foreach (Note note in category.Notes.ToList()) { // Note ile ilişikili like'ların silinmesi. foreach (Liked like in note.Likes.ToList()) { likedManager.Delete(like); } // Note ile ilişkili comment'lerin silinmesi foreach (Comment comment in note.Comments.ToList()) { commentManager.Delete(comment); } noteManager.Delete(note); } return(base.Delete(category)); }
public void Init() { _newsManager = new NewsManager(); _commentManager = new CommentManager(); //Create a list of Comments to add to a News. comments = new List<Comment>() { new Comment() {Id = 1, CommentText = "News Test Text1", Name = "News Test Name1"}, new Comment() {Id = 2, CommentText = "News Test Text2", Name = "News Test Name2"} }; //Create a News and set its Comments to be squal to the above Commentlist. _news1 = new News() { Title = "Test Title 1", Description = "Test Disc 1", Comments = comments, Id = 1, Date = DateTime.Now, Picture = "/Content/Pictures/oprydning.jpg" }; //Create the Comments in the DB. foreach (var comment in comments) { _commentManager.Create(comment); } _news2 = new News() {Date = DateTime.Now, Title = "Test Title 2", Description = "Test Disc 2"}; _news3 = new News() {Description = "Test Disc 3", Title = "Test Title 3", Id = 1}; }
public ActionResult ProjectComments(int project_id) { CommentManager cm = new CommentManager(); List <Comment> Comments = cm.List(x => x.Project.Id == project_id && x.IsConfirmed == false); return(View(Comments)); }
public ActionResult Details(CategoriesListData model, int pageNumber = 1) { string name = User.Identity.Name; model.AllCategory = new CategoryManager().GetAllCategory(); Recipes recipe = db.Recipes.Find(model.RecipesDB.ID); db.Recipes.Remove(recipe); try { System.IO.File.Delete(Path.Combine(Server.MapPath("~"), "Upload\\Images", recipe.PictureUrl)); } catch { } db.SaveChanges(); List <Comments> comments = new CommentManager().GetRecipeCommentsList(model.RecipesDB.ID); foreach (Comments comment in comments) { db.Comments.Remove(comment); } db.SaveChanges(); model.Recipes = new RecipeManager().GetUserRecipes(name, pageNumber); return(View(model)); }
public async void CanReadAllComments() { DbContextOptions <PostDbContext> options = new DbContextOptionsBuilder <PostDbContext>().UseInMemoryDatabase("ReadAllComments").Options; using (PostDbContext context = new PostDbContext(options)) { CommentManager CommentService = new CommentManager(context); Comment message = new Comment(); message.PostID = 1; message.User = "******"; message.UserComment = "Nice post!"; await CommentService.SaveAsync(message); Comment messageTwo = new Comment(); messageTwo.PostID = 1; messageTwo.User = "******"; messageTwo.UserComment = "I agree!"; await CommentService.SaveAsync(messageTwo); Comment messageThree = new Comment(); messageThree.PostID = 2; messageThree.User = "******"; messageThree.UserComment = "Comment belonging to different post"; await CommentService.SaveAsync(messageThree); var result = await CommentService.GetComments(); int count = result.Count; Assert.Equal(3, count); } }
public ActionResult MyAddComment(string comment_title, string comment_content, int project_id) { ProjectManager pm = new ProjectManager(); Notification not = new Notification(); bool result = false; int userid = (Session["user"] as User).Id; CommentManager cm = new CommentManager(); result = cm.AddComment(project_id, userid, comment_content, comment_title); if (!result) { not.Type = 0; not.FromWho = userid; not.Comment = comment_content; not.Date = DateTime.Now; not.ToWho = -1; not.projectid = project_id; nm.Insert(not); ViewBag.CommentResult = "Yorum ekleme işlemi başarılı"; ViewBag.Color = "success"; } else { ViewBag.CommentResult = "Yorum Eklerken Bir Hata Meydana Geldi"; ViewBag.Color = "danger"; } TempData["projectid"] = project_id; Project project = pm.Find(x => x.Id == project_id); TempData["projectOwner"] = project.user.UserName; TempData["projectImage"] = "/ProjectImages/" + project_id.ToString() + ".png"; return(RedirectToAction("Show", "Project", pm.Find(x => x.Id == project_id))); }
/// <summary> /// Counts number of attachments of the task /// </summary> /// <returns>number of attachments of the task</returns> private int numberOfAttachment() { int noOfAttachment = 0; try { CommentManager commentManagerObject = new CommentManager(); List <Comment> commentList = commentManagerObject.GetCommentsOfTheTask(taskId); foreach (Comment commentObj in commentList) { if (commentObj.CommentAttachment != "") { noOfAttachment++; } } } catch (SqlException sqlExceptionObj) { errorLabel.Text = sqlExceptionObj.Message; } catch (Exception exceptionObj) { errorLabel.Text = exceptionObj.Message; } return(noOfAttachment); }
/// <summary> /// Dynamically add attachments of a task in the bulletedList /// text fild= file name /// value fild= source path /// </summary> private void AddAttachmentToBulletedList() { try { CommentManager commentManagerObject = new CommentManager(); List <Comment> commentList = commentManagerObject.GetCommentsOfTheTask(taskId); foreach (Comment commentObj in commentList) { if (commentObj.CommentAttachment != "") { string sourcePath = commentObj.CommentAttachment; int lastIndexOfSlash = sourcePath.LastIndexOf(@"\"); string fileName = sourcePath.Substring(lastIndexOfSlash + 1); ListItem listItemObj = new ListItem(); listItemObj.Text = fileName; listItemObj.Value = Server.MapPath("~/") + sourcePath; attachmentBulletedList.Items.Add(listItemObj); } } } catch (SqlException sqlExceptionObj) { errorLabel.Text = sqlExceptionObj.Message; } catch (Exception exceptionObj) { errorLabel.Text = exceptionObj.Message; } }
public async void CanGetAllCommentsAsync() { DbContextOptions <InstaDOTNETDbContext> options = new DbContextOptionsBuilder <InstaDOTNETDbContext>().UseInMemoryDatabase("GetCommentsAsync").Options; using (InstaDOTNETDbContext context = new InstaDOTNETDbContext(options)) { Comment comment = new Comment(); comment.ID = 1; comment.ImageID = 1; comment.CommentString = "Test Comment"; comment.CommentAuthor = "Test Author"; Comment comment2 = new Comment(); comment2.ID = 2; comment2.ImageID = 1; comment2.CommentString = "Test Comment 2"; comment2.CommentAuthor = "Test Author 2"; CommentManager commentManager = new CommentManager(context); await commentManager.SaveAsync(comment); await commentManager.SaveAsync(comment2); List <Comment> comments = new List <Comment>(); comments.Add(comment); comments.Add(comment2); List <Comment> result = await commentManager.GetCommentsAsync(); Assert.Equal(comments, result); } }
/// <summary> /// Load all comments of the task into allCommentsTextBox /// also check for attachment /// upload attachment if any /// </summary> private void LoadAllComments() { try { string allComments = null; CommentManager commentManagerObject = new CommentManager(); List <Comment> commentList = commentManagerObject.GetCommentsOfTheTask(taskId); foreach (Comment commentObj in commentList) { allComments += commentObj.CommentEmployeeName + " : "; allComments += commentObj.Comments + ". \n on "; allComments += commentObj.CommentDate + ". \n"; } allCommentsTextBox.Text = allComments; CheckForAttachmentAndLoadInBulletedList(); } catch (SqlException sqlExceptionObj) { errorLabel.Text = sqlExceptionObj.Message; } catch (Exception exceptionObj) { errorLabel.Text = exceptionObj.Message; } }
//DataAccessLayer.EntityFramework içerisindeki Repository içerisindeki Category class'ına erişiyoruz // private Repository<Category> repo_category = new Repository<Category>(); /* * //Geriye Kategori Listesi dönendir. * public List<Category> GetCategories() * { * //Bütün Kategorileri Listelyip Döndürücek * return repo_category.List(); * } * * //Category id si dönen method ihtiyacından dolayı yazıldı * * public Category GetCategoryById(int id) * { * return repo_category.Find(x => x.Id == id); //id si eşit olanı bul varsa dön * } */ #endregion public override int Delete(Category category) { //Kategori ile ilişkişi notların silinmesi gerekir. NoteManager noteManager = new NoteManager(); LikedManager likedManager = new LikedManager(); CommentManager commentManager = new CommentManager(); //En sonda Kategoriyi siliyoruz. //Listeyi ayarlamak için ToList diyoruz. foreach (Note note in category.Notes.ToList()) { //O notlarla alakalı like silmemiz gerekir. foreach (Liked like in note.Likes.ToList()) { likedManager.Delete(like); } //O notlarla alakalı yorumların silmemiz gerekir. foreach (Comment comment in note.Comments.ToList()) { commentManager.Delete(comment); } //notların kendisi siliniyor. noteManager.Delete(note); } //en sonda Kategori siliniyor. return(base.Delete(category)); }
public ActionResult Details(CategoriesListData model, int pageNumber = 1) { CategoryManager manager = new CategoryManager(); model.AllCategory = manager.GetAllCategory(); Recipes recipe = db.Recipes.Find(model.RecipesDB.ID); db.Recipes.Remove(recipe); System.IO.File.Delete(Path.Combine(Server.MapPath("~"), "Upload\\Images", recipe.PictureUrl)); db.SaveChanges(); List <Comments> comments = new CommentManager().GetRecipeCommentsList(model.RecipesDB.ID); foreach (Comments comment in comments) { db.Comments.Remove(comment); } db.SaveChanges(); Categories category = db.Categories.Find(model.SelectedCategory.ID); model.Recipes = manager.GetRecipesInCategory(category.FriendlyUrl, pageNumber); model.SelectedCategory = model.AllCategory.FirstOrDefault(c => c.FriendlyUrl == category.FriendlyUrl); return(View(model)); }
public JsonResult AddComment(Comment Comment, int StoryID) { int UserID = (int)Session["ActiveUser"]; Comment comment = new CommentManager().AddComment(Comment, UserID, StoryID); return(Json(comment)); }
public ActionResult Delete(int?id) { using (CommentManager commentManager = new CommentManager()) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Comment comment = commentManager.Find(x => x.Id == id && !x.isDelete && !x.Owner.isDeleted); if (comment == null) { return(new HttpNotFoundResult()); } comment.isDelete = true; if (commentManager.Update(comment) > 0) { return(Json(new { Result = true }, JsonRequestBehavior.AllowGet)); } return(Json(new { Result = false }, JsonRequestBehavior.AllowGet)); } }
// GET: Cleaner public string CleanNotes() { NoteManager nm = new NoteManager(); LikedManager lm = new LikedManager(); CommentManager cm = new CommentManager(); DateTime minDate = DateTime.Now.AddMinutes(-2); // 2 dk dan eski notlar bulunur. List <Note> toDeleteNotes = nm.List(x => x.CreatedOn < minDate && x.IsDeletedNote); // Notun like ve comment'leri silinir.. toDeleteNotes.ForEach(x => { foreach (Comment com in x.Commnets.ToList()) { cm.Delete(com); } foreach (Liked liked in x.Likes.ToList()) { lm.Delete(liked); } }); // Notlar silinir. foreach (Note note in toDeleteNotes) { nm.Delete(note); } return("ok"); }
protected void ImportLinksToCommentTable(IList<App.Models.Questions.Questions> questions) { CommentManager commentManager = new CommentManager(); IList<Comment> comments = commentManager.GetList(); LinkManager linkManager = new LinkManager(); foreach (App.Models.Questions.Questions question in questions) { IList<Link> links = linkManager.GetLinksForQuestion(question.QuestionID); if(links != null && links.Count > 0) AddLinksToTheCommentTable(links, comments, question.QuestionID); } }
public void Init() { _commentManager = new CommentManager(); _newsManager = new NewsManager(); _comment1 = new Comment() {Id = 1, CommentText = "Text 1", Name = "Name 1"}; var news = new News() {Id = 1, Description = "Disc 1", Title = "Test title 1", Date = DateTime.Now, Picture = "/Content/Pictures/oprydning.jpg" }; news.Comments.Add(_comment1); _comment1.News = news; _comment2 = new Comment() {CommentText = "Text 2", Name = "Name 2"}; _comment3 = new Comment() {CommentText = "Text 3", Name = "Name 3", Id = 1}; }
private void AddLinksToTheCommentTable(IList<Link> links, IList<Comment> comments, int questionID) { CommentManager manager = new CommentManager(); foreach (Link link in links) { if (!IsLinkAlreadyImported(link, comments, questionID)) { ///Add the Link As Comment Comment comment = ConvertLinkToComment(link, questionID); manager.SaveOrUpdate(comment); _TotalImportedLink++; } } }