Beispiel #1
0
        public static DiaryNoteVo ToDiaryNoteVo(this DiaryNoteDac noteDac)
        {
            if (noteDac == null)
            {
                return(null);
            }

            return(new DiaryNoteVo
            {
                Id = noteDac.Id,
                CreatedOn = noteDac.CreatedOn,
                Details = noteDac.Details,
                Summary = noteDac.Summary,
                Title = noteDac.NoteTitle,
                ModifiedOn = noteDac.ModifiedOn,
                IsDraft = noteDac.IsDraft.GetValueOrDefault()
            });
        }
Beispiel #2
0
        public async Task UpdateNote(DiaryNoteVo noteVo)
        {
            DiaryNoteDac latest = await EnsureDocumentExist(noteVo);

            if (string.IsNullOrWhiteSpace(noteVo.Title))
            {
                throw new Exception("Document title cannot be null/empty");
            }
            if (string.IsNullOrWhiteSpace(noteVo.Details))
            {
                throw new Exception("Document body cannot be null/empty");
            }
            var currentUserId = SessionState.GetSession().User.Id;

            latest.NoteTitle  = noteVo.Title;
            latest.Details    = noteVo.Details;
            latest.Summary    = noteVo.Summary;
            latest.ModifiedOn = DateTime.UtcNow;
            latest.ModifiedBy = currentUserId;

            Repository.UpdateDiaryNote(latest);
            await EnsurePersisted();
        }