Beispiel #1
0
        /// <summary>
        /// Add note to the contact.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="note"></param>
        /// <param name="modifiedBy"></param>
        /// <returns></returns>
        public Result AddNote(ContactNote note, Guid modifiedBy)
        {
            //Fail pushed onto the CQRS pipeline execution
            var existingNotes = JsonConvert.DeserializeObject <ICollection <ContactNote> >(_notes);

            if (!existingNotes.Any(x => x.Equals(note)))
            {
                existingNotes.Add(note);
                _notes = JsonConvert.SerializeObject(existingNotes);


                return(Result.Ok());
            }

            return(Result.Fail($"Note already existing : {note.ToString()}"));
        }
Beispiel #2
0
        /// <summary>
        /// Remove note from the contact.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="note"></param>
        /// <param name="modifiedBy"></param>
        /// <returns></returns>
        public Result RemoveNote(ICrmContext context, ContactNote note, Guid modifiedBy)
        {
            //Fail pushed onto the CQRS pipeline execution
            var existingNotes = JsonConvert.DeserializeObject <ICollection <ContactNote> >(_notes);

            if (!existingNotes.Any(x => x.Equals(note)))
            {
                existingNotes.Remove(note);
                _notes = JsonConvert.SerializeObject(existingNotes);


                context.ClientContacts.Update(this);

                return(Result.Ok());
            }

            return(Result.Fail($"Trying to remove inexistent note {note.Note}"));
        }