public ActionResult Admin()
        {
            string queryString = @"SELECT * FROM SignUps";
            List <NewsletterSignUp> signups = new List <NewsletterSignUp>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    var signup = new NewsletterSignUp();
                    signup.Id                   = Convert.ToInt32(reader["Id"]);
                    signup.FirstName            = reader["FirstName"].ToString();
                    signup.LastName             = reader["LastName"].ToString();
                    signup.EmailAddress         = reader["EmailAddress"].ToString();
                    signup.SocialSecurityNumber = reader["SocialsecurityNumber"].ToString();
                    signups.Add(signup);
                }
            }
            var signupsVM = new List <SignupVM>();

            foreach (var signup in signups)
            {
                var signupVm = new SignupVM();
                signupVm.FirstName    = signup.FirstName;
                signupVm.LastName     = signup.LastName;
                signupVm.EmailAddress = signup.EmailAddress;
                signupsVM.Add(signupVm);
            }
            return(View(signupsVM));
        }
Ejemplo n.º 2
0
        public override global::System.Data.DataSet Clone()
        {
            NewsletterSignUp cln = ((NewsletterSignUp)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
        public async Task <IActionResult> Signup([FromBody] NewsletterSignUp signup)
        {
            if (signup == null || !signup.IsValid())
            {
                return(BadRequest());
            }

            await _svc.Signup(signup);

            return(Ok());
        }
Ejemplo n.º 4
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            NewsletterSignUp ds = new NewsletterSignUp();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
Ejemplo n.º 5
0
        // GET: Admin
        public ActionResult Index()
        {
            //using (NewsletterEntities db = new NewsletterEntities())
            //{

            //    var signups = db.SignUps.Where(x => x.Removed == null).ToList();
            //    //var signups = (from c in db.SignUps
            //    //               where c.Removed == null
            //    //               select c).ToList();
            //    var signupVms = new List<SignUpVm>();
            //    foreach (var signup in signups)
            //    {
            //        var signupVm = new SignUpVm();
            //        signupVm.Id = signup.Id;
            //        signupVm.FirstName = signup.FirstName;
            //        signupVm.LastName = signup.LastName;
            //        signupVm.EmailAddress = signup.EmailAddress;
            //        signupVms.Add(signupVm);
            //    }
            //    return View(signupVms);


            string queryString = @"SELECT Id, FirstName, LastName, EmailAddress, SocialSecurityNumber from SignUps";
            List <NewsletterSignUp> signups = new List <NewsletterSignUp>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);

                connection.Open();
                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var signup = new NewsletterSignUp();
                    signup.Id                   = Convert.ToInt32(reader["Id"]);
                    signup.FirstName            = reader["FirstName"].ToString();
                    signup.LastName             = reader["LastName"].ToString();
                    signup.EmailAddress         = reader["EmailAddress"].ToString();
                    signup.SocialSecurityNumber = reader["SocialSecurityNumber"].ToString();
                    signups.Add(signup);
                }
                connection.Close();
            }
        }
Ejemplo n.º 6
0
        public ActionResult Admin()
        {
            string queryString = @"SELECT Id, FirstName, LastName, EmailAddress, Removed FROM SignUps";
            List <NewsletterSignUp> signups = new List <NewsletterSignUp>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(queryString, connection);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var signup = new NewsletterSignUp();
                    signup.Id           = Convert.ToInt32(reader["Id"]);
                    signup.FirstName    = reader["FirstName"].ToString();
                    signup.LastName     = reader["LastName"].ToString();
                    signup.EmailAddress = reader["EmailAddress"].ToString();
                    signup.Removed      = reader["Removed"].ToString(); // wwe don't want to return this

                    signups.Add(signup);
                }
            }

            var signupVms = new List <SignupVm>();  // best practice if its obvious what the data type is

            //List<SignupVm> signupVms = new List<SignupVm>();

            foreach (var signup in signups)
            {
                var signupVm = new SignupVm();
                signupVm.FirstName    = signup.FirstName;
                signupVm.LastName     = signup.LastName;
                signupVm.EmailAddress = signup.EmailAddress;
                signupVms.Add(signupVm);
            }

            return(View(signupVms));
        }
Ejemplo n.º 7
0
        public ActionResult Admin()
        {
            string querystring = @"SELECT Id, FirstName, LastName, EmailAddress, SocialSecurityNumber from SignUps"; //select porperties from the signup tables.
            List <NewsletterSignUp> signups = new List <NewsletterSignUp>();                                         //iniitalize as an empty list

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                SqlCommand command = new SqlCommand(querystring, connection);

                connection.Open();

                SqlDataReader reader = command.ExecuteReader();

                while (reader.Read())
                {
                    var signup = new NewsletterSignUp();
                    signup.Id                   = Convert.ToInt32(reader["id"]);  // assigning the properties/ values coming from the database.
                    signup.FirstName            = reader["FirstName"].ToString(); //objects coming from the database are a different datatype and need to be defined
                    signup.LastName             = reader["LastName"].ToString();
                    signup.EmailAddress         = reader["EmailAddress"].ToString();
                    signup.SocialSecurityNumber = reader["SocialSecurityNumber"].ToString();

                    signups.Add(signup); // add this newsletter signup list
                }
            }
            var signupVMs = new List <SignUpVM>();

            foreach (var signup in signups)
            {
                var signupVM = new SignUpVM();
                signupVM.FirstName    = signup.FirstName;
                signupVM.LastName     = signup.LastName;
                signupVM.EmailAddress = signup.EmailAddress;

                signupVMs.Add(signupVM);
            }

            return(View(signupVMs)); //passes this list to the view
        }
Ejemplo n.º 8
0
 public async Task Signup(NewsletterSignUp signup)
 {
     await PostAsync("signup", signup, "/api/v1/signup");
 }