public ActionResult Verify(string Code) { var data = sDal.GetPersonSecurityCodeByCode(Code); if (data == null) { return(RedirectToAction("Login")); } if (data.ExpiredOn.HasValue) { return(RedirectToAction("Login")); } VerifictionViewModel rVM = new VerifictionViewModel() { FirstName = data.Person.Fname, MiddleName = data.Person.Mname, LastName = data.Person.Lname, PrimaryEmail = cDal.GetPersonEmailByPersonId(data.Person.Id).Where(x => x.Type.Id == 1).FirstOrDefault().Value, PhoneNumber = cDal.GetPersonPhoneByPersonId(data.Person.Id).Where(x => x.Type.Id == 1).FirstOrDefault().Value, PersonId = data.Person.Id, VerificationCode = Code, DateOfBirth = data.Person.DOB, SalutuionId = data.Person.SalutationId.ToString(), Gender = data.Person.GenderId.ToString() }; return(View(rVM)); }
public ActionResult CompleteRegistration(VerifictionViewModel pVM) { if (ModelState.IsValid) { sDal.ApplyPersonSecurityCode(pVM.PersonId, pVM.VerificationCode); sDal.SaveUserLogin(pVM.UserName, Helpers.BGHelper.ComputeHash(pVM.Password), pVM.PersonId); cDal.UpdatePerson(pVM.FirstName, pVM.MiddleName, pVM.LastName, pVM.PersonId, Int16.Parse(pVM.Gender), pVM.DateOfBirth.Value, int.Parse(pVM.SalutuionId)); sDal.LogMe("TRACKING", "REGISTRATION HAS BEEN COMPLTED", pVM.PersonId); mDal.CreateMember(pVM.PersonId, DateTime.Now.Date, 2, true); sDal.LogMe("TRACKING", "MEMBERSHIP HAS BEEN COMPLTED", pVM.PersonId); try { Dictionary <string, string> param = new Dictionary <string, string>(); param.Add("NAME", $"{pVM.FirstName} {pVM.LastName}"); param.Add("Username", pVM.UserName); param.Add("Password", Mask(pVM.Password)); string html = bgService.GetHtml(AppDomain.CurrentDomain.BaseDirectory + ConfigurationManager.AppSettings["mxTemplatePath"] + "tmpCredential.html", param); var mxType = lookupDal.GetAllMailoutType().Where(x => x.Id == 2).FirstOrDefault(); var q = mxDAL.PushNotification(cDal.GetPersonByPersonId(pVM.PersonId), param, mxType.Id, pVM.PrimaryEmail, html); var res = emailService.EmailBySMTP(pVM.PrimaryEmail, ConfigurationManager.AppSettings["SMTP_FROM"], html, mxType.Subject); if (res.HasError) { sDal.LogMe("EMAILEXCEPTION", $"EMAIL EXCEPTION: {res.ErrorMessage}", pVM.PersonId); mxDAL.UpdateNotification(q.Id); } } catch (Exception ex) { sDal.LogMe("EXCEPTION", ex.InnerException.Message, pVM.PersonId); } } ViewBag.Name = pVM.FirstName; return(RedirectToAction("ThankYouForVerification", new { Name = pVM.FirstName, EmailAddress = pVM.PrimaryEmail })); }