Exemplo n.º 1
0
        public ActionResult CreateUser(WebPlastic.Models.User model)
        {
            ConnectionDataBase.StoreProcediur data = new ConnectionDataBase.StoreProcediur();
            CredencialesDeAcceso access            = new CredencialesDeAcceso();
            string          password   = access.CreatePassword();
            RijndaelManaged myRijndael = new RijndaelManaged();

            myRijndael.GenerateKey();
            myRijndael.GenerateIV();
            string user = access.CreateUserName(model.Name, model.Last).ToLower();

            model.UserName = user;
            Byte[] contrasenaEncriptada = access.EncryptStringToBytes(password, myRijndael.Key, myRijndael.IV);

            DataTable dt  = data.SaveUser(model, contrasenaEncriptada, myRijndael.Key, myRijndael.IV);
            DataRow   row = dt.Rows[0];

            if (dt.Rows.Count > 0)
            {
                SentEmail correoCreacion = new SentEmail();
                string    bodyCorreo     = correoCreacion.EmailForNewUser(model.Name, model.Last, model.UserName, password);
                correoCreacion.SendEmailForNewUser(model.Email, "Creación de Usuario", "*****@*****.**", bodyCorreo, "*****@*****.**", "*****@*****.**", "hola1234", "");
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
            public DataTable UpdateUser(WebPlastic.Models.User model)
            {
                try
                {
                    SqlConnection  con = new SqlConnection(ConfigurationManager.ConnectionStrings["webplasticEntities"].ConnectionString);
                    SqlDataAdapter da  = new SqlDataAdapter("SP_UpdateProfile", con);
                    da.SelectCommand.Parameters.Add("@pidUser", SqlDbType.Int).Value       = model.idUser;
                    da.SelectCommand.Parameters.Add("@pName", SqlDbType.VarChar).Value     = model.Name;
                    da.SelectCommand.Parameters.Add("@pLast", SqlDbType.VarChar).Value     = model.Last;
                    da.SelectCommand.Parameters.Add("@pUserName", SqlDbType.VarChar).Value = model.UserName;
                    da.SelectCommand.Parameters.Add("@pEmail", SqlDbType.VarChar).Value    = model.Email;
                    da.SelectCommand.Parameters.Add("@pAddress", SqlDbType.VarChar).Value  = model.Address;

                    da.SelectCommand.CommandType = CommandType.StoredProcedure;
                    DataTable dt = new DataTable();
                    da.Fill(dt);
                    return(dt);
                }
                catch (Exception)
                {
                    throw;
                }
            }
Exemplo n.º 3
0
 public DataTable SaveUser(WebPlastic.Models.User model, byte[] password, Byte[] pKEY, Byte[] pIV)
 {
     try
     {
         SqlConnection  con = new SqlConnection(ConfigurationManager.ConnectionStrings["webplasticEntities"].ConnectionString);
         SqlDataAdapter da  = new SqlDataAdapter("SP_SaveUser", con);
         da.SelectCommand.Parameters.Add("@name", SqlDbType.VarChar).Value       = model.Name;
         da.SelectCommand.Parameters.Add("@last", SqlDbType.VarChar).Value       = model.Last;
         da.SelectCommand.Parameters.Add("@email", SqlDbType.VarChar).Value      = model.Email;
         da.SelectCommand.Parameters.Add("@userName", SqlDbType.VarChar).Value   = model.UserName;
         da.SelectCommand.Parameters.Add("@password", SqlDbType.VarBinary).Value = password;
         da.SelectCommand.Parameters.Add("@Key", SqlDbType.VarBinary).Value      = pKEY;
         da.SelectCommand.Parameters.Add("@IV", SqlDbType.VarBinary).Value       = pIV;
         da.SelectCommand.CommandType = CommandType.StoredProcedure;
         DataTable dt = new DataTable();
         da.Fill(dt);
         return(dt);
     }
     catch (Exception)
     {
         throw;
     }
 }