示例#1
0
            public async Task <Unit> Handle(Command request, CancellationToken cancellationToken)
            {
                var streamPersisted = _streamRepository.GetStream(request.Id).Result;

                /* Caso stream nao encontrada nao sera prosseguida a edicao */
                if (streamPersisted == null)
                {
                    throw new  NotFoundException("Stream nao encontrada");
                }

                /* Atualizacao dos valores */
                streamPersisted.Name        = request.Name ?? streamPersisted.Name;
                streamPersisted.Description = request.Description ?? streamPersisted.Description;
                streamPersisted.CountryId   = request.IdCountry ?? streamPersisted.CountryId;

                /* Tentativa de persistencia */
                var sucesso = await _streamRepository.UpdateStream(streamPersisted);

                /* Caso o salvar tenha sido bem sucedido */
                if (sucesso)
                {
                    return(Unit.Value);
                }

                throw new SaveException("Nao foi possivel salvar, tente novamente");
            }
示例#2
0
            public async Task <Unit> Handle(Command request, CancellationToken cancelation)
            {
                Stream stream = await _streamRepository.GetStream(request.Id);

                if (stream == null)
                {
                    throw new  NotFoundException($"Stream with id {request.Id} not found");
                }

                Boolean result = await _streamRepository.DeleteStream(stream);

                if (result)
                {
                    return(Unit.Value);
                }

                throw new SaveException("Problem saving changes");
            }
示例#3
0
            public async Task <Stream> Handle(Query request, CancellationToken cancellationToken)
            {
                var stream = await _streamRepository.GetStream(request.Id);

                return(stream);
            }