Exemple #1
0
        public void UpdateUser(UserAccount user)
        {
            var queryBuilder = new StringBuilder();

            queryBuilder.Append("UPDATE UserAccount SET ");
            queryBuilder.Append("RegistrationDate = @RegistrationDate, ");
            queryBuilder.Append("LoginDate = @LoginDate, ");
            queryBuilder.Append("Email = @Email, ");
            queryBuilder.Append("NickName = @NickName, ");
            queryBuilder.Append("PasswordSalt = @PasswordSalt, ");
            queryBuilder.Append("PasswordHash = @PasswordHash, ");
            queryBuilder.Append("Hash = @Hash, ");
            queryBuilder.Append("GoogleProfile = @GoogleProfile, ");
            queryBuilder.Append("FacebookProfile = @FacebookProfile, ");
            queryBuilder.Append("TwitterProfile = @TwitterProfile, ");
            queryBuilder.Append("SessionId = @SessionId, ");
            queryBuilder.Append("Session = @Session, ");
            queryBuilder.Append("Culture = @Culture, ");
            queryBuilder.Append("Avatar = @Avatar, ");
            queryBuilder.Append("Description = @Description, ");
            queryBuilder.Append("Provider = @Provider ");
            queryBuilder.Append("WHERE Id = @Id");
            using (var db = new ProfileDbManager(_conn))
            {
                db.SetCommand(queryBuilder.ToString(), db.CreateParameters(user)).
                ExecuteNonQuery();
            }
        }
Exemple #2
0
        public void UpdateUser(DateTime date, string salt, string hash, IRegistrationModel model)
        {
            var entity = new UserAccount();

            entity.Id = model.Id;
            entity.RegistrationDate = date;
            entity.PasswordSalt     = salt;
            entity.PasswordHash     = hash;
            entity.Avatar           = model.Avatar;
            entity.Description      = model.Description;
            entity.Email            = model.Email;
            entity.NickName         = model.NickName;
            var queryBuilder = new StringBuilder();

            queryBuilder.Append("UPDATE UserAccount SET ");
            queryBuilder.Append("RegistrationDate = @RegistrationDate, ");
            queryBuilder.Append("Email = @Email, ");
            queryBuilder.Append("NickName = @NickName, ");
            queryBuilder.Append("PasswordSalt = @PasswordSalt, ");
            queryBuilder.Append("PasswordHash = @PasswordHash, ");
            queryBuilder.Append("Avatar = @Avatar, ");
            queryBuilder.Append("Description = @Description ");
            queryBuilder.Append("WHERE Id = @Id");
            using (var db = new ProfileDbManager(_conn))
            {
                db.SetCommand(queryBuilder.ToString(), db.CreateParameters(entity)).
                ExecuteNonQuery();
            }
        }
Exemple #3
0
        public void Delete(string id)
        {
            var query = string.Format("DELETE FROM UserAccount WHERE Id= '{0}'", id);

            using (var db = new ProfileDbManager(_conn))
            {
                db.SetCommand(query).ExecuteNonQuery();
            }
        }
Exemple #4
0
        public UserAccount GetUserBy(string id)
        {
            UserAccount user;

            using (var context = new ProfileDbManager(_conn))
            {
                user = context.SetCommand(
                    string.Format("SELECT * FROM UserAccount WHERE Id = '{0}'", id)).
                       ExecuteObject <UserAccount>();
            }
            return(user);
        }
Exemple #5
0
        public UserAccount GetUsersBy(string email)
        {
            UserAccount user;

            using (var context = new ProfileDbManager(_conn))
            {
                try
                {
                    user = context.SetCommand(
                        string.Format("SELECT * FROM UserAccount WHERE Email = '{0}' ", email)).
                           ExecuteObject <UserAccount>();
                }catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
            return(user);
        }
Exemple #6
0
        public void UpdateUser(string salt, string hash, UserAccount curUser)
        {
            var entity = new UserAccount();

            entity.Id           = curUser.Id;
            entity.PasswordSalt = salt;
            entity.PasswordHash = hash;
            var queryBuilder = new StringBuilder();

            queryBuilder.Append("UPDATE UserAccount SET ");
            queryBuilder.Append("PasswordSalt = @PasswordSalt, ");
            queryBuilder.Append("PasswordHash = @PasswordHash ");
            queryBuilder.Append("WHERE Id = @Id");
            using (var db = new ProfileDbManager(_conn))
            {
                db.SetCommand(queryBuilder.ToString(), db.CreateParameters(entity)).
                ExecuteNonQuery();
            }
        }
Exemple #7
0
 public void SaveUser(UserAccount user)
 {
     try
     {
         using (var db = new ProfileDbManager(_conn))
         {
             db.SetCommand(@"
             INSERT INTO UserAccount ( 
             Id, RegistrationDate, LoginDate,Email,NickName,
             PasswordSalt,PasswordHash,Hash,GoogleProfile,FacebookProfile,TwitterProfile,SessionId,Session,
             Culture,Avatar,Description,Provider)
             VALUES (@Id, @RegistrationDate, @LoginDate,@Email,@NickName,
             @PasswordSalt,@PasswordHash,@Hash,@GoogleProfile,@FacebookProfile,@TwitterProfile,@SessionId,@Session,
             @Culture,@Avatar,@Description,@Provider)",
                           db.Parameter("@Id", user.Id),
                           db.Parameter("@RegistrationDate", user.RegistrationDate),
                           db.Parameter("@LoginDate", user.LoginDate),
                           db.Parameter("@Email", user.Email),
                           db.Parameter("@NickName", user.NickName),
                           db.Parameter("@PasswordSalt", user.PasswordSalt),
                           db.Parameter("@PasswordHash", user.PasswordHash),
                           db.Parameter("@Hash", user.Hash),
                           db.Parameter("@GoogleProfile", user.GoogleProfile),
                           db.Parameter("@FacebookProfile", user.FacebookProfile),
                           db.Parameter("@TwitterProfile", user.TwitterProfile),
                           db.Parameter("@SessionId", user.SessionId),
                           db.Parameter("@Session", user.Session),
                           db.Parameter("@Avatar", user.Avatar),
                           db.Parameter("@Culture", user.Culture),
                           db.Parameter("@Description", user.Description),
                           db.Parameter("@Provider", user.Provider))
             .ExecuteNonQuery();
         }
     }
     catch (Exception e)
     {
         throw;
     }
 }