Ejemplo n.º 1
0
 private void ShowMessage(User user)
 {
     var streamReader = new StreamReader(Server.MapPath(@"~/MailTemplates/activation.html"));
     var htmlContent = streamReader.ReadToEnd();
     divMessage.InnerHtml = htmlContent.Replace("[USER]", user.FirstName + " "+ user.LastName);
     streamReader.Close();
 }
Ejemplo n.º 2
0
        public bool Submit(out string returnMessage)
        {
            returnMessage = string.Empty;
            var success = true;
            try
            {
                var message = string.Empty;
                if (CommonFunctions.CheckIfUserExists(txtEmailId.Text, txtUserId.Text, out message,"GU"))
                {
                    returnMessage = message;
                    return false;
                }


                using (var dataContext = new nChangerDb())
                {
                    var dbEntry = new User
                    {
                        Id = Guid.NewGuid(),
                        UserTypeId="GU",
                        UserId = txtUserId.Text,
                        Email = txtEmailId.Text,
                        Password = txtPassword.Text,
                        FirstName = txtFirstName.Text,
                        MiddleName = txtMiddleName.Text,
                        LastName = txtLastName.Text,
                        Phone = txtPhone.Text,
                        City = txtCity.Text,
                        State = ddlState.SelectedIndex == -1 ? txtState.Text : ddlState.SelectedValue,
                        Zip = txtZipCode.Text,
                        Country = ddlCountry.SelectedValue,
                        Address = txtAddressLine1.Text,
                        Address2 = txtAddressLine2.Text,
                        IP = CommonFunctions.GetIpAddress(),
                        IsActive = false,
                        EmailVerified = false,
                        VerificationCode = Guid.NewGuid().ToString(),
                        RegistrationDate = DateTime.Now
                    };

                    dataContext.Users.Add(dbEntry);
                    dataContext.SaveChanges();
                    _queryId = dbEntry.UserId;
                    AddUserPackage(_queryId);
                    returnMessage = SendRegistrationMail(dbEntry) ? "SUCCESS" : "MAIL_ERROR";
                }

            }
            catch (DbEntityValidationException ex)
            {
                success = false;
                returnMessage = ex.EntityValidationErrors.SelectMany(eve => eve.ValidationErrors).Aggregate(returnMessage, (current, ve) => current + (ve.PropertyName + " Error Msg:" + ve.ErrorMessage));
            }

            return success;
        }
Ejemplo n.º 3
0
        private bool SendRecoveryMail(User user)
        {
            var success = true;
            try
            {
                var streamReader = new StreamReader(Server.MapPath(@"~/MailTemplates/forgotPass.html"));
                var htmlContent = streamReader.ReadToEnd();
                var mailBody = htmlContent.Replace("[USER]", user.UserId).Replace("[LINK]", @"http://" + Request.Url.Host + @"/account/passwordRecovery.aspx?id=" + user.VerificationCode);
                streamReader.Close();

                success = CommonFunctions.SendMail(user.Email, "[Name Changer] Password reset request", true, mailBody, true);
            }
            catch (Exception ex)
            {
                success = false;
            }
            return success;
        }
Ejemplo n.º 4
0
        private bool SendRegistrationMail(User user)
        {
            var success = true;
            try
            {
                var streamReader = new StreamReader(Server.MapPath(@"~/MailTemplates/signup.html"));
                var htmlContent = streamReader.ReadToEnd();
                var mailBody = htmlContent.Replace("[USER]", user.FirstName).Replace("[LINK]", @"http://"+ Request.Url.Host+ @"/account/verification.aspx?id=" + user.VerificationCode);
                streamReader.Close();

                success = CommonFunctions.SendMail(user.Email, "Registration Complete", true, mailBody, true);
            }
            catch (Exception ex)
            {
                success = false;
            }
            return success;
        }