protected void Button2_Click(object sender, EventArgs e) { Profiel p = new Profiel(); p.Naam = UserIdTextBox.Text; p.AvatarLokatie = "lokAvatar"; p.Emailadres = "*****@*****.**"; p.MobielNummer = "12345666"; p.Profielschets = "Inhoud van de profieltekst"; Result res = ServiceUtil.getProfielService(Application).save(p); if (!res.Code.Equals(ResultCode.SUCCES)) { testProfielTextBox.Text = res.getMessage(); } else { testProfielTextBox.Text = "Hoera, gelukt!!!!!"; } }
private Profiel findUserWithoutChildren(string userid) { Profiel profiel = new Profiel(); string selQuery = @"select profileid, username, password, profile, email, avatarlocation, mobilenumber, verficationpendingdatetime from profile where username = @USERNAME"; SqlConnection conn = null; //Profiel result = new Profiel(); try { conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = new SqlCommand(selQuery, conn); cmd.Parameters.AddWithValue("@USERNAME", userid); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds); DataTable table = ds.Tables[0]; if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; profiel.Id = (int)row[0]; profiel.Naam = (string)row[1]; profiel.Wachtwoord = (string)row[2]; if (!(row[3] is DBNull)) profiel.Profielschets = (string)row[3]; profiel.Emailadres = (string)row[4]; if (!(row[5] is DBNull)) profiel.AvatarLokatie = (string)row[5]; if (!(row[6] is DBNull)) profiel.MobielNummer = (string)row[6]; if (!(row[7] is DBNull)) profiel.VerificationPendingDate = (DateTime)row[7]; } return profiel; } catch (Exception de) { //return null; throw new DaoException("Eris iets misgegaan met zoeken naar users", de); } finally { conn.Close(); } }
public void update(Profiel profiel) { string updQuery = @"update profile set password = @password, profile = @profile, email = @email, avatarlocation = @avatarlocation, mobilenumber = @mobilenumber, verificationpending = @verificationpending, tempblocked = @tempblocked, permblocked = @permblocked, removed = @removed where profileid = @ID"; SqlConnection conn = null; try { conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = new SqlCommand(updQuery, conn); cmd.Parameters.AddWithValue("@ID", profiel.Id); cmd.Parameters.AddWithValue("@password", profiel.Wachtwoord); cmd.Parameters.AddWithValue("@email", profiel.Emailadres); cmd.Parameters.AddWithValue("@profile", profiel.Profielschets); cmd.Parameters.AddWithValue("@avatarlocation", profiel.AvatarLokatie); cmd.Parameters.AddWithValue("@mobilenumber", profiel.MobielNummer); cmd.Parameters.AddWithValue("@verificationpending", false); cmd.Parameters.AddWithValue("@tempblocked", false); cmd.Parameters.AddWithValue("@permblocked", false); cmd.Parameters.AddWithValue("@removed", false); cmd.ExecuteNonQuery(); } catch (Exception e) { throw new DaoException("Er is iets misgegaan met updaten van het profiel", e); } finally { conn.Close(); } }
public void save(Profiel profiel) { string insQuery = ""; insQuery = @"insert into profile (username, password, profile, email, avatarlocation, mobilenumber, verificationpending, tempblocked, permblocked, removed) values (@username, @password, @profile, @email, @avatarlocation, @mobilenumber, @verificationpending, @tempblocked, @permblocked, @removed);"; SqlConnection conn = null; try { conn = new SqlConnection(connectionString); conn.Open(); SqlCommand cmd = new SqlCommand(insQuery, conn); cmd.Parameters.AddWithValue("@profileid", getNextId()); cmd.Parameters.AddWithValue("@username", profiel.Naam); cmd.Parameters.AddWithValue("@password", "wwpUser"); cmd.Parameters.AddWithValue("@email", profiel.Emailadres); cmd.Parameters.AddWithValue("@profile", profiel.Profielschets); cmd.Parameters.AddWithValue("@avatarlocation", profiel.AvatarLokatie); cmd.Parameters.AddWithValue("@mobilenumber", profiel.MobielNummer); cmd.Parameters.AddWithValue("@verificationpending", false); cmd.Parameters.AddWithValue("@tempblocked", false); cmd.Parameters.AddWithValue("@permblocked", false); cmd.Parameters.AddWithValue("@removed", false); cmd.ExecuteNonQuery(); } catch (Exception e) { throw new DaoException("Er is iets misgegaan met opslaan van het profiel", e); } finally { conn.Close(); } }
public Result blockReacties(string userId, Profiel userIdToBlock, bool blocked) { try { //ophalen van de te bewerken data Profiel user = this.profielDao.find(userId); Profiel blockedUser = this.profielDao.find(userId); if (user == null || blockedUser == null) { return new Result(ResultCode.USERID_NOT_FOUND); } //bijwerken van de domeinobjecten if (blocked) { //gebruiker toevoegen aan de lijst met geblokkeere gebruikers // eerst checken of die bestaat if (!user.GeblokkeerdeGebruikers.Contains(blockedUser)) { user.GeblokkeerdeGebruikers.Add(blockedUser); } } else { if (user.GeblokkeerdeGebruikers.Contains(blockedUser)) { user.GeblokkeerdeGebruikers.Remove(blockedUser); } } //save het resultaat this.profielDao.update(user); return Result.newResultSucces(); } catch (DaoException de) { throw new ServiceException(de.Message, de); } }
public Result update(Profiel profiel) { try { this.profielDao.update(profiel); return Result.newResultSucces(); } catch (DaoException de) { throw new ServiceException(de.Message, de); } }
public Result save(Profiel profiel) { try { if (this.profielDao.findUsers(profiel.Naam).Count > 0) { return new Result(ResultCode.USERID_NOT_UNIQUE); } this.profielDao.save(profiel); SendMail("*****@*****.**", "welkom bij Quaack", "bla bla bla bla"); return Result.newResultSucces(); } catch (DaoException de) { throw new ServiceException(de.Message, de); } }