public void PutComment([FromBody] Comment comment) { Comment dbComment = context.Comments.FirstOrDefault(x => x.Id == comment.Id); dbComment.Clone(comment); context.SaveChanges(); }
public async Task <IModelServiceResponse <Comment> > Create(ActionContext actionContext, Comment comment) { comment = comment.Clone(); string userID = GetUserID(actionContext.HttpContext.User); if (userID != "") { comment.UserID = userID; } ValidationStateDictionary validationState = TryValidateModel(actionContext, comment); if (!validationState.IsValid()) //If Comment does not have validation errors { return(new ModelServiceResponse <Comment>(comment, validationState, HttpStatusCode.BadRequest)); } try { //Save the comment to the database _context.Add(comment); await _context.SaveChangesAsync(); // return(new ModelServiceResponse <Comment>(comment, validationState, HttpStatusCode.Created)); } catch { // return(new ModelServiceResponse <Comment>(null, validationState, HttpStatusCode.InternalServerError)); } }
protected override bool CloneEntity(IDiagram diagram) { if (diagram.DiagramType != DiagramType.ClassDiagram) { return(false); } return(((ClassDiagram)diagram).InsertComment(Comment.Clone())); }
/// <summary> /// Clones this instance. /// </summary> /// <returns>A new object that is a copy of this instance.</returns> public new DateTimeError Clone() { var datetimeErrorCloned = (DateTimeError)MemberwiseClone(); datetimeErrorCloned.Comment = Comment.Clone(); datetimeErrorCloned.Properties = Properties.Clone(); return(datetimeErrorCloned); }
/// <summary> /// Clones this instance. /// </summary> /// <returns>A new object that is a copy of this instance.</returns> public new PercentageErrorModel Clone() { var percentageErrorCloned = (PercentageErrorModel)MemberwiseClone(); percentageErrorCloned.Comment = Comment.Clone(); percentageErrorCloned.Properties = Properties.Clone(); return(percentageErrorCloned); }
/// <summary> /// Clones this instance. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> public new NumericError Clone() { var numericErrorCloned = (NumericError)MemberwiseClone(); numericErrorCloned.Comment = Comment.Clone(); numericErrorCloned.Properties = Properties.Clone(); return(numericErrorCloned); }
/// <summary> /// Clones this instance. /// </summary> /// <returns>A new object that is a copy of this instance.</returns> public new ScientificErrorModel Clone() { var scientificErrorCloned = (ScientificErrorModel)MemberwiseClone(); scientificErrorCloned.Comment = Comment.Clone(); scientificErrorCloned.Properties = Properties.Clone(); return(scientificErrorCloned); }
public override IPalasoDataObjectProperty Clone() { var clone = new LexEtymology(Type, Source); clone.Gloss = (MultiText)Gloss.Clone(); clone.Comment = (MultiText)Comment.Clone(); clone.Traits = new List <LexTrait>(Traits.Select(t => t.Clone())); clone.Fields = new List <LexField>(Fields.Select(f => (LexField)f.Clone())); //copies from MultiText clone.EmbeddedXmlElements = new List <string>(EmbeddedXmlElements); clone.Forms = Forms.Select(f => (LanguageForm)f.Clone()).ToArray(); return(clone); }
/// <summary> /// Used to duplicate all properties. Any property added must be duplicated here as well. /// </summary> /// <param name="newnode">The new node which is supposed to get a copy of the properties.</param> protected virtual void CloneProperties(Node newnode) { // clone attachements foreach (Attachments.Attachment attach in _attachments) { newnode.AddAttachment(attach.Clone(newnode)); } // clone comment if (_comment != null) { newnode._comment = _comment.Clone(); } }
public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup var original = new Comment { Body = "Random body" }; // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones); }
public async Task <IModelServiceResponse <Comment> > Reply(ActionContext actionContext, Comment comment) { comment = comment.Clone(); //If new comment has a parent Comment ID, set the comment to have the same Work ID as the parent Comment. if (comment.ParentID != null) { Comment parentComment = await _context.Comment.FindAsync(comment.ParentID); if (parentComment != null) { comment.WorkID = parentComment.WorkID; } } return(await Create(actionContext, comment)); }
/// <summary> /// Used to duplicate all properties. Any property added must be duplicated here as well. /// </summary> /// <param name="newnode">The new node which is supposed to get a copy of the properties.</param> protected virtual void CloneProperties(Node newnode) { // clone attachements foreach (Attachments.Attachment attach in _attachments) { newnode.AddAttachment(attach.Clone(newnode)); } System.Type type = this.GetType(); foreach (System.Reflection.FieldInfo fi in type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public)) { if (fi.DeclaringType == type) { fi.SetValue(newnode, fi.GetValue(this)); } } // clone comment if (_comment != null) { newnode._comment = _comment.Clone(); } }
protected override bool CloneEntity(Diagram diagram) { return(diagram.InsertComment(Comment.Clone())); }