Esempio n. 1
0
 public ActionResult Unsubscribe(int Id)
 {
     using (SignUpsEntities db = new SignUpsEntities())
     {
         var signup = db.SignUps.Find(Id);
         signup.Removed = DateTime.Now;
         db.SaveChanges();
     }
     return(RedirectToAction("Index"));
 }
Esempio n. 2
0
        public ActionResult SignUp(string firstName, string lastName, string emailAddress)
        {
            if (string.IsNullOrEmpty(firstName) || string.IsNullOrEmpty(lastName) || string.IsNullOrEmpty(emailAddress))
            {
                return(View("~/Views/Shared/Error.cshtml"));
            }
            else
            {
                using (SignUpsEntities db = new SignUpsEntities())
                {
                    var signup = new SignUp();
                    signup.FirstName    = firstName;
                    signup.LastName     = lastName;
                    signup.EmailAddress = emailAddress;

                    db.SignUps.Add(signup);
                    db.SaveChanges();
                }
                //string queryString = @"INSERT INTO SignUps (FirstName, LastName, EmailAddress) VALUES
                //                        (@FirstName, @LastName, @EmailAddress)";

                //using (SqlConnection connection = new SqlConnection(connectionString))
                //{
                //    SqlCommand command = new SqlCommand(queryString, connection);
                //    command.Parameters.Add("@FirstName", SqlDbType.VarChar);
                //    command.Parameters.Add("@LastName", SqlDbType.VarChar);
                //    command.Parameters.Add("@EmailAddress", SqlDbType.VarChar);

                //    command.Parameters["@FirstName"].Value = firstName;
                //    command.Parameters["@LastName"].Value = lastName;
                //    command.Parameters["@EmailAddress"].Value = emailAddress;

                //    connection.Open();
                //    command.ExecuteNonQuery();
                //    connection.Close();
                //}
                return(View("Success"));
            }
        }