/// <summary> /// Saves a single <see cref="NoteComment"/> /// </summary> /// <param name="noteComment"></param> public void Save(NoteComment noteComment) { using (var repo = new NoteCommentRepository()) { repo.AddOrUpdate(noteComment); } }
public void AddNoteComment(object noteCommentVm) { var noteComment = new NoteComment(); NoteCommentViewModel noteCommentDto = JsonConvert.DeserializeObject <NoteCommentViewModel>(noteCommentVm.ToString()); NotelyContext.Current.Services.NoteCommentService.Save(noteComment.Convert(noteCommentDto)); }
/// <summary> /// Adds or updates a <see cref="NoteComment"/> object /// </summary> /// <param name="entity"></param> public void AddOrUpdate(NoteComment entity) { if (entity.Id > 0) { _dbContext.Database.Update(entity); } else { _dbContext.Database.Insert(entity); } }
public NoteComment AddNoteComment(NoteComment noteComment) { NoteCommentEntity entity = noteComment.ToEntity(); noteComment.CreateTime = DateTime.Now; noteComment.DeletedTime = DateTime.Now; noteComment.IsDeleted = false; this.dbContext.NoteComments.Add(entity); this.dbContext.SaveChanges(); return(entity.ToModel()); }
protected void btnWriteComment_Click(object sender, EventArgs e) { NoteComment comment = new NoteComment(); comment.BoardId = Convert.ToInt32(Request["Id"]); // 게시글 번호 comment.Name = txtName.Text; comment.Password = txtPassword.Text; comment.Opinion = txtOpinion.Text; // 댓글 내용 _repo.AddNoteComment(comment); // 저장 Response.Redirect($"{Request.ServerVariables["SCRIPT_NAME"]}?Ud={Request["Id"]}"); // BoardView.aspx 등 동적으로 웹페이지 이름을 차단 }
public static NoteCommentEntity ToEntity(this NoteComment model) { return(new NoteCommentEntity() { Id = model.Id, NoteId = model.NoteId, CreatorId = model.CreatorId, CommentId = model.CommentId, CreateTime = model.CreateTime, IsDeleted = model.IsDeleted, DeletedTime = model.DeletedTime }); }
/// <summary> /// Converts a <see cref="NoteCommentViewModel"/> object to a <see cref="NoteComment"/> object /// </summary> /// <param name="comment"></param> /// <param name="commentVm"></param> /// <returns></returns> public static NoteComment Convert(this NoteComment comment, NoteCommentViewModel commentVm) { var result = new NoteComment() { Id = commentVm.Id, Datestamp = DateTime.Now, LogComment = commentVm.LogComment, LogType = commentVm.LogType, NoteId = commentVm.NoteId, UserId = commentVm.User.Id }; return(result); }
protected void btnWriteComment_Click(object sender, EventArgs e) { NoteComment comment = new NoteComment(); comment.BoardId = Convert.ToInt32(Request["Id"]); //부모글 comment.Name = txtName.Text; //이름 comment.Password = txtPassword.Text; //암호 comment.Opinion = txtOpinion.Text; //댓글 //데이터 입력 _repository.AddNoteComment(comment); Response.Redirect($"{Request.ServerVariables["SCRIPT_NAME"]}?Id={Request["Id"]}"); }
protected void btnWriteComment_OnClick(object sender, EventArgs e) { // 코멘트 객체 생성 NoteComment comment = new NoteComment(); comment.BoardId = Convert.ToInt32(Request["Id"]); comment.Name = txtName.Text; comment.Password = txtPassword.Text; comment.Opinion = txtOpinion.Text; // 코멘트 입력 repo.AddNoteComment(comment); Response.Redirect($"{Request.ServerVariables["SCRIPT_NAME"]}?Id={Request["Id"]}&ANum={Request["ANum"]}"); }
//删除笔记评论 public bool delnotec(int notecid) { NoteComment nc = db.NoteComment.Where(b => b.NoteCommentID == notecid).FirstOrDefault(); if (nc != null) { db.NoteComment.Remove(nc); db.SaveChanges(); return(true); } else { return(false); } }
[Authorize] // 스팸 글 때문에 추가 public IActionResult CommentAdd( int BoardId, string txtName, string txtPassword, string txtOpinion) { // 댓글 개체 생성 NoteComment comment = new NoteComment(); comment.BoardId = BoardId; comment.Name = txtName; comment.Password = (new Dul.Security.CryptorEngine()).EncryptPassword(txtPassword); comment.Opinion = txtOpinion; // 댓글 데이터 저장 _commentRepository.AddNoteComment(comment); // 댓글 저장 후 다시 게시판 상세 보기 페이지로 이동 return(RedirectToAction("Details", new { Id = BoardId })); }
public ActionResult notecomment(int noteid, string ccontent) { if (ccontent != null) { NoteComment nc = new NoteComment(); nc.likenum = 0; nc.Nccontent = ccontent; nc.NoteID = noteid; nc.Time = DateTime.Now; nc.UserID = Convert.ToInt32(Session["User_id"]); ncomments.AddNoteComment(nc); ycsv.allnotecommentbyid = ncomments.allnotecomment(noteid); //return PartialView(ycsv); return(Content("评论成功")); } else { return(Content("请输入")); } }
public ManagerResult <NoteComment> AddNoteComment(NoteComment noteComment) { ManagerResult <NoteComment> result = new ManagerResult <NoteComment>(); try { result.ResultData = NoteCommentDAL.Instance.AddNoteComment(noteComment); if (result.ResultData == null) { result.Code = 1; result.Description = "添加失败!"; } } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); result.Code = -1; } return(result); }
public NoteComment AddNoteComment(NoteComment comment) { return this.catalog.NoteComments.Create(comment); }
public void AddNoteComment(NoteComment notecomment) { inotecomment.AddNoteComment(notecomment); }
public NoteComment AddNoteComment(NoteComment noteComment) { try { if (noteComment == null) { return(null); } DbParameter[] parameters = new DbParameter[] { new SqlParameter() { ParameterName = SpParamsOfNoteComment.Sp_Insert_NoteComment_NoteId, Value = noteComment.NoteId }, new SqlParameter() { ParameterName = SpParamsOfNoteComment.Sp_Insert_NoteComment_CreatorId, Value = noteComment.CreatorId }, new SqlParameter() { ParameterName = SpParamsOfNoteComment.Sp_Insert_NoteComment_CommentId, Value = noteComment.CommentId } }; using (DataSet dataSet = DbHelper.Instance.RunProcedureGetDataSet(SpNamesOfNoteComment.Sp_Insert_NoteComment, parameters)) { NoteCommentEntity entity = null; if (dataSet != null && dataSet.Tables != null && dataSet.Tables.Count != 0 && dataSet.Tables[0].Rows != null && dataSet.Tables[0].Rows.Count != 0) { DataRow dataRow = dataSet.Tables[0].Rows[0]; DataColumnCollection dataColumns = dataSet.Tables[0].Columns; entity = new NoteCommentEntity() { Id = (int)dataRow[dataColumns[0]], NoteId = (int)dataRow[dataColumns[1]], CreatorId = (int)dataRow[dataColumns[2]], CommentId = (int)dataRow[dataColumns[3]], CreateTime = (DateTime)dataRow[dataColumns[4]], IsDeleted = (bool)dataRow[dataColumns[5]], DeletedTime = (DateTime)dataRow[dataColumns[6]] }; } if (entity == null) { return(null); } return(entity.ToModel()); } } catch (Exception ex) { throw ex; } }
public void AddNoteComment(NoteComment notecomment) { db.NoteComment.Add(notecomment); db.SaveChanges(); }
/// <summary> /// Delete <see cref="NoteComment"/> object /// </summary> /// <param name="entity"></param> public void Delete(NoteComment entity) { _dbContext.Database.Delete(entity); }
public ManagerResult <NoteComment> AddNoteComment(NoteComment noteComment) { INoteCommentManager business = NoteCommentBusinessFactory.Instance.Create(this.Version); return(business.AddNoteComment(noteComment)); }
/// <summary> /// Converts a <see cref="NoteComment"/> object to a <see cref="NoteCommentViewModel"/> object /// </summary> /// <param name="commentVm"></param> /// <param name="comment"></param> /// <returns></returns> public static NoteCommentViewModel Convert(this NoteCommentViewModel commentVm, NoteComment comment) { var userVm = new UserViewModel(); var _note = NotelyContext.Current.Services.NoteService.GetById(comment.NoteId); var result = new NoteCommentViewModel() { Id = comment.Id, Datestamp = umbraco.library.FormatDateTime(comment.Datestamp.ToString(), "dd MMM yyyy HH:mm:ss"), LogComment = comment.LogComment, LogType = comment.LogType, NoteId = comment.NoteId, NoteName = _note.Title, User = userVm.Convert( UmbracoContext.Current.Application.Services.UserService.GetUserById(comment.UserId) ) }; return(result); }