public int SaveItem(Person currentPerson, CommentDto newCommentDto) { var newComment = new Comment(); Mapper.Map(newCommentDto, newComment); newComment.MadeByPersonId = currentPerson.PersonId; newComment.MadeByRoleId = currentPerson.RoleId; Context.AddToComments(newComment); Context.SaveChanges(); return newComment.CommentId; }
/// <summary> /// Deprecated Method for adding a new object to the Comments EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToComments(Comment comment) { base.AddObject("Comments", comment); }
/// <summary> /// Create a new Comment object. /// </summary> /// <param name="commentId">Initial value of the CommentId property.</param> /// <param name="comment1">Initial value of the Comment1 property.</param> /// <param name="aboutPersonId">Initial value of the AboutPersonId property.</param> /// <param name="madeByPersonId">Initial value of the MadeByPersonId property.</param> /// <param name="madeByRoleId">Initial value of the MadeByRoleId property.</param> /// <param name="commentDate">Initial value of the CommentDate property.</param> public static Comment CreateComment(global::System.Int32 commentId, global::System.String comment1, global::System.Int32 aboutPersonId, global::System.Int32 madeByPersonId, global::System.Int32 madeByRoleId, global::System.DateTime commentDate) { Comment comment = new Comment(); comment.CommentId = commentId; comment.Comment1 = comment1; comment.AboutPersonId = aboutPersonId; comment.MadeByPersonId = madeByPersonId; comment.MadeByRoleId = madeByRoleId; comment.CommentDate = commentDate; return comment; }