public async Task<ActionResult> OwnerRegister(RegisterViewModel model) { if (ModelState.IsValid) { string message = _employee.AddEmployees(model); int index = message.IndexOf('~') + 1; var user = message.Substring(index, 36).Trim(); string code = await UserManager.GenerateEmailConfirmationTokenAsync(user); var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user, code }, Request.Url.Scheme); var boddy = new StringBuilder(); var boddyConf = new StringBuilder(); boddy.Append(message.Substring(index + 36).Trim()); string confirmMessage = "Hi! " + model.Email + "<br/>" + "Click the link to confirm your account " + callbackUrl; boddyConf.Append(confirmMessage); string bodyForConf = boddyConf.ToString(); string bodyFor = boddy.ToString(); string subjectFor = "Registration"; string subjectForConf = "Confirm Email"; string toFor = message.Substring(0, index - 1).Trim(); var mail = new MailAddress("*****@*****.**", "SPBFI-Administrators"); WebMail.SmtpServer = "pod51014.outlook.com"; WebMail.SmtpPort = 587; WebMail.UserName = "******"; WebMail.Password = "******"; WebMail.From = mail.ToString(); WebMail.EnableSsl = true; try { WebMail.Send(toFor, subjectFor, bodyFor); } catch { // ignored } try { WebMail.Send(toFor, subjectForConf, bodyForConf); } catch { //null } return RedirectToAction("OwnerGetAllEmployees"); } return View(model); }
public ActionResult Edit(RegisterViewModel model) { if (ModelState.IsValid) { _employee.UpdateEmployee(model); return RedirectToAction("GetAllEmployees"); } return View(model); }