Exemplo n.º 1
0
        /// <inheritdoc/>
        public async Task <EmailResponse> PostItem(EmailRequest request)
        {
            _logger.LogInformation($"{nameof(EmailRepositoryService)} " +
                                   $"- {nameof(PostItem)} - Started, Request: {JsonConvert.SerializeObject(request)}");
            var newItem = _mapper.Map <Email>(request);

            var addedItem = await _repository.Add(newItem);

            _logger.LogInformation($"{nameof(EmailRepositoryService)} " +
                                   $"- {nameof(PostItem)} - Finished, Request: {JsonConvert.SerializeObject(request)}");
            return(_mapper.Map <EmailResponse>(addedItem));
        }
        /// <inheritdoc/>
        public async Task <EmailBodyResponse> PostItem(Guid languageId, IFormFile formFile)
        {
            _logger.LogInformation($"{nameof(EmailBodyRepositoryService)} " +
                                   $"- {nameof(PostItem)} - Started, LanguageId: {languageId}");

            if (formFile == null)
            {
                _logger.LogError($"{nameof(EmailBodyRepositoryService)} - Formfile is null");
                throw new ArgumentNullException();
            }

            var newItem = new EmailBody
            {
                LanguageId = languageId,
                Name       = formFile.FileName,
                File       = await FormFileToByteArray(formFile)
            };

            var addedItem = await _repository.Add(newItem);

            _logger.LogInformation($"{nameof(EmailBodyRepositoryService)} " +
                                   $"- {nameof(PostItem)} - Finished, LanguageId: {languageId}");
            return(_mapper.Map <EmailBodyResponse>(addedItem));
        }