Example #1
0
        /// <summary>
        /// Inserts a new row into the Person table with the supplied parameters.
        /// </summary>
        /// <param name="lastName"></param>
        /// <param name="firstName"></param>
        /// <param name="emailAddress">optional</param>
        /// <param name="birthDate">optional</param>
        public Task InsertPerson(string lastName, string firstName, string emailAddress = null, string birthDate = null)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConfigurationManagerHelper.DBConn("Person")))
            {
                List <Person> people = new List <Person>();
                //Todo: figure out the mumbo jumbo about converting a string to a date or just f*****g make the prop a date?
                people.Add(new Person {
                    LastName = lastName, FirstName = firstName, EmailAddress = emailAddress, BirthDate = birthDate
                });

                //the parameters are filled in by the properties in the class if the names match up.
                //returning this instead of awaiting it frees up this singleton to handle other requests.
                return(connection.ExecuteAsync("dbo.PERSON_INSERTPERSON @LastName, @FirstName, @emailAddress, @BirthDate", people));
            }
        }