public async Task HandleAsync(AddPendingRegistration command, ICorrelationContext context) { PendingRegistration pendingReg = await _regRepo.GetAsync(x => x.Email == command.Email && x.PracticeId == command.PracticeId); if (pendingReg != null) { throw new MedParkException("specialist_registration_already_exists", $"Pending registration on practice {command.PracticeId} for specialist with email {command.Email} already exists."); } //Generate a new OTP var otp = String.Empty.NewOTP(8); pendingReg = new PendingRegistration(command.Id) { FirstName = command.FirstName, LastName = command.LastName, Email = command.Email, Mobile = command.Mobile, PracticeId = command.PracticeId, IsAdmin = command.IsAdmin, OTP = otp }; await _regRepo.AddAsync(pendingReg); }
public static void SendPendingEmail(PendingRegistration pending) { string password; string RegistrationEmail; using (StreamReader sr = new StreamReader(PassPath)) { password = sr.ReadLine(); } using (StreamReader sr = new StreamReader(RegistrationEmailPath)) { RegistrationEmail = sr.ReadToEnd(); } SmtpClient client = new SmtpClient(SmtpHost, SmtpPort); client.Credentials = new NetworkCredential(Username, password); client.EnableSsl = true; MailMessage message = new MailMessage() { From = new MailAddress(SendingAddress), Subject = "Bug Tracker Registration", Body = RegistrationEmail }; message.To.Add(pending.Email); client.Send(message); }
public ActionResult AddUser(AddUserViewModel model) { if (ModelState.IsValid) { var organizationId = db.Users.Find(User.Identity.GetUserId()).OrganizationId; var pending = new PendingRegistration() { Email = model.Email, Role = model.Role, OrganizationId = organizationId }; db.PendingRegistrations.Add(pending); db.SaveChanges(); Email.SendPendingEmail(pending); return(RedirectToAction("Index", "Admin")); } model.RoleOptions = db.Roles.ToList(); return(View(model)); }
public async Task HandleAsync(UpdatePendingRegistration command, ICorrelationContext context) { PendingRegistration pendReg = await _regRepo.GetAsync(command.Id); if (pendReg == null) { throw new MedParkException("specialist_registration_does_not_exists", $"The pending registration with Id {command.Id} does not exists."); } pendReg.FirstName = command.FirstName; pendReg.LastName = command.LastName; pendReg.Email = command.Email; pendReg.Mobile = command.Mobile; pendReg.PracticeId = command.PracticeId; pendReg.IsAdmin = command.IsAdmin; pendReg.UpdatedModifiedDate(); await _regRepo.UpdateAsync(pendReg); }