public async Task SendConfirmationMail(PersonnelCreatedEmail personnelCreatedEmail)
        {
            var templateJson = personnelCreatedEmail.ToJson();
            var body         = _templateBusinessService.CreateText(templateJson, personnelCreatedEmail.TemplateName);

            if (body == null)
            {
                return;
            }
            try
            {
                await _emailBusinessService.SendEmail(new EmailData
                {
                    Subject       = personnelCreatedEmail.Subject, //ToDo
                    ToAddressList = personnelCreatedEmail.ToAddress,
                    IsHtml        = true,
                    Body          = body
                });
            }
            catch (Exception)
            {
                throw new Exception();
            }
        }
예제 #2
0
        private async Task <ValidationResult> SendSellerApprovalStateEmail(Seller seller)
        {
            var validationResult         = new ValidationResult();
            var sellerApprovalStateEmail = new SellerApprovalStateEmail()
            {
                FullName     = seller.Name,
                Subject      = "Seller Approval",
                TemplateName = "SellerApprovalState",
                ToAddress    = new List <string>()
                {
                    seller.Email
                },
                ApprovalState = System.Enum.GetName(typeof(SellerApprovalState), seller.ApprovalStateId)
            };

            try
            {
                var templateJson = sellerApprovalStateEmail.ToJson();
                var body         = _templateBusinessService.CreateText(templateJson, sellerApprovalStateEmail.TemplateName);
                if (body != null)
                {
                    await _emailBusinessService.SendEmail(new EmailData
                    {
                        Subject       = sellerApprovalStateEmail.Subject, //ToDo
                        ToAddressList = sellerApprovalStateEmail.ToAddress,
                        IsHtml        = true,
                        Body          = body
                    });
                }
                validationResult.Succeeded = true;
            }
            catch (Exception ex)
            {
                validationResult.Succeeded = false;
                validationResult.Errors    = new List <string> {
                    ex.InnerMessage()
                };
                validationResult.Exception = ex;
            }
            return(validationResult);
        }