Example #1
0
        public async Task <IActionResult> SendUpdateMessage([FromBody] SendInfoDTO sendInoInfoDto)
        {
            await Task.Yield();

            if (ModelState.IsValid)
            {
                if (string.IsNullOrEmpty(sendInoInfoDto.Contact?.ContactPossibilities?.Mail))
                {
                    return(BadRequest("could not send message"));
                }

                if (!sendInoInfoDto.Delete)
                {
                    var emailData = _dataProtectionService.GetContactChangesForEmail(sendInoInfoDto.ContactChanges);
                    if (!string.IsNullOrEmpty(emailData))
                    {
                        _mailService.SendDataProtectionUpdateMessage(sendInoInfoDto.Contact.Name, sendInoInfoDto.Contact.PreName, sendInoInfoDto.Contact.ContactPossibilities.Mail, emailData);
                    }
                }
                else
                {
                    var emailData = _dataProtectionService.GetContactDeletesForEmail();
                    if (!string.IsNullOrEmpty(emailData))
                    {
                        _mailService.SendDataProtectionDeleteMessage(sendInoInfoDto.Contact.Name, sendInoInfoDto.Contact.PreName, sendInoInfoDto.Contact.ContactPossibilities.Mail, emailData);
                    }
                }

                return(Ok());
            }

            return(BadRequest(""));
        }