Exemplo n.º 1
0
        public void UpdatePoem(PoemDTO poem)
        {
            var spec       = new GetPoemAndPublishedRevisionByIdSpec(poem.Id);
            var poemEntity = _poemRepository.GetBySpec(spec);

            if (poemEntity == null)
            {
                throw new ApplicationException();
            }

            poemEntity.Name                = poem.Name;
            poemEntity.Notes               = poem.Notes;
            poemEntity.ConceivedDateUTC    = poem.ConceivedDateLocal.ToUniversalTime();
            poemEntity.LastModifiedDateUTC = DateTime.UtcNow;
            if (poem.PublishedRevisionId != null && poem.PublishedRevisionId != Guid.Empty)
            {
                poemEntity.PublishedRevision = _revisionRepository.GetByGuid((Guid)poem.PublishedRevisionId);
            }
            else
            {
                poemEntity.PublishedRevision = null;
            }

            _poemRepository.Update(poemEntity);
        }
Exemplo n.º 2
0
        public PoemDTO GetPoemById(Guid id)
        {
            var spec = new GetPoemAndPublishedRevisionByIdSpec(id);
            var poem = _poemRepository.GetBySpec(spec);

            return(PoemDTO.CreateDTOFromEntity(poem));
        }