Пример #1
0
        public void Update(Guid id, NotePatchInfo patchInfo)
        {
            if (patchInfo == null)
            {
                throw new ArgumentNullException(nameof(patchInfo));
            }

            var note = this.notes.FirstOrDefault(it => it.Id == id);

            if (note == null)
            {
                throw new NoteNotFoundException(id);
            }

            if (patchInfo.Title != null)
            {
                note.Title = patchInfo.Title;
            }

            if (patchInfo.Text != null)
            {
                note.Text = patchInfo.Text;
            }

            note.UpdatedAt = DateTime.UtcNow;
        }
Пример #2
0
        public static Model.NotePatchInfo Convert(View.NotePatchInfo viewNotePatchInfo)
        {
            if (viewNotePatchInfo == null)
            {
                throw new ArgumentNullException(nameof(viewNotePatchInfo));
            }

            var modelNotePatchInfo = new Model.NotePatchInfo
            {
                Title = viewNotePatchInfo.Title,
                Text  = viewNotePatchInfo.Text,
            };

            return(modelNotePatchInfo);
        }