Пример #1
0
        public async Task <Response <Trade> > SaveAsync(Trade payload)
        {
            try
            {
                _tradeRepository.Add(payload);

                await _unitOfWork.CompleteAsync();

                return(new Response <Trade>(payload));
            }
            catch (Exception ex)
            {
                _logger.LogError($"{nameof(TradeService)} {nameof(SaveAsync)} {ex.Message}");

                return(new Response <Trade>(ex.Message));
            }
        }
Пример #2
0
        public async Task <GenreResponse> SaveAsync(Genre genre)
        {
            try
            {
                await _genresRepository.AddAsync(genre);

                await _unitOfWork.CompleteAsync();

                return(new GenreResponse(genre));
            }
            catch (Exception ex)
            {
                var message = $"An error occurred when saving the genre: {ex.Message}";

                _logger.LogError(message);

                return(new GenreResponse(message));
            }
        }
Пример #3
0
        public async Task AddTest()
        {
            // Arrange
            var lookup = new Lookup {
                Name = "Facebook"
            };

            // Act
            _lookupRepository.Add(lookup);
            await _saveRepository.CompleteAsync();

            var response = await _lookupRepository.ListAsync();

            var searchEngine = await _lookupRepository.FindByIdAsync(3);

            // Assert
            Assert.AreEqual(3, response.Count());
            Assert.AreEqual("FACEBOOK", searchEngine.Name.ToUpper());
        }
Пример #4
0
        public async Task <MovieResponse> SaveAsync(Models.Movie movie)
        {
            try
            {
                await _moviesRepository.AddAsync(movie);

                await _unitOfWork.CompleteAsync();

                return(new MovieResponse(movie));
            }
            catch (Exception ex)
            {
                var message = $"An error occurred when saving the movie: {ex.Message}";

                _logger.LogError(message);

                return(new MovieResponse(message));
            }
        }
Пример #5
0
        public async Task <Response <Category> > SaveAsync(Category payload)
        {
            try
            {
                var category = new Category {
                    Name = payload.Name, CreatedBy = payload.CreatedBy
                };

                _categoryRepository.Add(category);

                await _unitOfWork.CompleteAsync();

                return(new Response <Category>(category));
            }
            catch (Exception ex)
            {
                _logger.LogError($"{nameof(CategoryService)} {nameof(SaveAsync)} {ex.Message}");

                return(new Response <Category>(ex.Message));
            }
        }