Esempio n. 1
0
        private async Task UpdateGroupsUsers(SqlConnection connection1, string id, GroupsUsersUpdateModel model)
        {
            String commandText1 = "update Usersgroups " +
                                  "set ischecked = @ischecked " +
                                  "where idgroup = @idgroup and iduser = @iduser";

            SqlCommand command1 = new SqlCommand(commandText1, connection1);

            SqlParameter parameter = new SqlParameter("@idgroup", SqlDbType.VarChar);

            parameter.Value = id;
            command1.Parameters.Add(parameter);

            parameter       = new SqlParameter("@iduser", SqlDbType.VarChar);
            parameter.Value = model.iduser;
            command1.Parameters.Add(parameter);

            parameter       = new SqlParameter("@ischecked", SqlDbType.Bit);
            parameter.Value = model.ischecked;
            command1.Parameters.Add(parameter);

            await command1.ExecuteNonQueryAsync();
        }
Esempio n. 2
0
        private async Task SaveGroupsUsers(SqlConnection connection1, string id, GroupsUsersUpdateModel model)
        {
            String commandText1 = "INSERT INTO Usersgroups " +
                                  "(idgroup,iduser,ischecked) " +
                                  "values (@idgroup,@iduser,@ischecked)";

            SqlCommand command1 = new SqlCommand(commandText1, connection1);

            SqlParameter parameter = new SqlParameter("@idgroup", SqlDbType.VarChar);

            parameter.Value = id;
            command1.Parameters.Add(parameter);

            parameter       = new SqlParameter("@iduser", SqlDbType.VarChar);
            parameter.Value = model.iduser;
            command1.Parameters.Add(parameter);

            parameter       = new SqlParameter("@ischecked", SqlDbType.Bit);
            parameter.Value = model.ischecked;
            command1.Parameters.Add(parameter);

            await command1.ExecuteNonQueryAsync();
        }