private void GenerateAndSendEmail(object model)
 {
     foreach (var emailGenerator in _emailGenerators.Where(e => e.CanGenerateEmailFromModel(model)))
     {
         _sendEmail.Send(emailGenerator.GenerateEmail(model));
     }
 }
Пример #2
0
 public async Task <IActionResult> Registro(Cliente cliente)
 {
     if (ModelState.IsValid)
     {
         if (!await _dbAccess.CheckEmail(cliente.Email) && await _dbAccess.signup(cliente))
         {
             string EncryptEmail = StringCipher.EncryptString(cliente.Email);
             string body         = "<h1><a href='https://localhost:44315/Tienda/EmailConfirm?cEmail=" + EncryptEmail + "'>Confirmar cuenta</a></h1>";
             _sendEmail.Send(cliente.Email, "Bienvenido a Hipercor, " + cliente.DatosPersonales.Nombre, body);
             return(View("ConfirmarEmail"));
         }
         else
         { // si hay un error en el signup también entraría x aquí, hay que solucionarlo
             ViewData["error"] = "Ese correo electronico ya esta registrado";
             return(View());
         }
     }
     return(View());
 }
Пример #3
0
        private void SendReminderMail(int countDays)
        {
            var model = _userInfoRepository.GetDataFromUsersByConcreteDay(countDays);

            var template = _template.GetTemplate(REMINDER_MAIL_VIEW);

            foreach (var user in model)
            {
                var body = _compiler.Compile(template, REMINDER_MAIL_VIEW, new UserEmail
                {
                    Name     = user.Name,
                    LeftDays = countDays
                });
                _sendEmail.Send(user.To, SUBJECT_RECURRINGJOB, body);
            }
        }
Пример #4
0
        public void Invite(int securableId, string inviteeEmail, string fromName)
        {
            var invitation = new Invitation
            {
                SecurableId = securableId,
                Email       = inviteeEmail,
                Token       = Guid.NewGuid().ToString(),
                InviteDate  = DateTime.Now
            };

            _invitationRepo.Create(invitation);

            UrlHelper urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);

            _emailSender.Send(new PermissionOfferedEmail(inviteeEmail, fromName, _securableRepo.GetBy(s => s.Id == securableId).Name,
                                                         urlHelper.Action("Register", "Account", new { Token = invitation.Token, Area = "" }, HttpContext.Current.Request.Url.Scheme)));
        }
Пример #5
0
        public async Task <IActionResult> SubmitAsync([FromBody] BPOClientViewModel clientVM)
        {
            if (!ModelState.IsValid)
            {
                return(Json(BadRequest(ModelState)));
            }

            try
            {
                var client = await _register.Register(clientVM);

                _mail.Send(client);

                return(Json(StatusCode(201)));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
Пример #6
0
        public Account AddAccount(Account account, string email)
        {
            //todo Add  businnes logic for new account
            var uow = new UoW(_chatContext);

            using (var dbContextTransaction = uow.BeginTransaction())
            {
                try
                {
                    _accountRepository.Add(account);
                    uow.SaveChanges();
                    _sendEmail.Send("from", email, "message");
                    _logData.LogThis(DateTime.Now + " insert " + account.AccountID);
                    dbContextTransaction.Commit();
                }
                catch (Exception ex)
                {
                    //todo some logs
                    dbContextTransaction.Rollback();
                    throw;
                }
            }
            return(account);
        }
Пример #7
0
 public IActionResult Post([FromBody] SendEmailDto dto, [FromServices] ISendEmail email)
 {
     email.Send(dto);
     return(Ok());
 }