public Guid InsertComment(CommentModel Comment) { if (Comment == null) { throw new NullReferenceException(); } using (AppTourEntities data = new AppTourEntities()) { COMMENT _new = new COMMENT { ID = (Comment.Id == null || Comment.Id == Guid.Empty ? Guid.NewGuid() : Comment.Id), EVENT = (Comment.Event != null ? data.EVENT.SingleOrDefault(x => x.ID.Equals(Comment.Event.Id)) : null), POINT = (Comment.Point != null ? data.POINT.SingleOrDefault(x => x.ID.Equals(Comment.Point.Id)) : null), IS_REPORTED = Comment.IsReported, IS_ACTIVE = Comment.IsActive, USER = data.USER.SingleOrDefault(x => x.ID.Equals(Comment.User.Id)), COMMENT1 = Comment.Comment, CREATION_DATE = DateTime.Now }; data.COMMENT.AddObject(_new); data.SaveChanges(); return(_new.ID); } }
public ActionResult AddCommentsForNews(int ID, COMMENT comment) { int id_team = Convert.ToInt16(Session["ID_team"]); if (ModelState.IsValid) { comment.UserName = User.Identity.Name; comment.userIP = Request.UserHostAddress; comment.date = System.Convert.ToString(System.DateTime.Now); if (WebSecurity.GetUserId(User.Identity.Name) != null && WebSecurity.GetUserId(User.Identity.Name) != 0) { db.insertCommentForNewsWithUserID(comment.userIP, comment.text, comment.date, WebSecurity.GetUserId(User.Identity.Name), ID, User.Identity.Name); } else { db.insertCommentForNewsWithUserName(comment.userIP, comment.text, comment.date, User.Identity.Name, ID); } db.SaveChanges(); if (Request.IsAjaxRequest()) { teamModelView.listOfNews = teamRepository.ListOfNews(id_team); teamModelView.listOfComments = teamRepository.ListOfComments(ID); teamModelView.numbersOfNews = teamRepository.ListOfNews(id_team).Count; teamModelView.numberOfComments = teamRepository.ListOfComments(ID).Count; teamModelView.idNews = ID; teamModelView.news = teamRepository.NewsByID(ID); //teamModelView.listOfNews = db.newsForTheTeam(id).ToList(); return(PartialView("~/Views/Partial/Team/_TeamNewsByIDPartial.cshtml", teamModelView)); } } return(RedirectToAction("ShowTeamNewsByID", "Team", ID)); }
protected void Button2_Click(object sender, EventArgs e) { int houseId = (int)Session["houseId"]; int customerId = (int)Session["customerId"]; string content = comment.Text.ToString(); GoatDataContext lqdb = new GoatDataContext(ConfigurationManager.ConnectionStrings["GoatConnectionString"].ConnectionString.ToString()); var result = from r in lqdb.COMMENT where r.houseId == houseId select r; COMMENT com = new COMMENT(); com.houseId = houseId; com.commentContent = content; com.commentId = customerId; string pis = getHeadPicById(customerId); com.photo = pis; string date = DateTime.Now.ToString(); com.commentDate = date; lqdb.COMMENT.InsertOnSubmit(com); lqdb.SubmitChanges(); Response.Write("<script>alert('评论已经成功提交')</script>"); Response.Redirect("~/historyOrder.aspx"); }
public ActionResult Details(FormCollection collection) { string MaTK = Request.Cookies["MaTK"]["MaTK"] ?? ""; if (MaTK == "" || !Request.IsAuthenticated) { return(RedirectToAction("Login", "Account")); } else { COMMENT comment = new COMMENT(); comment.MaCM = "CM" + db.LaySoLuongComment().ToString(); string MaSP = Request.Cookies["MaSP"]["MaSP"]; comment.MaSP = MaSP; comment.MaTK = MaTK; comment.Ngay = DateTime.Now; comment.Noidung = collection["NoiDung"]; db.COMMENTs.Add(comment); db.SaveChanges(); //Request.Cookies["MaSP"]["MaSP"] comment.UserName = db.LayUserNameTheoMaTK(MaTK); return(RedirectToAction("Details", "Home")); } }
private bool SetSingleValues(String begin, String rest) { switch (begin) { case "VRPTEST": VRPTEST = rest; return(true); case "COMMENT:": COMMENT.Add(rest); return(true); case "NAME:": NAME = rest; return(true); case "NUM_DEPOTS:": NUM_DEPOTS = uint.Parse(rest); return(true); case "NUM_CAPACITIES:": NUM_CAPACITIES = uint.Parse(rest); return(true); case "NUM_VISITS:": NUM_VISITS = uint.Parse(rest); return(true); case "NUM_LOCATIONS:": NUM_LOCATIONS = uint.Parse(rest); return(true); case "NUM_VEHICLES:": NUM_VEHICLES = uint.Parse(rest); return(true); case "CAPACITIES:": CAPACITIES = uint.Parse(rest); return(true); } return(false); }
public int Delete(int id) { USER user = db.USERS.Find(id); COMMENT cm = db.COMMENTS.Where(c => c.ID_USER == id).FirstOrDefault(); if (cm != null) { return(-1); } POST Post = db.POSTs.Where(c => c.ID_USER == id).FirstOrDefault(); if (Post != null) { return(-1); } using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { db.USERS.Remove(user); int i = db.SaveChanges(); transaction.Commit(); return(i); } catch { transaction.Rollback(); return(0); } } }
private void btncommentAPR_Click(object sender, EventArgs e) { COMMENT comment = new COMMENT(); comment = cboxcommentUA.SelectedItem as COMMENT; m.aprovarCOMMENT(comment); Refreshdata(); lblAC.Text = "Comentário Aprovado!"; }
private void btncommentban_Click(object sender, EventArgs e) { COMMENT comment = new COMMENT(); comment = cboxPCcomment.SelectedItem as COMMENT; m.banirCOMMENT(comment); Refreshdata(); lblBC.Text = "Comentário Banido!"; }
private void btnCommentUBAN_Click(object sender, EventArgs e) { COMMENT comment = new COMMENT(); comment = cboxCommentUBAN.SelectedItem as COMMENT; m.unbanCOMMENT(comment); Refreshdata(); lblUC.Text = "Comentário Desbanido!"; }
public int AddComment(COMMENT input) { try { db.COMMENTS.Add(input); db.SaveChanges(); return(1); } catch (Exception e) { return(-1); } }
public ActionResult AddComment(int SubID, string Comment) { var userInfo = (UserLoginModel)Session[Helper.Commons.USER_SEESION_ADMIN]; var newComment = new COMMENT() { Com_Name = Comment, User_ID = userInfo.UserID, Sub_ID = SubID, Created_Date = DateTime.Now, Created_By = userInfo.Username }; var res = dataAccess.AddComment(newComment); return(Json(res, JsonRequestBehavior.AllowGet)); }
public ActionResult PostComment(int idPost, FormCollection form) { POST Post = postsModels.GetItem(idPost); if (!form["DETAIL"].Equals("")) { COMMENT Cm = new COMMENT(); CustomPrincipal prin = (CustomPrincipal)User; Cm.DETAIL = form["DETAIL"]; Cm.ID_USER = prin.ID; Cm.ID_POST = idPost; Cm.DATE_CREATED = DateTime.Now; int i = commentsModels.Add(Cm); } return(RedirectToAction("DetailPost", "Categories", new { id = idPost, post = Post.URL_SLUG, idCate = Post.ID_CATEGORY, category = Post.CATEGORy.URL_SLUG })); }
public void AddCommentToTask(CommentAddModel commentModel, USER user) { TASK task = _taskRepository.GetTaskById(commentModel.TaskId); if (task != null) { COMMENT comment = new COMMENT { CONTENT = commentModel.CommentContent, CREATED = DateTime.Now, TASK = task, USER = user }; _commentRepository.AddComment(comment); } }
public int Add(COMMENT Cm) { using (DbContextTransaction transaction = db.Database.BeginTransaction()) { try { db.COMMENTS.Add(Cm); int i = db.SaveChanges(); transaction.Commit(); return(Cm.ID); } catch { transaction.Rollback(); return(0); } } }
public ActionResult createComment(int postid, string commentContent, int ownerid, string action_, string controller_, int userid = 1) { COMMENT comment = new COMMENT(); comment.CONTENT = commentContent; comment.LIKES = 0; comment.USERID = ownerid; comment.POSTID = postid; var con = new SOCIALMEDIA_DBEntities(); //get the last id and ++ the new id var comms = con.COMMENTS.OrderByDescending(c => c.COMMENTID); comment.COMMENTID = (comms.Count() != 0)? comms.First().COMMENTID + 1:1; con.COMMENTS.Add(comment); con.SaveChanges(); return(RedirectToAction(action_, controller_, new { userid = userid })); }
/// <summary> /// Wyciaga z bazy komentarze dla danego NEWS'a /// </summary> public List <COMMENT> ListOfComments(int id_news) { List <COMMENT> listOfComments = new List <COMMENT>(); var result = db.commentsForTheNews(id_news).ToList(); foreach (var element in result) { var tmp = new COMMENT(); //tmp.ID_comment = element. //tmp.ID_news = element.ID_comment; //tmp.UserId = element. //tmp.userIP = element.ID_comment; tmp.UserName = element.UserName; tmp.text = element.text; tmp.date = element.date; listOfComments.Add(tmp); } return(listOfComments); }
public ActionResult AddComment(int?hotelId, int?restaurantId, int?resortId, int?travelId, int?touristId, string contentComment, string id_user, bool?flag_reply, string id_reply) { COMMENT newCommnent = new COMMENT(); newCommnent.ID_COMMENT = Guid.NewGuid().ToString("N"); newCommnent.ID_HOTEL = hotelId; newCommnent.ID_RESTAURANT = restaurantId; newCommnent.ID_RESORT = resortId; newCommnent.ID_TRAVEL = travelId; newCommnent.ID_TOURISTSPOT = touristId; newCommnent.CONTENT_COMMENT = contentComment; newCommnent.ID_USER = id_user; newCommnent.FLAG_REPLY = flag_reply; newCommnent.ID_REPLY = id_reply; newCommnent.DT_COMMENT = DateTime.Now; dBContext.COMMENTs.Add(newCommnent); dBContext.SaveChanges(); return(RedirectToAction("LoadComment", "Comment")); }
public bool AddComment(COMMENT comment, int postOwnerID) { bool returnValue = false; comment.DATE_CREATED = DateTime.Now; returnValue = commentRepo.Add(comment); if (comment.POSTER_ID != postOwnerID) { notifManager.AddNotification(new NOTIFICATION() { RECEIVER_ID = postOwnerID, SEEN = "N", SENDER_ID = comment.POSTER_ID, NOTIF_TYPE = "C", POST_ID = comment.POST_ID, COMMENT_ID = comment.ID }); } return(returnValue); }
/// <summary> /// Invoked when Add Comment button clicked and add comment. /// </summary> /// <param name="sender">The Add Comment button clicked.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void AddCommentButton_Click(object sender, RoutedEventArgs e) { System.Diagnostics.Debug.WriteLine(newTitleTextBox.Text); if (newTitleTextBox.Text == "" || newContentTextBox.Text == "" || newTitleTextBox.Text.Trim() == "Title") { WarningTextBlock.Visibility = Visibility.Visible; return; } COMMENT commentEntity = new COMMENT(); commentEntity.COURSE_ID = course.ID.Value; commentEntity.CUSTOMER_ID = Constants.User.ID; commentEntity.TITLE = newTitleTextBox.Text; commentEntity.RATE = globalRate; commentEntity.TIME = DateTime.Now; commentEntity.CONTENT = newContentTextBox.Text; ctx.AddToCOMMENT(commentEntity); ctx.BeginSaveChanges(OnAddCommentComplete, null); }
public int CommentToPost(int postID, int userID, string content) { GenericDataAccess <COMMENT> dataAccessComment = new GenericDataAccess <COMMENT>(); GenericDataAccess <NOTIFICATION> dataAccessNotification = new GenericDataAccess <NOTIFICATION>(); int posterID = postDataAccess.GetProfileOwnerID(postID); int result = 0; if (!string.IsNullOrEmpty(content) && !string.IsNullOrWhiteSpace(content) && content.Length <= 1000) { var comment = new COMMENT() { POSTER_ID = userID, POST_ID = postID, DATE_CREATED = DateTime.Now, CONTENT = content.Trim() }; result = dataAccessComment.Create(comment); if (result == 1 && userID != posterID) { var notification = new NOTIFICATION() { NOTIF_TYPE = "C", POST_ID = postID, COMMENT_ID = comment.ID, RECEIVER_ID = posterID, SENDER_ID = userID, CREATED_DATE = DateTime.Now, SEEN = "N" }; dataAccessNotification.Create(notification); } } return(result); }
public static void TransToCommentData() { for (int i = 0; i < Info.items.Count; i++) { COMMENT a = Info.items[i]; CommentData comment = new CommentData(); comment.id = a.comment_id; comment.targetId = 0; comment.userId = a.user_id; comment.info = a.comment_info; comment.order = a.order; comment.commentType = (CommentType)a.target_type; List <CommentData> comments; int targetUserId = ZoneManager.Instance.GetCommentTargetId(comment); if (!ZoneManager.Instance.id2Comment.TryGetValue(targetUserId, out comments)) { comments = new List <CommentData>(); ZoneManager.Instance.id2Comment.Add(targetUserId, comments); } comments.Add(comment); } }
public ActionResult PostComment() { var mes = ""; try { int id = (int)Session["UserID"]; //var cmt = db.COMMENTs.Find(int.Parse(Request["POST_ID"])); var cmt = new COMMENT(); cmt.ID = CreateIDComment(); cmt.CONTEN = Request["comment"]; cmt.POST_ID = int.Parse(Request["POST_ID"]); cmt.CREATED = DateTime.Now; cmt.USER_ID = id; db.COMMENTs.Add(cmt); db.SaveChanges(); mes = "Bình luận thành công"; return(Json(mes, JsonRequestBehavior.AllowGet)); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } mes = "Đã có lỗi xảy ra "; return(Json(mes, JsonRequestBehavior.AllowGet)); }
protected override void Visit_COMMENT(COMMENT node) { /* MOVE CODE HERE */ }
public static COMMENT CreateCOMMENT(int ID, int cUSTOMER_ID, int cOURSE_ID, string cONTENT, global::System.DateTime tIME) { COMMENT cOMMENT = new COMMENT(); cOMMENT.ID = ID; cOMMENT.CUSTOMER_ID = cUSTOMER_ID; cOMMENT.COURSE_ID = cOURSE_ID; cOMMENT.CONTENT = cONTENT; cOMMENT.TIME = tIME; return cOMMENT; }
public void AddToCOMMENT(COMMENT cOMMENT) { base.AddObject("COMMENT", cOMMENT); }
public void AddComment(COMMENT comment) { _ctx.COMMENTs.Add(comment); _ctx.SaveChanges(); }
protected virtual void Visit_COMMENT(COMMENT node) { }