示例#1
0
        public int addUser(User user)
        {
            SSGetService getService = new SSGetService();

            User numberCheck   = getService.getUserByMobileNumber(user.mobile_number);
            User usernameCheck = getService.getUserByUsername(user.username);

            if (usernameCheck.username == null)
            {
                if (numberCheck.mobile_number == null)
                {
                    using (SqlCommand command = new SqlCommand("INSERT INTO ss_users(bid,name, username, password, mobile_number,picture)VALUES(@bid,@name,@username,@password, @mobile_number,@picture)"))
                    {
                        command.Parameters.AddWithValue("@bid", user.bid);
                        command.Parameters.AddWithValue("@name", user.name);
                        command.Parameters.AddWithValue("@username", user.username);
                        command.Parameters.AddWithValue("@password", user.password);
                        command.Parameters.AddWithValue("@mobile_number", user.mobile_number);
                        if (user.picture != null)
                        {
                            command.Parameters.Add("@picture", SqlDbType.Image, user.picture.Length).Value = user.picture;
                        }


                        int response = service.execute(command);
                        if (response > 0)
                        {
                            this.addLog(new Log()
                            {
                                type        = "Add User",
                                statement   = command.CommandText,
                                description = "Created user " + user.name,
                            });
                        }

                        return(response);
                    }
                }
                else
                {
                    return(-3);
                }
            }
            else
            {
                return(-2);
            }
        }