示例#1
0
 public ActionResult Contact(ContactViewModel model)
 {
     if (ModelState.IsValid)
     {
         DebugMailService service = new DebugMailService();
         service.SendMail(model.Email, model.Name, "Hello", model.Message);
     }
     ModelState.Clear();
     ViewBag.Message = "Mail Sent . Thanks !!";
     return(View());
 }
示例#2
0
 public void TestSendTask()
 {
     Debug.WriteLine($"Ожидаем {DateTime.Now:F}...."); 
     Debug.WriteLine($"ОТПРАВКА {DateTime.Now:F}....");
     var mailService = new DebugMailService();
     var sc = new SchedulerClass();
     sc.SendTask(senderTasks, mailService);
     var countExpected = 20;
     var countSend = senderTasks.Sum(x => x.IsSendEnd ? 1 : 0);
     Assert.AreEqual(countExpected, countSend);
 }
示例#3
0
        public async Task <IActionResult> Registration(/*[FromForm]*/ RegisterViewModel vm, string returnUrl)
        {
            if (vm.Email.Contains("aol.com") || vm.Email.Contains("amail.com"))
            {
                ModelState.AddModelError("", "We don't support this email domain addresses ");
            }
            if (ModelState.IsValid)
            {
                if (await _userManager.FindByEmailAsync(vm.Email) == null)
                {
                    WorldUser user = Mapper.Map <WorldUser>(vm);

                    var result = await _userManager.CreateAsync(user, vm.Password);

                    if (result.Succeeded)
                    {
                        var codes = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                        var callbackUrl = Url.Action(
                            "ConfirmEmail",
                            "Signup",
                            new { userId = user.Id, code = codes },
                            protocol: HttpContext.Request.Scheme
                            );

                        DebugMailService mailService = new DebugMailService();
                        await mailService.ConfirmationByEmailMsgAsync(vm.Email, "Confirm Your account, please.",
                                                                      $"Confirm registration folowing the link: <a href='{callbackUrl}'>Confirm email NOW</a>");

                        return(RedirectToAction("Index", "App"));
                    }
                    else
                    {
                        foreach (var error in result.Errors)
                        {
                            ModelState.AddModelError("", error.Description);
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError(vm.Email, "This email is already registered!");
                }
            }

            return(View(vm));
        }