示例#1
0
 /// <summary>
 /// Creer en base le compte passer en parametre
 /// </summary>
 /// <param name="account"></param>
 /// <returns>Vrai si l'insertion a reussi, faux sinon</returns>
 public static bool Create(BO.Account account)
 {
     try
     {
         SqlConnection cnx    = DAL.SqlConnexion.OpenConnexion();
         int           output = cnx.Execute("ajout_account", new { username = account.Username, password = account.PasswordSHA1 },
                                            commandType: CommandType.StoredProcedure);
         SqlConnexion.CloseConnexion(cnx);
         return(output > 0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#2
0
 /// <summary>
 /// Modifie le compte passé en paramètre
 /// </summary>
 /// <returns></returns>
 public static bool Update(BO.Account account)
 {
     try
     {
         SqlConnection cnx   = DAL.SqlConnexion.OpenConnexion();
         var           query = @"UPDATE Account SET username=@user, password=@pwd WHERE id=@id";
         int           rowNb = cnx.Execute(query, new { id = account.Id, user = account.Username, pwd = account.PasswordSHA1 });
         SqlConnexion.CloseConnexion(cnx);
         return(rowNb > 0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#3
0
 /// <summary>
 /// Selectionne les données en base correspondant au compte passé en paramètre.
 /// </summary>
 /// <param name="account"></param>
 /// <returns>Vrai si reussite, faux sinon</returns>
 public static bool Logout(BO.Account account)
 {
     try
     {
         SqlConnection cnx   = DAL.SqlConnexion.OpenConnexion();
         var           query = @"UPDATE Account SET is_onlie=0 WHERE id = @id";
         int           rowNb = cnx.Execute(query, new { id = account.Id });
         SqlConnexion.CloseConnexion(cnx);
         return(rowNb > 0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#4
0
 /// <summary>
 /// Supprime le compte passé en paramètre
 /// </summary>
 /// <param name="account"></param>
 /// <returns>vrai si reussite, faux sinon</returns>
 public static bool Delete(BO.Account account)
 {
     try
     {
         SqlConnection cnx   = DAL.SqlConnexion.OpenConnexion();
         var           query = @"DELETE FROM Account WHERE id = @id";
         int           rowNb = cnx.Execute(query, new { id = account.Id });
         SqlConnexion.CloseConnexion(cnx);
         return(rowNb > 0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }