Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection conn = null;
            SqlDataReader dr = null;

            try
            {
                UserRepository ur = new UserRepository();
                conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DataServices"].ConnectionString);
                conn.Open();

                SqlCommand cmd = new SqlCommand("Select * from [dbo].[User]", conn);
                dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    UserData user = new UserData();
                    user.emailAddress = dr.GetString(1);
                    user.lastLogin = dr.GetDateTime(2);
                    user.createdDate = user.lastLogin.AddDays(-10);
                    user.locale = dr.GetString(3);
                    user.firstName = dr.GetString(4);
                    user.lastName = dr.GetString(5);
                    user.timezoneFromUTC = dr.GetInt32(6);
                    user.name = dr.GetString(7);
                    if (dr.GetValue(8) != DBNull.Value)
                        user.gender = dr.GetString(8);
                    if (dr.GetValue(9) != DBNull.Value && dr.GetString(9).Trim().Length > 0)
                        user.location = dr.GetString(9);
                    if (dr.GetValue(10) != DBNull.Value && dr.GetString(10).Trim().Length > 0)
                        user.fBUsername = dr.GetString(10);
                    if (dr.GetValue(11) != DBNull.Value && dr.GetString(11).Trim().Length > 0)
                        user.fBLink = dr.GetString(11);
                    if (dr.GetValue(12) != DBNull.Value && dr.GetString(12).Trim().Length > 0)
                        user.oauthId = dr.GetString(12);

                    user = (UserData)ur.Add(user);
                    string fbstuff = user.fBLink;
                }

            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Пример #2
0
 public UserData Update(UserData user)
 {
     _userRepository.Collection.Save(user);
     return Get(user.emailAddress);
 }
Пример #3
0
 public UserData Add(UserData user)
 {
     _userRepository.Collection.Insert(user);
     return Get(user.emailAddress);
 }