public async Task <GetEmailTemplateDto> Create(NewEmailTemplateDto newTemplate)
        {
            var template = _mapper.Map <EmailTemplate>(newTemplate);
            await _repository.Create(template);

            var getDto = _mapper.Map <GetEmailTemplateDto>(template);

            return(getDto);
        }
Beispiel #2
0
        public static NewEmailTemplateDto NewEmailTemplateDto()
        {
            var newEmailTemplateDto = new NewEmailTemplateDto
            {
                Purpose      = "new purpose",
                Subject      = "new subject",
                Template     = "new template",
                Instructions = "new instructions"
            };

            return(newEmailTemplateDto);
        }
        public async Task Update(int id, NewEmailTemplateDto updateData)
        {
            if (updateData == null)
            {
                throw new ArgumentNullException(nameof(updateData));
            }

            var itemToUpdate = await _repository.GetById(id);

            if (itemToUpdate == null)
            {
                throw new InvalidOperationException();
            }

            _mapper.Map(updateData, itemToUpdate);
            await _repository.Update(itemToUpdate);
        }
        public async Task <IActionResult> Post(NewEmailTemplateDto newEmailTemplate)
        {
            var createdTemplateDto = await _emailTemplatesService.Create(newEmailTemplate);

            return(Ok(createdTemplateDto));
        }
        public async Task <IActionResult> Put(int id, [FromBody] NewEmailTemplateDto newEmailTemplate)
        {
            await _emailTemplatesService.Update(id, newEmailTemplate);

            return(NoContent());
        }