public async Task <EmailDto> PostEmail(EmailCreateableDto data)
        {
            _ = data ?? throw new ValidationException("Email data is empty");

            ValidateEmailRecipients(data.Recipients);

            var emailToCreate = _mapper.Map <EmailModel>(data);

            emailToCreate.Recipients = CreateEmailRecipients(emailToCreate, data.Recipients);

            var createdEmail = await _dbContext.Emails.AddAsync(emailToCreate);

            await _dbContext.SaveChangesAsync();

            return(_mapper.Map <EmailDto>(createdEmail.Entity));
        }
Exemplo n.º 2
0
 public async Task SaveAsync()
 {
     await dbContext.SaveChangesAsync();
 }