Merge TestUnitaire To Master #35

Merged
remi.arnal merged 77 commits from TestUnitaire into master 2 years ago

@ -0,0 +1,73 @@
using System;
using System.Runtime.Serialization;
namespace ParionsCuite.Modeles
{
/// <summary>
/// Represents an item of a different type.
/// </summary>
[DataContract]
public class Autre
{
/// <summary>
/// Gets or sets the name of the item.
/// </summary>
[DataMember]
public string Nom { get; set; }
/// <summary>
/// Gets or sets the quantity of the item.
/// </summary>
[DataMember]
public int Quantite { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Autre"/> class with the specified name and quantity.
/// </summary>
/// <param name="nom">The name of the item.</param>
/// <param name="qu">The quantity of the item.</param>
public Autre(string nom, int qu)
{
Nom = nom;
Quantite = qu;
}
/// <summary>
/// Default constructor.
/// </summary>
public Autre()
{
}
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
/// <param name="obj">The object to compare with the current object.</param>
/// <returns>True if the specified object is equal to the current object; otherwise, false.</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as Autre);
}
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"nom : {Nom} \n";
}
/// <summary>
/// Serves as a hash function for a particular type.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
return HashCode.Combine(Nom);
}
}
}

@ -0,0 +1,74 @@
using System;
using System.Runtime.Serialization;
using System.Security.Principal;
namespace ParionsCuite.Modeles
{
/// <summary>
/// Represents a beverage item.
/// </summary>
[DataContract]
public class Boisson
{
/// <summary>
/// Gets or sets the name of the beverage.
/// </summary>
[DataMember]
public string Nom { get; set; }
/// <summary>
/// Gets or sets the quantity of the beverage.
/// </summary>
[DataMember]
public int Quantite { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Boisson"/> class with the specified name and quantity.
/// </summary>
/// <param name="nom">The name of the beverage.</param>
/// <param name="qu">The quantity of the beverage.</param>
public Boisson(string nom, int qu)
{
Nom = nom;
Quantite = qu;
}
/// <summary>
/// Default constructor.
/// </summary>
public Boisson()
{
}
/// <summary>
/// Determines whether the specified object is equal to the current object.
/// </summary>
/// <param name="obj">The object to compare with the current object.</param>
/// <returns>True if the specified object is equal to the current object; otherwise, false.</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as Boisson);
}
/// <summary>
/// Returns a string that represents the current object.
/// </summary>
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"nom : {Nom} \n";
}
/// <summary>
/// Serves as a hash function for a particular type.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
return HashCode.Combine(Nom);
}
}
}

@ -0,0 +1,7 @@
namespace Modeles
{
public class Class1
{
}
}

@ -0,0 +1,264 @@
using ParionsCuite;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
/// <summary>
/// Represents an event.
/// </summary>
[DataContract]
public class Evenement : INotifyPropertyChanged
{
/// <summary>
/// Event that is raised when a property value changes.
/// </summary>
public event PropertyChangedEventHandler? PropertyChanged;
/// <summary>
/// Raises the <see cref="PropertyChanged"/> event for a specific property.
/// </summary>
/// <param name="propertyName">The name of the property that changed.</param>
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/* Properties */
/// <summary>
/// Gets or private sets the name of the event.
/// </summary>
[DataMember]
public string Nom { get; private set; }
/// <summary>
/// Gets or private sets the date of the event.
/// </summary>
[DataMember]
public string Date { get; private set; }
/// <summary>
/// Gets or private sets the location of the event.
/// </summary>
[DataMember]
public string Lieu { get; private set; }
/// <summary>
/// Gets or private sets the time of the event.
/// </summary>
[DataMember]
public string Heure { get; private set; }
/// <summary>
/// Gets the participation information for the event.
/// </summary>
[DataMember]
public Participation Participation { get; private set; }
/// <summary>
/// Gets the list of invited guests for the event.
/// </summary>
[DataMember]
public List<Inviter> ListInviter { get; private set; }
/// <summary>
/// Event that is raised when a bet is added to the event.
/// </summary>
public event Action<Parier> PariAdd;
/// <summary>
/// Gets or private sets the list of bets for the event.
/// </summary>
[DataMember]
private ObservableCollection<Parier> listParier;
/// <summary>
/// Gets or sets the list of bets for the event.
/// </summary>
public ObservableCollection<Parier> ListParier
{
get { return listParier; }
set
{
if (listParier != value)
{
listParier = value;
OnPropertyChanged();
OnPariAdded(value.LastOrDefault());
}
}
}
/* Methods */
private void OnPariAdded(Parier parier)
{
// Logic to execute when a bet is added
Debug.WriteLine("Bet added: ");
}
/// <summary>
/// Adds a bet to the event.
/// </summary>
/// <param name="pari">The bet to add.</param>
/// <returns>True if the bet was added successfully; otherwise, false.</returns>
public bool Ajout_Pari(Parier pari)
{
ListParier.Add(pari);
OnPropertyChanged(nameof(Parier));
PariAdd?.Invoke(pari);
return true;
}
/// <summary>
/// Initializes a new instance of the <see cref="Evenement"/> class with the specified name, date, location, and time.
/// </summary>
/// <param name="nom">The name of the event.</param>
/// <param name="date">The date of the event.</param>
/// <param name="lieu">The location of the event.</param>
/// <param name="heure">The time of the event.</param>
public Evenement(string nom, string date, string lieu, string heure)
{
Nom = nom;
Date = date;
Lieu = lieu;
Heure = heure;
ListInviter = new List<Inviter>();
ListParier = new ObservableCollection<Parier>();
Participation = new Participation();
}
/// <summary>
/// Initializes a new instance of the <see cref="Evenement"/> class with the specified name, date, location, time, and participation information.
/// </summary>
/// <param name="nom">The name of the event.</param>
/// <param name="date">The date of the event.</param>
/// <param name="lieu">The location of the event.</param>
/// <param name="heure">The time of the event.</param>
/// <param name="participation">The participation information for the event.</param>
public Evenement(string nom, string date, string lieu, string heure, Participation participation)
{
Nom = nom;
Date = date;
Lieu = lieu;
Heure = heure;
Participation = participation;
ListInviter = new List<Inviter>();
ListParier = new ObservableCollection<Parier>();
}
/* Inviter methods */
/// <summary>
/// Adds a guest to the event's list of invited guests.
/// </summary>
/// <param name="I">The guest to add.</param>
/// <returns>True if the guest was added successfully; otherwise, false.</returns>
public bool Ajouter_inviter(Inviter I)
{
ListInviter.Add(I);
foreach (Inviter i in ListInviter)
{
if (i == I)
return true;
}
return false;
}
/// <summary>
/// Removes a guest from the event's list of invited guests.
/// </summary>
/// <param name="inviter">The guest to remove.</param>
/// <returns>True if the guest was removed successfully; otherwise, false.</returns>
public bool Supprimer_inviter(Inviter inviter)
{
return ListInviter.Remove(inviter);
}
/// <summary>
/// Returns the number of invited guests in the event's list.
/// </summary>
/// <param name="list">The list of invited guests.</param>
/// <returns>The number of invited guests.</returns>
public int LenListInvite(List<Inviter> list)
{
int len = 0;
foreach (Inviter inviter in list)
{
len++;
}
return len;
}
/// <summary>
/// Returns the list of invited guests for the event.
/// </summary>
/// <returns>The list of invited guests.</returns>
public List<Inviter> ReturnListInvite()
{
return ListInviter;
}
/* Parie methods */
/// <summary>
/// Adds a bet to the event's list of bets.
/// </summary>
/// <param name="parier">The bet to add.</param>
/// <returns>True if the bet was added successfully; otherwise, false.</returns>
public bool Ajouter_parie(Parier parier)
{
ListParier.Add(parier);
foreach (Parier p in ListParier)
{
if (p == parier)
return true;
}
return false;
}
/// <summary>
/// Removes a bet from the event's list of bets.
/// </summary>
/// <param name="p">The bet to remove.</param>
/// <returns>True if the bet was removed successfully; otherwise, false.</returns>
public bool Supprimer_parie(Parier p)
{
return ListParier.Remove(p);
}
/* Setter */
/// <summary>
/// Sets the event's information.
/// </summary>
/// <param name="nom">The name of the event.</param>
/// <param name="date">The date of the event.</param>
/// <param name="lieu">The location of the event.</param>
/// <param name="heure">The time of the event.</param>
public void SetEvenement(string nom, string date, string lieu, string heure)
{
Nom = nom;
Date = date;
Lieu = lieu;
Heure = heure;
return;
}
/// <summary>
/// Returns a string representation of the event.
/// </summary>
/// <returns>A string representation of the event.</returns>
public override string ToString()
{
return $"Nom : {Nom} \nDate : {Date}\nLieu : {Lieu}\nHeure : {Heure} ";
}
}
}

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.ObjectModel;
namespace ParionsCuite.Modeles
{
/// <summary>
/// Defines the interface for a persistence manager.
/// </summary>
public interface IPersistanceManager
{
/// <summary>
/// Loads the data and returns a collection of events.
/// </summary>
/// <returns>An <see cref="ObservableCollection{T}"/> of <see cref="Evenement"/>.</returns>
ObservableCollection<Evenement> chargeDonnees();
/// <summary>
/// Saves the data by taking a collection of events as input.
/// </summary>
/// <param name="evenements">The collection of events to be saved.</param>
void sauvegardeDonnees(ObservableCollection<Evenement> evenements);
}
}

@ -0,0 +1,61 @@
using System;
using System.Runtime.Serialization;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Inviter
{
/// <summary>
/// Gets or sets the last name of the guest.
/// </summary>
[DataMember]
public string Nom { get; set; }
/// <summary>
/// Gets or sets the first name of the guest.
/// </summary>
[DataMember]
public string Prenom { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Inviter"/> class with the specified last name and first name.
/// </summary>
/// <param name="nom">The last name of the guest.</param>
/// <param name="prenom">The first name of the guest.</param>
public Inviter(string nom, string prenom)
{
Nom = nom;
Prenom = prenom;
}
/// <summary>
/// Initializes a new instance of the <see cref="Inviter"/> class with the specified first name.
/// </summary>
/// <param name="prenom">The first name of the guest.</param>
public Inviter(string prenom)
{
Prenom = prenom;
}
/// <summary>
/// Initializes a new instance of the <see cref="Inviter"/> class.
/// </summary>
public Inviter()
{
}
/// <summary>
/// Returns a string representation of the guest.
/// </summary>
/// <returns>A string representation of the guest.</returns>
public override string ToString()
{
return $"nom : {Nom}, prenom : {Prenom} \n";
}
}
}

@ -0,0 +1,246 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
/**
* @brief Manageur Class
*
* This class represents a manager that implements the INotifyPropertyChanged interface.
* It manages a collection of events and provides events and properties for data management.
*/
public class Manageur : INotifyPropertyChanged
{
/**
* @brief Event triggered when a property changes.
*
* This event is triggered when the value of a property in the Manageur object changes.
*/
public event PropertyChangedEventHandler PropertyChanged;
/**
* @brief Event triggered when an event is added.
*
* This event is triggered when a new event is added to the event collection.
*/
public event Action<Evenement> EvenementAdded;
private ObservableCollection<Evenement> evenement;
/**
* @brief Gets or sets the value of the Value1 property.
*/
public bool Value1;
/**
* @brief Gets or sets the value of the Value2 property.
*/
public bool Value2;
/**
* @brief Gets or sets the value of the Value3 property.
*/
public bool Value3;
/**
* @brief Raises the PropertyChanged event.
*
* This method is used to raise the PropertyChanged event when a property changes.
*
* @param propertyName (optional) The name of the property that has changed. If not specified, the name of the calling property will be used.
*/
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/**
* @brief Gets or sets the event collection.
*/
public ObservableCollection<Evenement> Evenement
{
get { return evenement; }
set
{
if (evenement != value)
{
evenement = value;
OnPropertyChanged();
OnEvenementAdded(value.LastOrDefault()); // Call the function after adding an event
}
}
}
/**
* @brief Performs logic when an event is added.
*
* This method is called when an event is added to the event collection.
*
* @param evenement The event that was added.
*/
private void OnEvenementAdded(Evenement evenement)
{
// Logic to execute when an event is added
Debug.WriteLine("Event added: ");
}
/**
* @brief Gets or sets the list of invitees.
*/
public List<Inviter> Invites { get; set; }
/**
* @brief Gets or sets the persistence manager.
*/
public IPersistanceManager Persistance { get; set; }
/**
* @brief Manageur Constructor
*
* Initializes a new instance of the Manageur class with the specified persistence manager.
*
* @param Pers The persistence manager to be used.
*/
public Manageur(IPersistanceManager Pers)
{
Invites = new List<Inviter>();
Evenement = new ObservableCollection<Evenement>();
Persistance = Pers;
}
/**
* @brief Manageur Constructor
*
* Initializes a new instance of the Manageur class with default values.
*/
public Manageur()
{
Evenement = new ObservableCollection<Evenement>();
Invites = new List<Inviter>();
}
/**
* @brief Manageur Constructor
*
* Initializes a new instance of the Manageur class with the specified event collection.
*
* @param evenements The event collection to be used.
*/
public Manageur(ObservableCollection<Evenement> evenements)
{
Evenement = evenements;
}
/**
* @brief Adds an event to the event collection.
*
* This method adds the specified event to the event collection, triggers the PropertyChanged event,
* and invokes the EvenementAdded event.
*
* @param ev The event to be added.
* @return Returns true indicating the event was added successfully.
*/
public bool Ajout_evenement(Evenement ev)
{
Evenement.Add(ev);
OnPropertyChanged(nameof(Evenement));
EvenementAdded?.Invoke(ev);
return true;
}
/**
* @brief Removes an event from the event collection.
*
* This method removes the specified event from the event collection.
*
* @param ev The event to be removed.
* @return Returns true if the event was successfully removed; otherwise, false.
*/
public bool Supprimer_evenement(Evenement ev)
{
return Evenement.Remove(ev);
}
/**
* @brief Adds an invitee to the invitees list.
*
* This method adds the specified invitee to the list of invitees.
*
* @param invite1 The invitee to be added.
* @return Returns the updated list of invitees.
*/
public List<Inviter> AddInvite(Inviter invite1)
{
Invites.Add(invite1);
return Invites;
}
/**
* @brief Removes an invitee from the invitees list.
*
* This method removes the specified invitee from the list of invitees.
*
* @param invite1 The invitee to be removed.
* @return Returns the updated list of invitees.
*/
public List<Inviter> RemoveInviter(Inviter invite1)
{
Invites.Remove(invite1);
return Invites;
}
/**
* @brief Returns the length of a list of invitees.
*
* This method calculates and returns the length of the specified list of invitees.
*
* @param list The list of invitees.
* @return Returns the length of the list of invitees.
*/
public int LenListInvite(List<Inviter> list)
{
int len = 0;
foreach (Inviter inviter in list)
{
len++;
}
return len;
}
/**
* @brief Loads data using the persistence manager.
*
* This method loads data using the configured persistence manager.
* It retrieves data from the persistence layer and adds it to the event collection.
*
* @return Returns the loaded data as an ObservableCollection of Evenement.
*/
public ObservableCollection<Evenement> Charge_Donnee()
{
var donnees = Persistance.chargeDonnees();
foreach (var donnee in donnees)
{
Evenement.Add(donnee);
}
return donnees;
}
/**
* @brief Saves data using the persistence manager.
*
* This method saves the event collection using the configured persistence manager.
* It persists the current state of the event collection to the underlying storage.
*/
public void Save_Data()
{
Persistance.sauvegardeDonnees(Evenement);
}
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Class1.cs" />
</ItemGroup>
</Project>

@ -0,0 +1,71 @@
using System;
using System.Runtime.Serialization;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Nourriture
{
/// <summary>
/// Gets or sets the name of the food.
/// </summary>
[DataMember]
public string Nom { get; set; }
/// <summary>
/// Gets or sets the quantity of the food.
/// </summary>
[DataMember]
public int Quantite { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="Nourriture"/> class.
/// </summary>
/// <param name="nom">The name of the food.</param>
/// <param name="qu">The quantity of the food.</param>
public Nourriture(string nom, int qu)
{
Nom = nom;
Quantite = qu;
}
/// <summary>
/// Initializes a new instance of the <see cref="Nourriture"/> class.
/// </summary>
public Nourriture()
{
}
/// <summary>
/// Determines whether the current <see cref="Nourriture"/> object is equal to another object.
/// </summary>
/// <param name="obj">The object to compare with the current object.</param>
/// <returns><c>true</c> if the objects are equal; otherwise, <c>false</c>.</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as Nourriture);
}
/// <summary>
/// Returns a string that represents the current <see cref="Nourriture"/> object.
/// </summary>
/// <returns>A string representation of the object.</returns>
public override string ToString()
{
return $"nom : {Nom} \n";
}
/// <summary>
/// Serves as a hash function for a <see cref="Nourriture"/> object.
/// </summary>
/// <returns>A hash code for the current object.</returns>
public override int GetHashCode()
{
return HashCode.Combine(Nom);
}
}
}

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Parier
{
/// <summary>
/// Gets or sets the first player involved in the bet.
/// </summary>
[DataMember]
public Inviter i1 { get; set; }
/// <summary>
/// Gets or sets the second player involved in the bet.
/// </summary>
[DataMember]
public Inviter i2 { get; set; }
/// <summary>
/// Gets or sets the goal of the bet.
/// </summary>
[DataMember]
public string But { get; private set; }
/// <summary>
/// Gets or sets the stake of the bet.
/// </summary>
[DataMember]
public string Enjeu { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="Parier"/> class.
/// </summary>
/// <param name="i1">The first player involved in the bet.</param>
/// <param name="i2">The second player involved in the bet.</param>
/// <param name="but">The goal of the bet.</param>
/// <param name="enjeu">The stake of the bet.</param>
public Parier(Inviter i1, Inviter i2, string but, string enjeu)
{
this.i1 = i1;
this.i2 = i2;
But = but;
Enjeu = enjeu;
}
/// <summary>
/// Returns a string that represents the current <see cref="Parier"/> object.
/// </summary>
/// <returns>A string representation of the object.</returns>
public override string ToString()
{
return $"joueur n°1 : {i1.Prenom}, \njoueur n°2 : {i2.Prenom}, \nbut : {But}, enjeux : {Enjeu}";
}
}
}

@ -0,0 +1,211 @@
using Microsoft;
using ParionsCuite;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Participation
{
[DataMember]
public List<Boisson> Boissons { get; private set; }
[DataMember]
public List<Nourriture> Nourriture { get; private set; }
[DataMember]
public List<Autre> Autre { get; private set; }
/// <summary>
/// Initializes a new instance of the <see cref="Participation"/> class.
/// </summary>
public Participation()
{
Boissons = new List<Boisson>();
Nourriture = new List<Nourriture>();
Autre = new List<Autre>();
}
/// <summary>
/// Initializes a new instance of the <see cref="Participation"/> class.
/// </summary>
/// <param name="boisson">The list of drinks.</param>
/// <param name="nourriture">The list of food.</param>
/// <param name="autre">The list of other items.</param>
public Participation(List<Boisson> boisson, List<Nourriture> nourriture, List<Autre> autre)
{
Boissons = boisson;
Nourriture = nourriture;
Autre = autre;
}
/* Boisson */
/// <summary>
/// Adds a drink to the participation.
/// </summary>
/// <param name="boisson">The drink to add.</param>
/// <returns><c>true</c> if the drink was added successfully; otherwise, <c>false</c>.</returns>
public bool Ajout_Boissons(Boisson boisson)
{
foreach (var obj in Boissons)
{
if (obj.Equals(boisson))
{
if (boisson.Quantite > 0)
{
obj.Quantite += boisson.Quantite;
return true;
}
return false;
}
}
Boissons.Add(boisson);
return true;
}
/// <summary>
/// Removes a specified quantity of a drink from the participation.
/// </summary>
/// <param name="boisson">The drink to remove.</param>
/// <param name="quantite">The quantity to remove.</param>
/// <returns><c>true</c> if the drink was removed successfully; otherwise, <c>false</c>.</returns>
public bool Sup_Boissons(Boisson boisson, int quantite)
{
foreach (var obj in Boissons)
{
if (obj.Equals(boisson))
{
if (quantite > 0)
{
if (quantite >= boisson.Quantite)
{
Boissons.Remove(boisson);
return true;
}
obj.Quantite -= quantite;
return true;
}
return false;
}
}
return false;
}
/* Nourriture */
/// <summary>
/// Adds a food item to the participation.
/// </summary>
/// <param name="food">The food item to add.</param>
/// <returns><c>true</c> if the food item was added successfully; otherwise, <c>false</c>.</returns>
public bool Ajout_Nourriture(Nourriture food)
{
foreach (var obj in Nourriture)
{
if (obj.Equals(food))
{
if (food.Quantite > 0)
{
obj.Quantite += food.Quantite;
return true;
}
return false;
}
}
Nourriture.Add(food);
return true;
}
/// <summary>
/// Removes a specified quantity of a food item from the participation.
/// </summary>
/// <param name="food">The food item to remove.</param>
/// <param name="quantite">The quantity to remove.</param>
/// <returns><c>true</c> if the food item was removed successfully; otherwise, <c>false</c>.</returns>
public bool Sup_Nourriture(Nourriture food, int quantite)
{
foreach (var obj in Nourriture)
{
if (obj.Equals(food))
{
if (quantite > 0)
{
if (quantite >= food.Quantite)
{
Nourriture.Remove(food);
return true;
}
obj.Quantite -= quantite;
return true;
}
return false;
}
}
return false;
}
/* Autre */
/// <summary>
/// Adds another item to the participation.
/// </summary>
/// <param name="autre">The other item to add.</param>
/// <returns><c>true</c> if the other item was added successfully; otherwise, <c>false</c>.</returns>
public bool Ajout_Autre(Autre autre)
{
foreach (var obj in Autre)
{
if (obj.Equals(autre))
{
if (autre.Quantite > 0)
{
obj.Quantite += autre.Quantite;
return true;
}
return false;
}
}
Autre.Add(autre);
return true;
}
/// <summary>
/// Removes a specified quantity of another item from the participation.
/// </summary>
/// <param name="autre">The other item to remove.</param>
/// <param name="quantite">The quantity to remove.</param>
/// <returns><c>true</c> if the other item was removed successfully; otherwise, <c>false</c>.</returns>
public bool Sup_Autre(Autre autre, int quantite)
{
foreach (var obj in Autre)
{
if (obj.Equals(autre))
{
if (quantite > 0)
{
if (quantite >= autre.Quantite)
{
Autre.Remove(autre);
return true;
}
obj.Quantite -= quantite;
return true;
}
return false;
}
}
return false;
}
}
}

@ -5,6 +5,10 @@ VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ParionsCuite", "ParionsCuite\ParionsCuite.csproj", "{695ECD3A-15DB-4B29-BC9D-E8CC87D92900}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modeles", "Modeles\Modeles.csproj", "{F96C29D3-33A7-4230-A1C7-799114865D52}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestParionsCuite", "TestParionsCuite\TestParionsCuite.csproj", "{0978D34C-3D5E-4863-B40C-55A38C6A2BBE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -17,6 +21,14 @@ Global
{695ECD3A-15DB-4B29-BC9D-E8CC87D92900}.Release|Any CPU.ActiveCfg = Release|Any CPU
{695ECD3A-15DB-4B29-BC9D-E8CC87D92900}.Release|Any CPU.Build.0 = Release|Any CPU
{695ECD3A-15DB-4B29-BC9D-E8CC87D92900}.Release|Any CPU.Deploy.0 = Release|Any CPU
{F96C29D3-33A7-4230-A1C7-799114865D52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F96C29D3-33A7-4230-A1C7-799114865D52}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F96C29D3-33A7-4230-A1C7-799114865D52}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F96C29D3-33A7-4230-A1C7-799114865D52}.Release|Any CPU.Build.0 = Release|Any CPU
{0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0978D34C-3D5E-4863-B40C-55A38C6A2BBE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -1,11 +1,55 @@
namespace ParionsCuite;
using ParionsCuite.Modeles;
using ParionsCuite.DataContractPersistance;
namespace ParionsCuite;
/**
* @brief Represents the application instance and its entry point.
*
* The `App` class initializes the application environment, sets up the data persistence, and manages the `Manageur` instance.
*/
public partial class App : Application
{
public App()
{
InitializeComponent();
/**
* @brief Gets or sets the file name for data persistence.
*/
public string FileName { get; set; } = "A_Save_Data.xml";
MainPage = new AppShell();
}
/**
* @brief Gets or sets the file path for data persistence.
*/
public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
/**
* @brief Gets the instance of the `Manageur` class used in the application.
*/
public Manageur MyManager { get; private set; } = new Manageur(new Stub.Stub());
/**
* @brief Initializes a new instance of the `App` class.
*/
public App()
{
InitializeComponent();
// Check if the data file exists
if (File.Exists(Path.Combine(FilePath, FileName)))
{
MyManager = new Manageur(new DataContractPersistance.DataContractPersistance());
}
// Load data into the Manageur instance
MyManager.Charge_Donnee();
MainPage = new AppShell();
// Save data
// If the data file doesn't exist, set the persistence to DataContractPersistance
if (!File.Exists(Path.Combine(FilePath, FileName)))
{
MyManager.Persistance = new DataContractPersistance.DataContractPersistance();
}
MyManager.Save_Data();
}
}

@ -5,18 +5,21 @@
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:ParionsCuite"
xmlns:views="clr-namespace:ParionsCuite.Views"
xmlns:participation="clr-namespace:ParionsCuite.Views.Participation"
xmlns:participation="clr-namespace:ParionsCuite.Views.Participations"
xmlns:invite="clr-namespace:ParionsCuite.Views.Invite"
xmlns:pari="clr-namespace:ParionsCuite.Views.Pari"
xmlns:info="clr-namespace:ParionsCuite"
xmlns:info="clr-namespace:ParionsCuite.Views.Information"
Shell.FlyoutBehavior="Disabled">
<TabBar>
<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
<Tab>
<ShellContent
Title="Invité"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />
</Tab>
</TabBar>
</Shell>

@ -1,9 +1,11 @@
namespace ParionsCuite;
using Microsoft.Maui.Controls;
using System;
namespace ParionsCuite;
public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
InitializeComponent();
}
}

@ -0,0 +1,82 @@
using System;
using System.Xml;
using System.Runtime.Serialization;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using ParionsCuite.Modeles;
using System.Collections.ObjectModel;
namespace ParionsCuite.DataContractPersistance
{/**
* @brief Provides data persistence using the DataContractSerializer.
*
* The `DataContractPersistance` class implements the `IPersistanceManager` interface and provides methods for saving and loading data using the `DataContractSerializer`.
*/
public class DataContractPersistance : Modeles.IPersistanceManager
{
/**
* @brief Gets the name of the data file.
*/
public string FileName { get; private set; } = "A_Save_Data.xml";
/**
* @brief Gets the path to the data file.
*/
public string FilePath { get; private set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
/**
* @brief Initializes a new instance of the `DataContractPersistance` class.
*/
public DataContractPersistance() { }
/**
* @brief Loads the data from the data file.
*
* This method reads the data from the data file using the `DataContractSerializer` and returns the deserialized data as an `ObservableCollection<Evenement>`.
*
* @return The loaded data as an `ObservableCollection<Evenement>`.
*/
public ObservableCollection<Evenement> chargeDonnees()
{
var serializer = new DataContractSerializer(typeof(ObservableCollection<Evenement>));
ObservableCollection<Evenement> list;
using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName)))
{
list = serializer.ReadObject(s) as ObservableCollection<Evenement>;
}
return list;
}
/**
* @brief Saves the data to the data file.
*
* This method serializes the given `ObservableCollection<Evenement>` using the `DataContractSerializer` and saves it to the data file.
*
* @param evenements The data to be saved as an `ObservableCollection<Evenement>`.
*/
public void sauvegardeDonnees(ObservableCollection<Evenement> evenements)
{
var serializer = new DataContractSerializer(typeof(ObservableCollection<Evenement>));
if (!Directory.Exists(FilePath))
{
Debug.WriteLine("Sauvegarde des données dans:");
Debug.WriteLine(Directory.GetDirectoryRoot(FileName));
Debug.WriteLine(FilePath + "\n");
Directory.CreateDirectory(FilePath);
}
var settings = new XmlWriterSettings() { Indent = true };
using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName)))
{
using (XmlWriter writer = XmlWriter.Create(tw, settings))
{
serializer.WriteObject(writer, evenements);
}
}
}
}
}

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ParionsCuite.Modeles;
namespace ParionsCuite.DataContractPersistance
{
/**
* @brief DataToPersists Class
*
* Represents the data to be persisted.
*/
public class DataToPersists
{
/**
* @brief Gets or sets the collection of events to persist.
*/
public ObservableCollection<Evenement> e { get; set; } = new ObservableCollection<Evenement>();
}
}

@ -11,76 +11,43 @@
xmlns:boisson="clr-namespace:ParionsCuite.Views.Participations.Boisson"
xmlns:nourriture="clr-namespace:ParionsCuite.Views.Participations"
xmlns:autre="clr-namespace:ParionsCuite.Views.Participations.Autre"
Title="ParionsCuite">
>
<VerticalStackLayout>
<Grid ColumnDefinitions="1*,10*">
<!-- Séparation de la page -->
<ScrollView>
<Grid>
<!-- Séparation de la page -->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*" />
<ColumnDefinition Width="10*" />
</Grid.ColumnDefinitions>
<!-- Première colonne -->
<ScrollView >
<StackLayout x:Name="ButtonStackLayout" BindingContext="{Binding mgr.Evenement}">
<Button Text="+" BackgroundColor="Green" Grid.Column="0" HeightRequest="50" Clicked="Button_Clicked"/>
</StackLayout>
</ScrollView>
<!-- Première colonne -->
<Grid Grid.Column="0" BackgroundColor="LightGray">
<StackLayout>
<Button Text="Groupe 1"
VerticalOptions="Center"
HorizontalOptions="Center"/>
<!-- Deuxième colonne -->
<Grid Grid.Column="1" RowDefinitions="1*,8*">
<Button Text="+"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</StackLayout>
<!-- 1er ligne -->
<!--Grid menu-->
<Grid Grid.Row="0" Margin="20" ColumnDefinitions="*,*,*,*" MinimumHeightRequest="30" MaximumHeightRequest="50">
<Button Text="Invité" Clicked="InviteView" />
<Button Text="Participant" Grid.Column="1" Clicked="ParticipantView"/>
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey" Clicked="PariView"/>
<Button Text="Information" Grid.Column="3" Clicked="InfoView" />
</Grid>
<!-- Deuxième colonne -->
<Grid Grid.Column="1">
<!-- Création de 2 lignes -->
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="8*"/>
</Grid.RowDefinitions>
<!-- 1er ligne -->
<Grid Grid.Row="0">
<HorizontalStackLayout>
<Button Text="Invité"
VerticalOptions="Center"
HorizontalOptions="Center"/>
<Button Text="Participation"
VerticalOptions="Center"
HorizontalOptions="Center"/>
<!-- 2e ligne -->
<Grid Grid.Row="1" >
<ContentView x:Name="changeButton">
<views:Accueil/>
</ContentView>
</Grid>
</Grid>
<Button Text="Parie"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</Grid>
<Button Text="Information"
VerticalOptions="Center"
HorizontalOptions="Center"/>
</HorizontalStackLayout>
</Grid>
<!-- 2e ligne -->
<Grid Grid.Row="1">
<ContentView>
<ajout:Ajouts_Pari/>
</ContentView>
</Grid>
</Grid>
</Grid>
</ScrollView>
</VerticalStackLayout>
</ContentPage>

@ -1,12 +1,181 @@
namespace ParionsCuite;
using System;
using System.Collections.ObjectModel;
using System.Diagnostics;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Platform;
using Microsoft.VisualBasic;
using ParionsCuite.Modeles;
using ParionsCuite.Views.Information;
using ParionsCuite.Views.Invite;
using ParionsCuite.Views.Participations.Autre;
namespace ParionsCuite;
/**
* @brief Represents the main page of the application.
*
* The `MainPage` class is responsible for displaying a list of events and handling event selection. It also provides methods for restoring events from data and adding new events.
*/
public partial class MainPage : ContentPage
{
int count = 0;
/**
* @brief Gets the instance of the `Manageur` class from the application.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Gets or sets the selected event.
*/
Evenement EventSelect { get; set; }
public MainPage()
{
/**
* @brief Initializes a new instance of the `MainPage` class.
*/
public MainPage()
{
InitializeComponent();
}
this.BindingContext = this;
mgr.EvenementAdded += OnEvenementAdded;
ObservableCollection<Evenement> EventCharge = mgr.Charge_Donnee();
restoreEvent(EventCharge);
}
/**
* @brief Restores the events from the given collection.
*
* This method is responsible for restoring events from the given collection and adding buttons to the UI for each event. It also sets the `mgr.Evenement` property to the restored events.
*
* @param EventCharge The collection of events to be restored.
*/
private void restoreEvent(ObservableCollection<Evenement> EventCharge)
{
foreach (Evenement ev in EventCharge)
{
Debug.WriteLine("Événement ajoutéz : " + ev.Nom);
Button newButton = new Button
{
Text = ev.Nom,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
};
newButton.Clicked += (sender, e) =>
{
// Call the method that handles event selection
SelectEvent(ev);
var newPage = new Views.Accueil();
changeButton.Content = newPage;
};
// Add the button to the ButtonStackLayout
ButtonStackLayout.Children.Add(newButton); ;
}
mgr.Evenement = EventCharge;
}
/**
* @brief Event handler for the `EvenementAdded` event.
*
* This method is called when a new event is added. It adds a button for the new event to the UI and sets the `mgr.Evenement` property accordingly.
*
* @param evenement The newly added event.
*/
private void OnEvenementAdded(Evenement evenement)
{
Button newButton = new Button
{
Text = evenement.Nom,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
};
newButton.Clicked += (sender, e) =>
{
// Call the method that handles event selection
SelectEvent(evenement);
var newPage = new Views.Accueil();
changeButton.Content = newPage;
};
// Add the button to the ButtonStackLayout
ButtonStackLayout.Children.Add(newButton); ;
Debug.WriteLine(mgr.Evenement);
mgr.Save_Data();
}
/**
* @brief Selects the specified event.
*
* This method is called when an event is selected. It sets the `EventSelect` property to the specified event.
*
* @param evenement The selected event.
*/
public void SelectEvent(Evenement evenement)
{
Debug.WriteLine("Événement cliqué : " + evenement.Nom);
Debug.WriteLine("Date : " + evenement.Date);
Debug.WriteLine("Lieu : " + evenement.Lieu);
Debug.WriteLine("Heure : " + evenement.Heure);
EventSelect = evenement;
}
/**
* @brief Navigates to the Groupe view.
*
* This method is called when the Groupe button is clicked. It creates a new instance of the Groupe view and sets it as the content of the changeButton element.
*/
public void Button_Clicked(object sender, EventArgs e)
{
var newPage = new Views.Groupe();
changeButton.Content = newPage;
}
/**
* @brief Navigates to the Invite view.
*
* This method is called when the Invite button is clicked. It creates a new instance of the Invite view, passing the selected event as a parameter, and sets it as the content of the changeButton element.
*/
private void InviteView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Invite.Inviter(EventSelect);
changeButton.Content = newPage;
}
/**
* @brief Navigates to the Participant view.
*
* This method is called when the Participant button is clicked. It creates a new instance of the Participant view, passing the selected event as a parameter, and sets it as the content of the changeButton element.
*/
private void ParticipantView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.Nourriture(EventSelect);
changeButton.Content = newPage;
}
/**
* @brief Navigates to the Pari view.
*
* This method is called when the Pari button is clicked. It creates a new instance of the Pari view, passing the selected event as a parameter, and sets it as the content of the changeButton element.
*/
private void PariView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Pari.Parier(EventSelect);
changeButton.Content = newPage;
}
/**
* @brief Navigates to the Information view.
*
* This method is called when the Info button is clicked. It creates a new instance of the Information view, passing the selected event as a parameter, and sets it as the content of the changeButton element.
*/
private void InfoView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Information.Info(EventSelect);
changeButton.Content = newPage;
}
}

@ -1,21 +1,44 @@
using System;
using System.Runtime.Serialization;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Autre
{
public string Nom { get; set; }
public decimal Quantite { get; set; }
[DataMember]
public string Nom { get; set; }
public Autre(string nom, decimal Quantite)
[DataMember]
public int Quantite { get; set; }
public Autre(string nom, int qu)
{
Nom = nom;
Quantite = qu;
}
public Autre()
{
}
public override bool Equals(object obj)
{
this.Nom = nom;
this.Quantite = Quantite;
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as Autre);
}
public override string ToString()
{
return $"nom : {Nom}, quantité : {Quantite} \n";
return $"nom : {Nom} \n";
}
public override int GetHashCode()
{
return HashCode.Combine(Nom);
}
}
}

@ -1,23 +1,46 @@
using System;
using System.Runtime.Serialization;
using System.Security.Principal;
namespace ParionsCuite.Modeles
{
public class Boissons
[DataContract]
public class Boisson
{
public string Nom { get; set; }
public decimal Quantite { get; set; }
[DataMember]
public string Nom { get; set; }
public Boissons(string nom, decimal Quantite)
[DataMember]
public int Quantite { get; set; }
public Boisson(string nom, int qu)
{
Nom = nom;
Quantite = qu;
}
public Boisson()
{
}
public override bool Equals(object obj)
{
this.Nom = nom;
this.Quantite = Quantite;
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as Boisson);
}
public override string ToString()
{
return $"nom : {Nom}, quantité : {Quantite} \n";
return $"nom : {Nom} \n";
}
public override int GetHashCode()
{
return HashCode.Combine(Nom);
}
}
}

@ -1,46 +1,163 @@
using System;
using ParionsCuite.Views.Invite;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
public class Evenement
[DataContract]
public class Evenement : INotifyPropertyChanged
{
public string nom { get; private set; }
public event PropertyChangedEventHandler? PropertyChanged;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
/* Déclaration */
[DataMember]
public string Nom { get; private set; }
[DataMember]
public string Date { get; private set; }
[DataMember]
public string Lieu { get; private set; }
[DataMember]
public string Heure { get; private set; }
[DataMember]
public Participation Participation { get; private set; }
[DataMember]
public List<Inviter> ListInviter { get; private set; }
public event Action<Parier> PariAdd;
[DataMember]
private ObservableCollection<Parier> listParier;
public ObservableCollection<Parier> ListParier
{
get { return listParier; }
set
{
if (listParier != value)
{
listParier = value;
OnPropertyChanged();
OnPariAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement
}
}
}
private void OnPariAdded(Parier parier)
{
// Logique à exécuter lorsque un événement est ajouté
Debug.WriteLine("Événement ajouté : ");
}
public bool Ajout_Pari(Parier pari)
{
ListParier.Add(pari);
OnPropertyChanged(nameof(Parier));
PariAdd?.Invoke(pari);
return true;
}
/* Constructeur */
public Evenement(string nom, string date, string lieu, string heure)
{
Nom = nom;
Date = date;
Lieu = lieu;
Heure = heure;
ListInviter = new List<Inviter>();
ListParier = new ObservableCollection<Parier>();
Participation = new Participation();
}
public Evenement(string nom, string date, string lieu, string heure, Participation participation)
{
Nom = nom;
Date = date;
Lieu = lieu;
Heure = heure;
Participation = participation;
ListInviter = new List<Inviter>();
ListParier = new ObservableCollection<Parier>();
}
public DateTime date { get; private set; }
public Evenement(List<Inviter> inviters, List<Participation> participations, List<Parier> pariers)
{
public string lieu { get; private set; }
}
/* Méthode Inviter */
public bool Ajouter_inviter(Inviter I)
{
ListInviter.Add(I);
foreach (Inviter i in ListInviter)
{
if (i == I)
return true;
}
return false;
}
public bool Supprimer_inviter(Inviter inviter)
{
return ListInviter.Remove(inviter);
}
public int heure { get; private set; }
public int LenListInvite(List<Inviter> list)
{
int len = 0;
foreach (Inviter inviter in list)
{
len++;
}
return len;
}
public int minute { get; private set; }
public List<Inviter> ReturnListInvite()
{
return ListInviter;
}
public Participation participation { get; private set; }
/* Méthode Parie */
public bool Ajouter_parie(Parier parier)
{
ListParier.Add(parier);
foreach (Parier p in ListParier)
{
if (p == parier)
return true;
}
return false;
}
Evenement(string nom, DateTime date, string lieu, int heure, int minute, Participation participation)
public bool Supprimer_parie(Parier p)
{
this.nom = nom;
this.date = date;
this.lieu = lieu;
this.heure = heure;
this.minute = minute;
this.participation = participation;
List<Inviter> list_inviter = new List<Inviter>();
List<Parier> list_parie = new List<Parier>();
return ListParier.Remove(p);
}
void setEvenement(string nom, DateTime date, string lieu, int heure, int minute)
/* Setter */
public void SetEvenement(string nom, string date, string lieu, string heure)
{
this.nom = nom;
this.date = date;
this.lieu = lieu;
this.heure = heure;
this.minute = minute;
Nom = nom;
Date = date;
Lieu = lieu;
Heure = heure;
return;
}
public override string ToString()
{
return $"Nom : {Nom} \nDate : {Date}\nLieu : {Lieu}\nHeure : {Heure} ";
}
}
}

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
namespace ParionsCuite.Modeles
{
public interface IPersistanceManager
{
public ObservableCollection<Evenement> chargeDonnees();
public void sauvegardeDonnees(ObservableCollection<Evenement> evenements);
}
}

@ -1,15 +1,30 @@
using System;
using System.Runtime.Serialization;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Inviter
{
public string Nom;
public string Prenom;
[DataMember]
public string Nom { get; set; }
[DataMember]
public string Prenom { get; set; }
public Inviter(string nom, string prenom)
{
this.Nom = nom;
this.Prenom = prenom;
Nom = nom;
Prenom = prenom;
}
public Inviter(string prenom)
{
Prenom = prenom;
}
public Inviter()
{
}
public override string ToString()

@ -1,25 +1,123 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
public class Manageur
public class Manageur : INotifyPropertyChanged
{
public string nom { get; private set; }
public event PropertyChangedEventHandler PropertyChanged;
public string prenom { get; private set; }
public event Action<Evenement> EvenementAdded;
public List<Evenement> ev { get; private set; }
private ObservableCollection<Evenement> evenement;
Manageur(string nom, string prenom)
{
this.nom = nom;
this.prenom = prenom;
this.ev = new List<Evenement>();
public bool Value1;
public bool Value2;
public bool Value3;
void OnPropertyChanged([CallerMemberName] string propertyName = null)
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public ObservableCollection<Evenement> Evenement
{
get { return evenement; }
set
{
if (evenement != value)
{
evenement = value;
OnPropertyChanged();
OnEvenementAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement
}
}
}
private void OnEvenementAdded(Evenement evenement)
{
// Logique à exécuter lorsque un événement est ajouté
Debug.WriteLine("Événement ajouté : ");
}
public List<Inviter> Invites { get; set; }
public IPersistanceManager Persistance { get; set; }
public Manageur(IPersistanceManager Pers) {
Invites = new List<Inviter>();
Evenement = new ObservableCollection<Evenement>();
Persistance = Pers;
}
public Manageur()
{
Evenement = new ObservableCollection<Evenement>();
Invites = new List<Inviter>();
}
public Manageur(ObservableCollection<Evenement> evenements)
{
Evenement = evenements;
}
public bool Ajout_evenement(Evenement ev)
{
Evenement.Add(ev);
OnPropertyChanged(nameof(Evenement));
EvenementAdded?.Invoke(ev);
return true;
}
public bool Supprimer_evenement(Evenement ev)
{
return Evenement.Remove(ev);
}
public List<Inviter> AddInvite(Inviter invite1)
{
Invites.Add(invite1);
return Invites;
}
public List<Inviter> RemoveInviter(Inviter invite1)
{
Invites.Remove(invite1);
return Invites;
}
public int LenListInvite(List<Inviter> list)
{
int len = 0;
foreach (Inviter inviter in list)
{
len++;
}
return len;
}
public List<Inviter> ReturnListInvite()
{
return Invites;
}
public void Charge_Donnee()
{
var donnees = Persistance.chargeDonnees();
foreach (var donnee in donnees)
{
Evenement.Add(donnee);
}
}
public void Save_Data()
{
Persistance.sauvegardeDonnees(Evenement);
}
}
}

@ -1,20 +1,45 @@
using System;
using System.Runtime.Serialization;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Nourriture
{
public string Nom { get; set; }
public decimal Quantite { get; set; }
[DataMember]
public string Nom { get; set; }
[DataMember]
public int Quantite { get; set; }
public Nourriture(string nom, int qu)
{
Nom = nom;
Quantite = qu;
}
public Nourriture()
{
}
public Nourriture(string nom, decimal quantite)
public override bool Equals(object obj)
{
this.Nom = nom;
Quantite = quantite;
if (ReferenceEquals(obj, null)) return false;
if (ReferenceEquals(obj, this)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals(obj as Nourriture);
}
public override string ToString()
{
return $"nom : {Nom}, quantité : {Quantite} \n";
return $"nom : {Nom} \n";
}
public override int GetHashCode()
{
return HashCode.Combine(Nom);
}
}
}

@ -1,23 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
public class Parier
[DataContract]
public class Parier
{
[DataMember]
public Inviter i1;
[DataMember]
public Inviter i2;
public string but { get; private set; }
public string But { get; private set; }
public string enjeu { get; private set; }
public string Enjeu { get; private set; }
public Parier(Inviter i1, Inviter i2, string but, string enjeu)
{
this.i1 = i1;
this.i2 = i2;
But = but;
Enjeu = enjeu;
}
public override string ToString()
{
return $"joueur n°1 : {i1}, \njoueur n°2 : {i2}, \nbut : {but}, enjeux : {enjeu}";
return $"joueur n°1 : {i1}, \njoueur n°2 : {i2}, \nbut : {But}, enjeux : {Enjeu}";
}
}
}

@ -1,20 +1,163 @@
using System;
using Microsoft.Maui.ApplicationModel;
using ParionsCuite.Views.Participations.Autre;
using ParionsCuite.Views.Participations.Boisson;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Participation
{
Participation()
[DataMember]
public List<Boisson> Boissons { get; private set; }
[DataMember]
public List<Nourriture> Nourriture { get; private set; }
[DataMember]
public List<Autre> Autre { get; private set; }
public Participation(List<Boisson> boisson, List<Nourriture> nourriture, List<Autre> autre)
{
Boissons = boisson;
Nourriture = nourriture;
Autre = autre;
}
public Participation()
{
Boissons = new List<Boisson>();
Nourriture = new List<Nourriture>();
Autre = new List<Autre>();
}
/* Boisson */
public bool Ajout_Boissons(Boisson boisson)
{
foreach (var obj in Boissons)
{
if (obj.Equals(boisson))
{
if (boisson.Quantite > 0)
{
obj.Quantite = obj.Quantite + boisson.Quantite;
return true;
}
return false;
}
}
Boissons.AddRange((IEnumerable<Boisson>)boisson);
return true;
}
public bool Sup_Boissons(Boisson boisson, int quantite)
{
foreach(var obj in Boissons)
{
if (obj.Equals(boisson))
if (quantite > 0)
{
if (quantite >= boisson.Quantite)
{
Boissons.Remove(boisson);
return true;
}
obj.Quantite = obj.Quantite + boisson.Quantite;
return true;
}
return false;
}
return false;
}
/* Nourriture */
public bool Ajout_Nourriture(Nourriture food)
{
foreach (var obj in Nourriture)
{
if (obj.Equals(food))
{
if (food.Quantite > 0)
{
obj.Quantite = obj.Quantite + food.Quantite;
return true;
}
return false;
}
}
Nourriture.AddRange((IEnumerable<Nourriture>)food);
return true;
}
public bool Sup_Nourriture(Nourriture food, int quantite)
{
foreach (var obj in Boissons)
{
if (obj.Equals(food))
if (quantite > 0)
{
if (quantite >= food.Quantite)
{
Nourriture.Remove(food);
return true;
}
obj.Quantite = obj.Quantite + food.Quantite;
return true;
}
return false;
}
return false;
}
/* Autre */
public bool Ajout_Autre(Autre autre)
{
List<Boissons> list_boisson = new List<Boissons>();
List<Autre> list_autre = new List<Autre>();
List<Nourriture> list_nourriture = new List<Nourriture>();
foreach (var obj in Autre)
{
if (obj.Equals(autre))
{
if (autre.Quantite > 0)
{
obj.Quantite = obj.Quantite + autre.Quantite;
return true;
}
return false;
}
}
Autre.AddRange((IEnumerable<Autre>)autre);
return true;
}
public bool Sup_Autre(Autre autre, int quantite)
{
foreach (var obj in Autre)
{
if (obj.Equals(autre))
if (quantite > 0)
{
if (quantite >= autre.Quantite)
{
Autre.Remove(autre);
return true;
}
obj.Quantite = obj.Quantite + autre.Quantite;
return true;
}
return false;
}
return false;
}
}
}

@ -1,103 +1,131 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<TargetFrameworks>net7.0;</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('maccatalyst'))">$(TargetFrameworks);net7.0-maccatalyst</TargetFrameworks>
<OutputType Condition="'$(TargetFramework)' != 'net7.0'">Exe</OutputType>
<RootNamespace>ParionsCuite</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>ParionsCuite</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.parionscuite</ApplicationId>
<ApplicationIdGuid>be941c7a-90b1-469a-aa20-94c786120159</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-maccatalyst|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\Accueil.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Groupe.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Information\Info.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Invite\Inviter.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Pari\Parier.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Images\fleches.png" />
<None Remove="Views\Ajout_Paris\" />
<None Remove="Views\Participations\" />
<None Remove="Views\Participations\Autre\" />
<None Remove="Views\Participations\Boisson\" />
<None Remove="Modeles\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Images\fleches.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Images\fleches.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Ajout_Paris\" />
<Folder Include="Views\Participations\" />
<Folder Include="Views\Participations\Autre\" />
<Folder Include="Views\Participations\Boisson\" />
<Folder Include="Modeles\" />
</ItemGroup>
<PropertyGroup>
<TargetFrameworks>net7.0-android;net7.0-ios;net7.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net7.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<!--<RuntimeIdentifiers>maccatalyst-arm64</RuntimeIdentifiers>-->
<OutputType>Exe</OutputType>
<RootNamespace>ParionsCuite</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>ParionsCuite</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.companyname.parionscuite</ApplicationId>
<ApplicationIdGuid>be941c7a-90b1-469a-aa20-94c786120159</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">11.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">13.1</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net7.0-ios|AnyCPU'">
<CreatePackage>false</CreatePackage>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<AndroidResource Remove="Modeles\**" />
<AndroidResource Remove="Views\Participations\NewFolder\**" />
<Compile Remove="Modeles\**" />
<Compile Remove="Views\Participations\NewFolder\**" />
<EmbeddedResource Remove="Modeles\**" />
<EmbeddedResource Remove="Views\Participations\NewFolder\**" />
<MauiCss Remove="Modeles\**" />
<MauiCss Remove="Views\Participations\NewFolder\**" />
<MauiXaml Remove="Modeles\**" />
<MauiXaml Remove="Views\Participations\NewFolder\**" />
<None Remove="Modeles\**" />
<None Remove="Views\Participations\NewFolder\**" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\Accueil.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Groupe.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Information\Info.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Invite\Inviter.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Pari\InfoPAri.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Pari\Parier.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Participations\Boisson\Drink.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Participations\NewFolder1\Nourri.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
<ItemGroup>
<None Remove="Resources\Images\fleches.png" />
<None Remove="Views\Ajout_Paris\" />
<None Remove="Views\Participations\" />
<None Remove="Views\Participations\Autre\" />
<None Remove="Views\Participations\Boisson\" />
<None Remove="Modeles\" />
<None Remove="Stub\" />
<None Remove="Test\" />
</ItemGroup>
<ItemGroup>
<BundleResource Include="Resources\Images\fleches.png" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\Images\fleches.png" />
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Ajout_Paris\" />
<Folder Include="Views\Participations\Autre\" />
<Folder Include="Stub\" />
</ItemGroup>
<ItemGroup Condition="$(VisualStudioVersion) == '17.0'">
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modeles\Modeles.csproj" />
</ItemGroup>
<PropertyGroup>
<SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
</PropertyGroup>
</Project>

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 25.0.1706.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParionsCuite", "ParionsCuite.csproj", "{DE9B9528-B8C4-4578-AF15-A0C048245739}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ParionsCuite", "ParionsCuite.csproj", "{3C605C4F-A3EE-4E08-B43D-692792A3DFCD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,15 +13,18 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DE9B9528-B8C4-4578-AF15-A0C048245739}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE9B9528-B8C4-4578-AF15-A0C048245739}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DE9B9528-B8C4-4578-AF15-A0C048245739}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE9B9528-B8C4-4578-AF15-A0C048245739}.Release|Any CPU.Build.0 = Release|Any CPU
{3C605C4F-A3EE-4E08-B43D-692792A3DFCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3C605C4F-A3EE-4E08-B43D-692792A3DFCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3C605C4F-A3EE-4E08-B43D-692792A3DFCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3C605C4F-A3EE-4E08-B43D-692792A3DFCD}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {51AF7064-DA59-4B4B-AA97-0D2CDBC1ADA8}
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6A064B44-E657-47A6-9D3E-2585AD56A945}
EndGlobalSection
EndGlobal

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using ParionsCuite.Modeles;
namespace ParionsCuite.Stub;
/// <summary>
/// Represents a stub implementation of the <see cref="IPersistanceManager"/> interface.
/// </summary>
public class Stub : IPersistanceManager
{
/// <summary>
/// Loads the data and returns an <see cref="ObservableCollection{Evenement}"/>.
/// </summary>
/// <returns>An <see cref="ObservableCollection{Evenement}"/> containing the loaded data.</returns>
public ObservableCollection<Evenement> chargeDonnees()
{
ObservableCollection<Evenement> lisEvent = new ObservableCollection<Evenement>();
List<Boisson> boissons = new List<Boisson>();
List<Nourriture> nourritures = new List<Nourriture>();
List<Autre> autres = new List<Autre>();
Boisson boisson = new Boisson("biere", 15);
boissons.Add(boisson);
Nourriture nourriture = new Nourriture("pain", 15);
nourritures.Add(nourriture);
Autre autre = new Autre("chaise", 15);
autres.Add(autre);
Participation participation = new Participation(boissons, nourritures, autres);
DateTime dt = new DateTime(2018, 7, 24);
Evenement e = new Evenement("nom", "dt", "lieu", "12", participation);
lisEvent.Add(e);
return lisEvent;
}
/// <summary>
/// Saves the data from the specified <see cref="ObservableCollection{Evenement}"/>.
/// </summary>
/// <param name="evenements">The <see cref="ObservableCollection{Evenement}"/> to save.</param>
public void sauvegardeDonnees(ObservableCollection<Evenement> evenements)
{
throw new NotImplementedException();
}
}

@ -4,40 +4,30 @@
x:Class="ParionsCuite.Views.Ajout_Paris.Ajouts_Pari">
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
<Button Text="Invité" />
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
<Button Text="Information" Grid.Column="3" />
</Grid>
<!--Ajout Parieur-->
<Grid Margin="20" ColumnDefinitions="5*,*,5*,*" RowDefinitions="*,*">
<Grid Margin="5" ColumnDefinitions="5*,*,5*,*" RowDefinitions="*,*">
<Label Text="Parieur(s) 1 :" FontSize="Title" HorizontalOptions="Center"/>
<Label Grid.Column="2" Text="Parieur(s) 2 :" FontSize="Title" HorizontalOptions="End"/>
<Entry Grid.Row="1" Placeholder="Entrer nom" FontSize="Title" HorizontalOptions="Center"/>
<Button Grid.Row="1" Grid.Column="1" Text="+" Margin="5"/>
<Entry Grid.Row="1" Placeholder="Entrer nom" x:Name="Parieur1" FontSize="Title" HorizontalOptions="Center"/>
<Entry Grid.Row="1" Grid.Column="2" Placeholder="Entrer nom" FontSize="Title" HorizontalOptions="Center"/>
<Button Grid.Row="1" Grid.Column="3" Text="+" Margin="5"/>
<Entry Grid.Row="1" Grid.Column="2" Placeholder="Entrer nom" x:Name="Parieur2" FontSize="Title" HorizontalOptions="Center"/>
</Grid>
<!--Ajout But+Enjeux-->
<Grid Margin="20" ColumnDefinitions="*,*" RowDefinitions="*,*">
<Label Text="But du pari :" FontSize="Title" HorizontalOptions="Center"/>
<Entry Grid.Column="1" Placeholder="Entrer" FontSize="Title" HorizontalOptions="Center"/>
<Entry Grid.Column="1" Placeholder="Entrer" x:Name="ButPari" FontSize="Title" HorizontalOptions="Center"/>
<Label Grid.Row="1" Text="Enjeux du pari :" FontSize="Title" HorizontalOptions="Center"/>
<Entry Grid.Row="1" Grid.Column="1" Placeholder="Entrer" FontSize="Title" HorizontalOptions="Center"/>
<Entry Grid.Row="1" Grid.Column="1" Placeholder="Entrer" x:Name="EnjeuxPari" FontSize="Title" HorizontalOptions="Center"/>
</Grid>
<!--Button ajouter-->
<StackLayout>
<Button Text="Ajouter Pari" HorizontalOptions="Start" FontSize="Title" Margin="500,30,0,0"/>
<Button Text="Ajouter Pari" Clicked="NewPari" HorizontalOptions="Start" FontSize="Title" Margin="500,30,0,0"/>
</StackLayout>
</VerticalStackLayout>
</ContentView>

@ -1,9 +1,52 @@
namespace ParionsCuite.Views.Ajout_Paris;
using ParionsCuite.Modeles;
using System.Diagnostics;
namespace ParionsCuite.Views.Ajout_Paris;
/**
* @brief The Ajouts_Pari class is a partial class derived from ContentView.
*/
public partial class Ajouts_Pari : ContentView
{
public Ajouts_Pari()
{
InitializeComponent();
}
/**
* @brief The EventSelect field stores the selected event.
*/
readonly Evenement EventSelect;
/**
* @brief The mgr property returns the application's manager instance.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Initializes a new instance of the Ajouts_Pari class.
* @param EventSelect The selected event.
*/
public Ajouts_Pari(Evenement EventSelect)
{
InitializeComponent();
this.EventSelect = EventSelect;
}
/**
* @brief Handles the NewPari event.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void NewPari(object sender, EventArgs e)
{
string parieur1 = Parieur1.Text;
string parieur2 = Parieur2.Text;
string but = ButPari.Text;
string enjeux = EnjeuxPari.Text;
Inviter NewParieur1 = new Inviter(parieur1);
Inviter NewParieur2 = new Inviter(parieur2);
Modeles.Parier newPari = new Parier(NewParieur1, NewParieur2, but, enjeux);
Debug.WriteLine("PArieur ajouter" + newPari.But);
EventSelect.Ajout_Pari(newPari);
mgr.Save_Data();
}
}

@ -25,8 +25,8 @@
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" TextColor="Aqua" Text="Nom de l'événement :" FontSize="Title"/>
<Entry Placeholder="Entrer nom" Grid.Column="1" FontSize="Title"/>
<Label Grid.Column="0" TextColor="Black" Text="Nom de l'événement :" FontSize="Title"/>
<Entry Placeholder="Entrer nom" x:Name="nomE" Grid.Column="1" FontSize="Title"/>
</Grid>
<!-- Deuxième input date evenement-->
@ -35,8 +35,8 @@
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" TextColor="Aqua" Text="Date de l'événement :" FontSize="Title"/>
<Entry Placeholder="Entrer date" Grid.Column="1" FontSize="Title"/>
<Label Grid.Column="0" TextColor="Black" Text="Date de l'événement :" FontSize="Title"/>
<Entry Placeholder="Entrer date" x:Name="dateE" Grid.Column="1" FontSize="Title"/>
</Grid>
<!-- Troisième input lieux evenement-->
@ -45,8 +45,8 @@
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" TextColor="Aqua" Text="Indiquer adresse:" FontSize="Title"/>
<Entry Placeholder="Entrer adresse" Grid.Column="1" FontSize="Title"/>
<Label Grid.Column="0" TextColor="Black" Text="Indiquer adresse:" FontSize="Title"/>
<Entry Placeholder="Entrer adresse" x:Name="lieuE" Grid.Column="1" FontSize="Title"/>
</Grid>
<!-- Quatrième input heure evenement-->
@ -55,12 +55,12 @@
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="5*"/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" TextColor="Aqua" Text="Indiquer horaire de l'evenement :" FontSize="Title"/>
<Entry Placeholder="Entrer heure" Grid.Column="1" FontSize="Title"/>
<Label Grid.Column="0" TextColor="Black" Text="Indiquer horaire de l'evenement :" FontSize="Title"/>
<Entry Placeholder="Entrer heure" x:Name="heureE" Grid.Column="1" FontSize="Title"/>
</Grid>
<!-- Cinquième input ajout invité-->
<Grid Grid.Row="5">
<Grid Grid.Row="5" HeightRequest="60">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="10*"/>
@ -69,7 +69,7 @@
<Entry Placeholder="Ajouter un invité" Grid.Column="1" FontSize="Title"/>
</Grid>
<Button Grid.Row="6" Text="Creer événement" Margin="10" MinimumHeightRequest="50" MinimumWidthRequest="150" MaximumHeightRequest="400" MaximumWidthRequest="300"/>
<Button Grid.Row="6" Text="Creer événement" Clicked="Button_Clicked" />
</Grid>

@ -1,13 +1,63 @@
namespace ParionsCuite.Views;
using System.Collections.ObjectModel;
using System.Diagnostics;
using ParionsCuite.Modeles;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace ParionsCuite.Views;
/**
* @brief Represents a ContentView for creating new events.
*
* The `Groupe` class provides a form for creating new events. It has a reference to the `Manageur` instance to perform operations on the data.
*/
public partial class Groupe : ContentView
{
public Groupe()
{
InitializeComponent();
}
/**
* @brief Gets the instance of the `Manageur` class used in the application.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Gets or sets the collection of events.
*/
public ObservableCollection<Evenement> Evenements { get; set; } = new ObservableCollection<Evenement>();
void DatePicker_DateSelected(System.Object sender, Microsoft.Maui.Controls.DateChangedEventArgs e)
/**
* @brief Initializes a new instance of the `Groupe` class.
*/
public Groupe()
{
InitializeComponent();
}
/**
* @brief Event handler for the button clicked event.
*
* This method is called when the button for creating a new event is clicked. It retrieves the input values from the form, creates a new event object, adds it to the Manageur instance, and clears the form fields.
*
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void Button_Clicked(object sender, EventArgs e)
{
var nomEvent = nomE.Text;
var dateEvent = dateE.Text;
var lieuEvent = lieuE.Text;
var heureEvent = heureE.Text;
if (!string.IsNullOrEmpty(nomEvent) && !string.IsNullOrEmpty(dateEvent) && !string.IsNullOrEmpty(lieuEvent) && !string.IsNullOrEmpty(heureEvent))
{
var newEvent = new Evenement(nomEvent, dateEvent, lieuEvent, heureEvent);
mgr.Ajout_evenement(newEvent);
nomE.Text = "";
dateE.Text = "";
lieuE.Text = "";
heureE.Text = "";
}
else
{
Debug.WriteLine("Creation Event Error PLease Check!!!");
}
}
}
}

@ -2,36 +2,25 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Information.Info">
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<Button Text="Invité" />
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2"/>
<Button Text="Information" Grid.Column="3" BackgroundColor="Grey"/>
</Grid>
<StackLayout HorizontalOptions="Start" MinimumWidthRequest="1000" MinimumHeightRequest="1000" Margin="200,20,0,0" >
<VerticalStackLayout HeightRequest="1000">
<Grid >
<TableView x:Name="tableview" >
<TableRoot >
<TableSection Title="Informations" x:Name="tableInfo" >
<TextCell Text="Nom de l'événement" Detail="{Binding Nom}" x:Name="NomEvent" />
<TextCell Text="Date de l'événement" Detail="{Binding Date}" x:Name="DateEvent"/>
<TextCell Text="Nombres d'invité" x:Name="NbInvite"/>
<TextCell Text="Nombres de paris" x:Name="NbPari"/>
<TextCell Text="Adresse" Detail="{Binding Lieu}" x:Name="AdresseEvent"/>
<TextCell Text="Horaire" Detail="{Binding Heure}" x:Name="HoraireEvent"/>
</TableSection>
</TableRoot>
</TableView>
<TableView RowHeight="70">
<TableRoot >
<TableSection Title="Informations">
<TextCell Text="Nom de l'événement" Detail ="Nom"/>
<TextCell Text="Date de l'événement" Detail ="Date"/>
<TextCell Text="Nombres d'invité" Detail ="Nombre"/>
<TextCell Text="Nombres de paris" Detail ="Nombre"/>
<TextCell Text="Adresse" Detail ="Adresse"/>
<TextCell Text="Horaire" Detail ="Horaire"/>
</TableSection>
</TableRoot>
</TableView>
</StackLayout>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -1,9 +1,51 @@
namespace ParionsCuite.Views.Information;
using ParionsCuite.Modeles;
using System.Diagnostics;
using System.Xml.Linq;
namespace ParionsCuite.Views.Information;
/**
* @brief The Info class is a partial class derived from ContentView.
*/
public partial class Info : ContentView
{
public Info()
{
InitializeComponent();
}
}
/**
* @brief The mgr property returns the application's manager instance.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Initializes a new instance of the Info class.
* @param EventSelect The selected event.
*/
public Info(Evenement EventSelect)
{
InitializeComponent();
MiseAJourInfo(EventSelect);
this.BindingContext = EventSelect;
}
/**
* @brief The m field stores an instance of the Manageur class.
*/
public Manageur m = new Manageur();
/**
* @brief The DefaultCellHeight constant defines the default height of a cell.
*/
public const int DefaultCellHeight = 40;
/**
* @brief Updates the information for the selected event.
* @param EventSelect The selected event.
*/
public void MiseAJourInfo(Evenement EventSelect)
{
int i = EventSelect.ListInviter.Count();
NbInvite.Detail = i.ToString();
int v = EventSelect.ListParier.Count();
NbPari.Detail = v.ToString();
AdresseEvent.Detail = EventSelect.Lieu;
HoraireEvent.Detail = EventSelect.Heure;
}
}

@ -1,29 +1,21 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:system="clr-namespace:System;assembly=mscorlib"
x:Class="ParionsCuite.Views.Invite.Inviter">
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
<Button Text="Invité" BackgroundColor="Grey"/>
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2"/>
<Button Text="Information" Grid.Column="3"/>
</Grid>
<VerticalStackLayout >
<!--Grid Pincipale-->
<Grid ColumnDefinitions="8*,*,10*">
<Grid ColumnDefinitions="8*,*,10*" x:Name="gridInvite">
<!--Input des noms et prenoms-->
<StackLayout Grid.Column="0" >
<Entry Placeholder="Entrer nom invité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer prénom invité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
<Entry Placeholder="Entrer nom invité" x:Name="nomEditor" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer prénom invité" x:Name="prenomEditor" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" Clicked="AddInvitelist" HorizontalOptions="Center" Margin="0,20,0,0"/>
</StackLayout>
<!--Grid prenom et nom + output -->
<Grid Grid.Column="2" Margin="30">
<Grid Grid.Column="2" Margin="30" x:Name="GrilleInvite">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" />
@ -31,15 +23,14 @@
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Label Text="Prenom" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Nom" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Thomas" Grid.Column="1" Grid.Row="1" FontSize="Large"/>
<Label Text="Muzard" Grid.Row="1" FontSize="Large"/>
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
<Label Text="{Binding Modeles.Inviter.Nom}" Grid.Column="1" Grid.Row="1" FontSize="Large"/>
<Label Text="{Binding Prenom}" Grid.Row="1" FontSize="Large"/>
</Grid>

@ -1,13 +1,189 @@
using ParionsCuite.Modeles;
using System.Diagnostics;
using System.Windows;
namespace ParionsCuite.Views.Invite;
/**
* @brief The Inviter class is a partial class derived from ContentView.
*/
public partial class Inviter : ContentView
{
public Inviter()
{
InitializeComponent();
}
/**
* @brief The mgr property returns the application's manager instance.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief The EventSelect field stores the selected event.
*/
private readonly Evenement EventSelect;
/**
* @brief Gets or sets the Inviters object.
*/
public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter();
void ColumnDefinition_SizeChanged(System.Object sender, System.EventArgs e)
/**
* @brief Initializes a new instance of the Inviter class.
* @param EventSelect The selected event.
*/
public Inviter(Evenement EventSelect)
{
this.EventSelect = EventSelect;
InitializeComponent();
restoreListInvite(EventSelect);
BindingContext = this;
}
}
/**
* @brief Restores the list of invitees for the selected event.
* @param EventSelect The selected event.
*/
public void restoreListInvite(Evenement EventSelect)
{
List<Modeles.Inviter> listInvite = EventSelect.ListInviter;
Debug.WriteLine(listInvite);
int len = 1;
foreach (Modeles.Inviter inviter in listInvite)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GrilleInvite.RowDefinitions.Add(row);
// Ajout Prenom
Label prenomLabel = new Label();
prenomLabel.Text = inviter.Prenom;
Grid.SetRow(prenomLabel, len);
Grid.SetColumn(prenomLabel, 0);
GrilleInvite.Children.Add(prenomLabel);
// Ajout Nom
Label nomLabel = new Label();
nomLabel.Text = inviter.Nom;
Grid.SetRow(nomLabel, len);
Grid.SetColumn(nomLabel, 1);
GrilleInvite.Children.Add(nomLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GrilleInvite.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
/**
* @brief Handles the event when the add invite list button is clicked.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void AddInvitelist(object sender, EventArgs e)
{
string nom = nomEditor.Text;
string prenom = prenomEditor.Text;
if (nom == null || prenom == null || nom == "" || prenom == "") { return; }
Modeles.Inviter invite1 = new Modeles.Inviter(nom, prenom);
EventSelect.ListInviter.Add(invite1);
int len = 1;
Debug.WriteLine("LA taille de la liste est de " + mgr.LenListInvite(EventSelect.ListInviter));
foreach (Modeles.Inviter inviter in EventSelect.ListInviter)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GrilleInvite.RowDefinitions.Add(row);
// Ajout Prenom
Label prenomLabel = new Label();
prenomLabel.Text = inviter.Prenom;
Grid.SetRow(prenomLabel, len);
Grid.SetColumn(prenomLabel, 0);
GrilleInvite.Children.Add(prenomLabel);
// Ajout Nom
Label nomLabel = new Label();
nomLabel.Text = inviter.Nom;
Grid.SetRow(nomLabel, len);
Grid.SetColumn(nomLabel, 1);
GrilleInvite.Children.Add(nomLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GrilleInvite.Children.Add(buttonMoins);
len++;
}
prenomEditor.Text = "";
nomEditor.Text = "";
mgr.Save_Data();
}
/**
* @brief Handles the event when the delete button is clicked.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
{
// Récupérer le bouton cliqué
Button button = (Button)sender;
// Récupérer la grille parente du bouton
Grid parentGrid = (Grid)button.Parent;
// Récupérer la ligne parente du bouton
int rowIndex = Grid.GetRow(button);
// Vérifier que l'indice rowIndex est valide
Label prenomLabel = null;
Label nomLabel = null;
// Parcourir les enfants de la grille pour trouver les labels de la ligne
foreach (View child in parentGrid.Children)
{
int childRowIndex = Grid.GetRow(child);
if (childRowIndex == rowIndex)
{
if (Grid.GetColumn(child) == 0)
prenomLabel = (Label)child;
else if (Grid.GetColumn(child) == 1)
nomLabel = (Label)child;
}
}
if (prenomLabel != null && nomLabel != null)
{
// Récupérer le prénom et le nom de l'invité à supprimer
string prenom = prenomLabel.Text;
string nom = nomLabel.Text;
// Rechercher l'invité correspondant dans la liste
Modeles.Inviter inviter = EventSelect.ListInviter.FirstOrDefault(i => i.Prenom == prenom && i.Nom == nom);
if (inviter != null)
{
// Supprimer l'invité de la liste
EventSelect.ListInviter.Remove(inviter);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(prenomLabel);
parentGrid.Children.Remove(nomLabel);
parentGrid.Children.Remove(button);
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
mgr.Save_Data();
}
}

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Pari.InfoPAri">
<VerticalStackLayout>
<!--P1 vs P2-->
<Grid ColumnDefinitions="2*,*,2*,2*,*,2*" >
<Button x:Name="Parieur1" Margin="40,0,0,0"/>
<Label Text="Contre" Grid.Column="2" HorizontalOptions="Center" FontAttributes="Bold" FontSize="Title"/>
<Button Text="Parieur 2" x:Name="Parieur2" Grid.Column="3" />
</Grid>
<!--Info Pari-->
<TableView RowHeight="70" Margin="30,0,0,0" HorizontalOptions="Start" WidthRequest="1000">
<TableRoot>
<TableSection>
<EntryCell Label="But du Pari" Text="{Binding But}" x:Name="butPari" />
<EntryCell Label="Enjeux du Pari" Text="{Binding Enjeu}" x:Name="enjeuxPari" />
<ViewCell>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="15,0,0,0">
<Label Text="Pari terminé" VerticalOptions="Center" />
<Switch x:Name="ValuePari" Toggled="ValuePari_Toggled" />
</StackLayout>
</ViewCell>
<ViewCell>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="15,0,0,0">
<Label Text="Joueur(s) 1 gagnant" VerticalOptions="Center" />
<Switch x:Name="j1" Toggled="j1_Toggled" IsEnabled="{Binding Source={x:Reference ValuePari}, Path=IsToggled}" />
</StackLayout>
</ViewCell>
<ViewCell>
<StackLayout Orientation="Horizontal" VerticalOptions="CenterAndExpand" Padding="15,0,0,0">
<Label Text="Joueur(s) 2 gagnant" VerticalOptions="Center" />
<Switch x:Name="j2" Toggled="j2_Toggled" IsEnabled="{Binding Source={x:Reference ValuePari}, Path=IsToggled}" />
</StackLayout>
</ViewCell>
</TableSection>
</TableRoot>
</TableView>
</VerticalStackLayout>
</ContentView>

@ -0,0 +1,97 @@
using ParionsCuite.Modeles;
using System.Diagnostics;
namespace ParionsCuite.Views.Pari;
/**
* @brief Represents a ContentView for displaying information about a specific bet (Pari).
*/
public partial class InfoPAri : ContentView
{
readonly Modeles.Parier PariSelect;
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Initializes a new instance of the InfoPAri class.
* @param PariSelect The selected bet (Pari).
*/
public InfoPAri(Modeles.Parier PariSelect)
{
InitializeComponent();
this.PariSelect = PariSelect;
this.BindingContext = PariSelect;
MiseAJourInfo(PariSelect);
}
/**
* @brief Updates the information displayed for the selected bet (Pari).
* @param PariSelect The selected bet (Pari).
*/
private void MiseAJourInfo(Modeles.Parier PariSelect)
{
Parieur1.Text = PariSelect.i1.Prenom;
Parieur2.Text = PariSelect.i2.Prenom;
ValuePari.IsToggled = mgr.Value1;
j1.IsToggled = mgr.Value2;
j2.IsToggled = mgr.Value3;
Debug.WriteLine("Value " + mgr.Value2);
}
/**
* @brief Handles the event when the toggle switch for ValuePari is toggled.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void ValuePari_Toggled(object sender, ToggledEventArgs e)
{
if (!ValuePari.IsToggled)
{
j1.IsToggled = false;
j2.IsToggled = false;
}
mgr.Value1 = ValuePari.IsToggled;
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
/**
* @brief Handles the event when the toggle switch for j1 is toggled.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void j1_Toggled(object sender, ToggledEventArgs e)
{
if (j1.IsToggled && !ValuePari.IsToggled || j2.IsToggled && ValuePari.IsToggled && j1.IsToggled)
{
j1.IsToggled = false;
}
mgr.Value1 = ValuePari.IsToggled;
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
/**
* @brief Handles the event when the toggle switch for j2 is toggled.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void j2_Toggled(object sender, ToggledEventArgs e)
{
if (j2.IsToggled && !ValuePari.IsToggled || j2.IsToggled && ValuePari.IsToggled && j1.IsToggled)
{
j2.IsToggled = false;
}
mgr.Value1 = ValuePari.IsToggled;
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
}

@ -1,46 +1,30 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Pari.Parier">
x:Class="ParionsCuite.Views.Pari.Parier"
xmlns:AjoutINfo="clr-namespace:ParionsCuite.Views.Pari">
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
<Button Text="Invité" />
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
<Button Text="Information" Grid.Column="3" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="10*"/>
</Grid.ColumnDefinitions>
<Button Text="Ajouter Pari" Grid.Column="0" Clicked="SwitchView"/>
<Grid Grid.Column="1" ColumnDefinitions="auto" x:Name="GridPari">
</Grid>
</Grid>
<!--Grid Pari-->
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
<Button Text="Pari 1" BackgroundColor="Grey" />
<Button Text="Pari 2" Grid.Column="1"/>
<Button Text="Pari 3" Grid.Column="2" />
<Button Text="Ajouter Pari" Grid.Column="3" Margin="50,0,0,0"/>
</Grid>
<!--P1 vs P2-->
<Grid ColumnDefinitions="2*,*,2*,2*,*,2*">
<Button Text="Parieur 1" Margin="40,0,0,0"/>
<Button Text="+" Grid.Column="1"/>
<Label Text="Contre" Grid.Column="2" HorizontalOptions="Center" FontAttributes="Bold" FontSize="Title"/>
<Button Text="Parieur 2" Grid.Column="3" />
<Button Text="+" Grid.Column="4"/>
<Button Text="Supprimer Pari" Grid.Column="5" Margin="50,0,0,0"/>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition/>
</Grid.RowDefinitions>
<ContentView x:Name="changeButton" >
</ContentView>
</Grid>
<!--Info Pari-->
<TableView RowHeight="70" Margin="30,0,0,0" HorizontalOptions="Start" WidthRequest="1000">
<TableRoot>
<TableSection>
<EntryCell Label="But du Pari"/>
<EntryCell Label="Enjeux du Pari"/>
<SwitchCell Text="Pari terminé" On="False" />
<SwitchCell Text="Joueur(s) 1 gagnant" On="True" />
<SwitchCell Text="Joueur(s) 2 gagnant" On="True" />
</TableSection>
</TableRoot>
</TableView>
</VerticalStackLayout>
</ContentView>

@ -1,9 +1,103 @@
namespace ParionsCuite.Views.Pari;
using System;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Platform;
using Microsoft.VisualBasic;
using ParionsCuite.Modeles;
using ParionsCuite.Views.Information;
using ParionsCuite.Views.Invite;
using ParionsCuite;
using ParionsCuite.Views.Participations.Autre;
using System.Diagnostics;
namespace ParionsCuite.Views.Pari;
/**
* @brief Represents a ContentView for managing bets (Parier) related to a specific event (Evenement).
*/
public partial class Parier : ContentView
{
public Parier()
{
InitializeComponent();
}
}
public Manageur mgr => (App.Current as App).MyManager;
readonly Evenement EventSelect;
Parier PariSelect { get; set; }
/**
* @brief Initializes a new instance of the Parier class.
* @param EventSelect The selected event (Evenement).
*/
public Parier(Evenement EventSelect)
{
InitializeComponent();
this.EventSelect = EventSelect;
restorePari(EventSelect);
EventSelect.PariAdd += OnPariAdded;
}
/**
* @brief Restores the display of bets (Parier) for the selected event (Evenement).
* @param EventSelect The selected event (Evenement).
*/
private void restorePari(Evenement EventSelect)
{
int len = 0;
Debug.WriteLine("Taille Liste Pari" + EventSelect.ListParier);
foreach (Modeles.Parier pari in EventSelect.ListParier)
{
Debug.WriteLine("But du Pari" + pari.i2.Prenom);
ColumnDefinition column = new ColumnDefinition();
GridPari.ColumnDefinitions.Insert(len, column);
Button button = new Button();
button.Text = "Pari " + (len + 1);
Grid.SetRow(button, 0);
Grid.SetColumn(button, len);
GridPari.Children.Add(button);
len++;
button.Clicked += (sender, e) =>
{
var newPage = new Views.Pari.InfoPAri(pari);
changeButton.Content = newPage;
};
}
}
/**
* @brief Event handler for the PariAdd event of the selected event (Evenement).
* @param obj The added bet (Modeles.Parier) object.
*/
private void OnPariAdded(Modeles.Parier obj)
{
int pariCount = GridPari.ColumnDefinitions.Count - 1;
ColumnDefinition column = new ColumnDefinition();
GridPari.ColumnDefinitions.Insert(pariCount + 1, column);
Button button = new Button();
button.Text = "Pari " + (pariCount + 1);
Grid.SetRow(button, 0);
Grid.SetColumn(button, pariCount + 1);
GridPari.Children.Add(button);
button.Clicked += (sender, e) =>
{
Debug.WriteLine(obj.But);
var newPage = new Views.Pari.InfoPAri(obj);
changeButton.Content = newPage;
};
mgr.Save_Data();
}
/**
* @brief Event handler for the SwitchView button.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void SwitchView(object sender, EventArgs e)
{
var newPage = new Views.Ajout_Paris.Ajouts_Pari(EventSelect);
changeButton.Content = newPage;
}
}

@ -2,53 +2,35 @@
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Participations.Autre.Autres">
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
<Button Text="Invité" />
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
<Button Text="Information" Grid.Column="3" />
</Grid>
<!--Grid Participation-->
<Grid ColumnDefinitions="*,*,*">
<Button Text="Nourriture" />
<Button Text="Boisson" Grid.Column="1" />
<Button Text="Autre" Grid.Column="2" BackgroundColor="Grey" />
</Grid>
<Grid ColumnDefinitions="5*, 1*, 5*">
<!--Grid Pincipale-->
<Grid ColumnDefinitions="*,*,*">
<!--Input des boissons et quantité-->
<!--Input des nourritures et quantité-->
<StackLayout Grid.Column="0" >
<Entry Text="Entrer autre" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Text="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
<Entry Placeholder="Entrer l'objet" x:Name="AutreInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer quantité" Keyboard="Numeric" x:Name="QteInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AddAutrelist"/>
</StackLayout>
<!--Grid quantité et boisson + output -->
<Grid Grid.Column="1" Margin="30">
<!--Grid quantité et nourrite + output -->
<Grid Grid.Column="2" x:Name="GridAutre">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto" x:Name="sup"/>
</Grid.RowDefinitions>
<!--Header Grille quantité+boisson-->
<Label Text="Quantité" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Autre" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<!--Header Grille quantité+nourritre-->
<Label Text="Objet" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<!--Content Grille quantité+boisson-->
<Label Text="Tire bouchon" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
<Label Text="1" Grid.Column="1" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
</Grid>
</Grid>

@ -1,9 +1,203 @@
namespace ParionsCuite.Views.Participations.Autre;
using ParionsCuite.Modeles;
using ParionsCuite.Views.Participations;
using System.Diagnostics;
namespace ParionsCuite.Views.Participations.Autre;
/**
* @brief Autres Class
*
* Represents a ContentView for displaying and managing "Autres" data related to an event.
*/
public partial class Autres : ContentView
{
public Autres()
{
InitializeComponent();
}
readonly Evenement EventSelect;
/**
* @brief Gets the instance of the Manageur class.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Autres Constructor
*
* Initializes a new instance of the Autres class with the specified event.
*
* @param EventSelect The selected event.
*/
public Autres(Evenement EventSelect)
{
this.EventSelect = EventSelect;
InitializeComponent();
restoreListAutre(EventSelect);
BindingContext = this;
}
/**
* @brief Restores the list of "Autres" for the selected event.
*
* This method restores and displays the list of "Autres" (other items) associated with the selected event.
*
* @param EventSelect The selected event.
*/
public void restoreListAutre(Evenement EventSelect)
{
List<Modeles.Autre> listAutre = EventSelect.Participation.Autre;
Debug.WriteLine("TEst " + listAutre.Count());
int len = 1;
foreach (Modeles.Autre food in listAutre)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridAutre.RowDefinitions.Add(row);
// Ajout Nourriture
Label AutreLabel = new Label();
AutreLabel.Text = food.Nom.ToString();
Debug.WriteLine(AutreLabel);
Grid.SetRow(AutreLabel, len);
Grid.SetColumn(AutreLabel, 0);
GridAutre.Children.Add(AutreLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridAutre.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridAutre.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
/**
* @brief Event handler for adding an "Autre" item to the list.
*
* This method is called when the "Add" button is clicked.
* It retrieves the entered "Autre" item and quantity, creates a new Autre object, adds it to the event's Participation.Autre list,
* and updates the UI to display the added item.
*/
private void AddAutrelist(object sender, EventArgs e)
{
//restoreListInvite();
string autre = AutreInput.Text;
string qte = QteInput.Text;
if (int.TryParse(qte, out int value))
{
if (autre == null || qte == null) { return; }
Modeles.Autre autre1 = new Modeles.Autre(autre, Int32.Parse(qte));
EventSelect.Participation.Autre.Add(autre1);
int len = 1;
//if (len == 0 ) { len = 1; }
foreach (Modeles.Autre autre2 in EventSelect.Participation.Autre)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridAutre.RowDefinitions.Add(row);
// AJout Nourriture
Label AutreLabel = new Label();
AutreLabel.Text = autre2.Nom;
Grid.SetRow(AutreLabel, len);
Grid.SetColumn(AutreLabel, 0);
GridAutre.Children.Add(AutreLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = autre2.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridAutre.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridAutre.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
mgr.Save_Data();
}
else
{
//await DisplayAlert("esv", "efds", "OK");
return;
}
}
/**
* @brief Event handler for removing an "Autre" item from the list.
*
* This method is called when the "-" button is clicked.
* It identifies the clicked button's parent grid, determines the row index of the clicked button,
* finds the corresponding labels in that row, removes the "Autre" item from the event's Participation.Autre list,
* and updates the UI by removing the associated UI elements for that row.
*/
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
{
// Récupérer le bouton cliqué
Button button = (Button)sender;
// Récupérer la grille parente du bouton
Grid parentGrid = (Grid)button.Parent;
// Récupérer la ligne parente du bouton
int rowIndex = Grid.GetRow(button);
// Vérifier que l'indice rowIndex est valide
Label AutreLabel = null;
Label qteLabel = null;
// Parcourir les enfants de la grille pour trouver les labels de la ligne
foreach (View child in parentGrid.Children)
{
int childRowIndex = Grid.GetRow(child);
if (childRowIndex == rowIndex)
{
if (Grid.GetColumn(child) == 0)
AutreLabel = (Label)child;
else if (Grid.GetColumn(child) == 1)
qteLabel = (Label)child;
}
}
if (AutreLabel != null && qteLabel != null)
{
// Récupérer le prénom et le nom de l'invité à supprimer
string nom = AutreLabel.Text;
string qte = qteLabel.Text;
// Rechercher l'invité correspondant dans la liste
Modeles.Autre autre = EventSelect.Participation.Autre.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
if (autre != null)
{
// Supprimer l'invité de la liste
EventSelect.Participation.Autre.Remove(autre);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(AutreLabel);
parentGrid.Children.Remove(qteLabel);
parentGrid.Children.Remove(button);
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
mgr.Save_Data();
}
}

@ -1,63 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Participations.Boisson.Boissons">
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button Text="Invité" />
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
<Button Text="Information" Grid.Column="3" />
</Grid>
<!--Grid Participation-->
<Grid ColumnDefinitions="*,*,*">
<Button Text="Nourriture" />
<Button Text="Boisson" Grid.Column="1" BackgroundColor="Grey"/>
<Button Text="Autre" Grid.Column="2" />
</Grid>
<!--Grid Pincipale-->
<Grid ColumnDefinitions="*,*,*">
<!--Input des boissons et quantité-->
<StackLayout Grid.Column="0" >
<Entry Text="Entrer boisson" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Text="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
</StackLayout>
<!--Grid quantité et boisson + output -->
<Grid Grid.Column="2" Margin="30">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--Header Grille quantité+boisson-->
<Label Text="Boisson" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<!--Content Grille quantité+boisson-->
<Label Text="Vodka" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
<Label Text="2" Grid.Column="1" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
</Grid>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -1,9 +0,0 @@
namespace ParionsCuite.Views.Participations.Boisson;
public partial class Boissons : ContentView
{
public Boissons()
{
InitializeComponent();
}
}

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Participations.Boisson.Drink">
<VerticalStackLayout>
<Grid ColumnDefinitions="5*, 1*, 5*">
<!--Input des nourritures et quantité-->
<StackLayout Grid.Column="0" >
<Entry Placeholder="Entrer Boisson" x:Name="DrinkInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer quantité" Keyboard="Numeric" x:Name="QteInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AddDrinklist"/>
</StackLayout>
<!--Grid quantité et nourrite + output -->
<Grid Grid.Column="2" x:Name="GridDrink">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto" x:Name="sup"/>
</Grid.RowDefinitions>
<!--Header Grille quantité+nourritre-->
<Label Text="Boisson" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
</Grid>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -0,0 +1,198 @@
using ParionsCuite.Modeles;
using ParionsCuite.Views.Participations;
using System.Diagnostics;
namespace ParionsCuite.Views.Participations.Boisson;
/**
* @brief Represents the view for managing drinks in an event.
*
* This class is a ContentView that displays the list of drinks for a specific event.
*/
public partial class Drink : ContentView
{
readonly Evenement EventSelect;
/**
* @brief Gets the instance of the Manageur class from the application's current instance.
*/
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Initializes a new instance of the Drink class.
*
* @param EventSelect The selected event for which the drink list is displayed.
*/
public Drink(Evenement EventSelect)
{
this.EventSelect = EventSelect;
InitializeComponent();
restoreListBoisson(EventSelect);
BindingContext = this;
}
/**
* @brief Restores the list of drinks for the specified event and updates the UI to display the drinks.
*
* @param EventSelect The event for which the drink list is restored.
*/
public void restoreListBoisson(Evenement EventSelect)
{
List<Modeles.Boisson> listDrink = EventSelect.Participation.Boissons;
Debug.WriteLine("TEst " + listDrink.Count());
int len = 1;
foreach (Modeles.Boisson food in listDrink)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridDrink.RowDefinitions.Add(row);
// AJout Nourriture
Label DrinkLabel = new Label();
DrinkLabel.Text = food.Nom;
Grid.SetRow(DrinkLabel, len);
Grid.SetColumn(DrinkLabel, 0);
GridDrink.Children.Add(DrinkLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridDrink.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridDrink.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
/**
* @brief Event handler for adding a new drink to the list.
*
* This method is triggered when the "Add" button is clicked. It retrieves the drink name and quantity from the input fields,
* creates a new instance of the Modeles.Boisson class, adds it to the drink list of the selected event, and updates the UI to display the new drink.
*
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void AddDrinklist(object sender, EventArgs e)
{
string drink = DrinkInput.Text;
string qte = QteInput.Text;
if (int.TryParse(qte, out int value))
{
if (drink == null || qte == null) { return; }
Modeles.Boisson drink1 = new Modeles.Boisson(drink, Int32.Parse(qte));
EventSelect.Participation.Boissons.Add(drink1);
int len = 1;
foreach (Modeles.Boisson food2 in EventSelect.Participation.Boissons)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridDrink.RowDefinitions.Add(row);
// AJout Nourriture
Label DrinkLabel = new Label();
DrinkLabel.Text = food2.Nom;
Grid.SetRow(DrinkLabel, len);
Grid.SetColumn(DrinkLabel, 0);
GridDrink.Children.Add(DrinkLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food2.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridDrink.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridDrink.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
else
{
return;
}
mgr.Save_Data();
}
/**
* @brief Event handler for removing a drink from the list.
*
* This method is triggered when the "-" button next to a drink is clicked. It retrieves the selected drink's name and quantity,
* searches for the corresponding Modeles.Boisson object in the drink list of the selected event, removes it from the list,
* and updates the UI to reflect the changes.
*
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
{
// Récupérer le bouton cliqué
Button button = (Button)sender;
// Récupérer la grille parente du bouton
Grid parentGrid = (Grid)button.Parent;
// Récupérer la ligne parente du bouton
int rowIndex = Grid.GetRow(button);
// Vérifier que l'indice rowIndex est valide
Label DrinkLabel = null;
Label qteLabel = null;
// Parcourir les enfants de la grille pour trouver les labels de la ligne
foreach (View child in parentGrid.Children)
{
int childRowIndex = Grid.GetRow(child);
if (childRowIndex == rowIndex)
{
if (Grid.GetColumn(child) == 0)
DrinkLabel = (Label)child;
else if (Grid.GetColumn(child) == 1)
qteLabel = (Label)child;
}
}
if (DrinkLabel != null && qteLabel != null)
{
// Récupérer le prénom et le nom de l'invité à supprimer
string nom = DrinkLabel.Text;
string qte = qteLabel.Text;
// Rechercher l'invité correspondant dans la liste
Modeles.Boisson drink = EventSelect.Participation.Boissons.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
if (drink != null)
{
// Supprimer l'invité de la liste
EventSelect.Participation.Boissons.Remove(drink);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(DrinkLabel);
parentGrid.Children.Remove(qteLabel);
parentGrid.Children.Remove(button);
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
mgr.Save_Data();
}
}

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Participations.NewFolder1.Nourri">
<VerticalStackLayout>
<Grid ColumnDefinitions="5*, 1*, 5*">
<!--Input des nourritures et quantité-->
<StackLayout Grid.Column="0" >
<Entry Placeholder="Entrer nourriture" x:Name="FoodInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Placeholder="Entrer quantité" Keyboard="Numeric" x:Name="QteInput" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0" Clicked="AddFoodlist"/>
</StackLayout>
<!--Grid quantité et nourrite + output -->
<Grid Grid.Column="2" x:Name="GridFood">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto" x:Name="sup"/>
</Grid.RowDefinitions>
<!--Header Grille quantité+nourritre-->
<Label Text="Nourriture" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="{Binding Nom}" Grid.Column="1" Grid.Row="1" FontSize="Large"/>
<Label Text="{Binding Quantite}" Grid.Row="1" FontSize="Large"/>
</Grid>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -0,0 +1,164 @@
using ParionsCuite.Modeles;
using ParionsCuite.Views.Participations;
using System.Diagnostics;
namespace ParionsCuite.Views.Participations.NewFolder1;
/**
* @brief Represents a ContentView for managing food items (Nourriture) related to a specific event (Evenement).
*/
public partial class Nourri : ContentView
{
readonly Evenement EventSelect;
public Manageur mgr => (App.Current as App).MyManager;
/**
* @brief Initializes a new instance of the Nourri class.
* @param EventSelect The selected event (Evenement).
*/
public Nourri(Evenement EventSelect)
{
this.EventSelect = EventSelect;
InitializeComponent();
restoreListFood(EventSelect);
BindingContext = this;
}
/**
* @brief Restores the display of food items (Nourriture) for the selected event (Evenement).
* @param EventSelect The selected event (Evenement).
*/
public void restoreListFood(Evenement EventSelect)
{
List<Modeles.Nourriture> listFood = EventSelect.Participation.Nourriture;
Debug.WriteLine("TEst " + listFood.Count());
int len = 1;
foreach (Modeles.Nourriture food in listFood)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridFood.RowDefinitions.Add(row);
Label foodLabel = new Label();
foodLabel.Text = food.Nom.ToString();
Debug.WriteLine(foodLabel);
Grid.SetRow(foodLabel, len);
Grid.SetColumn(foodLabel, 0);
GridFood.Children.Add(foodLabel);
Label qteLabel = new Label();
qteLabel.Text = food.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridFood.Children.Add(qteLabel);
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridFood.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
/**
* @brief Event handler for the AddFoodlist button.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void AddFoodlist(object sender, EventArgs e)
{
string food = FoodInput.Text;
string qte = QteInput.Text;
if (int.TryParse(qte, out int value))
{
if (food == null || qte == null) { return; }
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
EventSelect.Participation.Nourriture.Add(food1);
int len = 1;
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridFood.RowDefinitions.Add(row);
Label foodLabel = new Label();
foodLabel.Text = food2.Nom;
Grid.SetRow(foodLabel, len);
Grid.SetColumn(foodLabel, 0);
GridFood.Children.Add(foodLabel);
Label qteLabel = new Label();
qteLabel.Text = food2.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridFood.Children.Add(qteLabel);
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins, 2);
GridFood.Children.Add(buttonMoins);
len++;
Debug.WriteLine("Test test");
}
}
else
{
return;
}
mgr.Save_Data();
}
/**
* @brief Event handler for the BoutonSupprimer_Clicked event.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void BoutonSupprimer_Clicked(object sender, EventArgs e)
{
Button button = (Button)sender;
Grid parentGrid = (Grid)button.Parent;
int rowIndex = Grid.GetRow(button);
Label foodLabel = null;
Label qteLabel = null;
foreach (View child in parentGrid.Children)
{
int childRowIndex = Grid.GetRow(child);
if (childRowIndex == rowIndex)
{
if (Grid.GetColumn(child) == 0)
foodLabel = (Label)child;
else if (Grid.GetColumn(child) == 1)
qteLabel = (Label)child;
}
}
if (foodLabel != null && qteLabel != null)
{
string nom = foodLabel.Text;
string qte = qteLabel.Text;
Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
if (nourriture != null)
{
EventSelect.Participation.Nourriture.Remove(nourriture);
parentGrid.Children.Remove(foodLabel);
parentGrid.Children.Remove(qteLabel);
parentGrid.Children.Remove(button);
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
mgr.Save_Data();
}
}

@ -1,58 +1,45 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="ParionsCuite.Views.Participations.Nourriture">
xmlns:model="clr-namespace:ParionsCuite.Modeles"
x:Class="ParionsCuite.Views.Participations.Nourriture"
xmlns:nourriture="clr-namespace:ParionsCuite.Views.Participations.NewFolder1"
>
<VerticalStackLayout>
<!--Grid menu-->
<Grid Margin="20" ColumnDefinitions="*,*,*,*">
<Button Text="Invité" />
<Button Text="Participant" Grid.Column="1"/>
<Button Text="Pari" Grid.Column="2" BackgroundColor="Grey"/>
<Button Text="Information" Grid.Column="3" />
</Grid>
<!--Grid Participation-->
<Grid ColumnDefinitions="*,*,*">
<Button Text="Nourriture" BackgroundColor="Grey" />
<Button Text="Boisson" Grid.Column="1"/>
<Button Text="Autre" Grid.Column="2" />
</Grid>
<!--Grid Pincipale-->
<Grid ColumnDefinitions="5*, 1*, 5*">
<!--Input des nourritures et quantité-->
<StackLayout Grid.Column="0" >
<Entry Text="Entrer nourriture" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Entry Text="Entrer quantité" HorizontalOptions="End" FontSize="Large" Margin="0,20,0,0" />
<Button Text="Ajouter" HorizontalOptions="Center" Margin="0,20,0,0"/>
</StackLayout>
<!--Grid quantité et nourrite + output -->
<Grid Grid.Column="2" Margin="30">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="300"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="2*" />
<ColumnDefinition Width="*"/>
<ColumnDefinition />
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button Text="Nourriture" BackgroundColor="Grey" Clicked="NourritureView" />
<Button Text="Boisson" Grid.Column="1" Clicked="BoissonView"/>
<Button Text="Autre" Grid.Column="2" Clicked="AutreView" />
</Grid>
<!--Grid Participation-->
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<ContentView x:Name="changeButton" >
</ContentView>
</Grid>
</Grid>
<!--Header Grille quantité+nourritre-->
<Label Text="Nourriture" Grid.Column="1" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Text="Quantité" Grid.Column="0" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<Label Grid.Column="2" Grid.Row="0" BackgroundColor="LightGrey" FontSize="Large"/>
<!--Content Grille quantité+nourritre-->
<Label Text="Pizza" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
<Label Text="2" Grid.Column="1" Grid.Row="1" FontSize="Large" HorizontalOptions="Center"/>
<Button Text="-" Grid.Row="1" Grid.Column="2"/>
</Grid>
</Grid>
</VerticalStackLayout>
</ContentView>

@ -1,9 +1,65 @@
namespace ParionsCuite.Views.Participations;
using ParionsCuite.Modeles;
using ParionsCuite.Views.Participations;
namespace ParionsCuite.Views.Participations;
/**
* @brief Represents a ContentView for managing food-related actions.
*/
public partial class Nourriture : ContentView
{
public Nourriture()
{
InitializeComponent();
}
public Manageur mgr => (App.Current as App).MyManager;
Evenement EventSelect;
/**
* @brief Initializes a new instance of the Nourriture class.
* @param EventSelect The selected event (Evenement).
*/
public Nourriture(Evenement EventSelect)
{
InitializeComponent();
this.EventSelect = EventSelect;
}
/**
* @brief Event handler for the NourritureView button.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void NourritureView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.NewFolder1.Nourri(EventSelect);
changeButton.Content = newPage;
}
/**
* @brief Event handler for the BoissonView button.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void BoissonView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.Boisson.Drink(EventSelect);
changeButton.Content = newPage;
}
/**
* @brief Event handler for the AutreView button.
* @param sender The object that raised the event.
* @param e The event arguments.
*/
private void AutreView(object sender, EventArgs e)
{
if (EventSelect == null) { return; }
var newPage = new Views.Participations.Autre.Autres(EventSelect);
changeButton.Content = newPage;
}
}

@ -0,0 +1,39 @@
using ParionsCuite.Modeles;
namespace TestParionsCuite
{
public class TestAutre
{
[Fact]
public void TestAutreConstructor()
{
// Arrange
string nom = "chaise";
int quantite = 15;
// Act
Autre autre = new Autre(nom, quantite);
// Assert
Assert.Equal(nom, autre.Nom);
Assert.Equal(quantite, autre.Quantite);
}
[Fact]
public void TestAutreToString()
{
// Arrange
Autre autre = new Autre("chaise", 15);
string expectedToString = "nom : chaise \n";
// Act
string actualToString = autre.ToString();
// Assert
Assert.Equal(expectedToString, actualToString);
}
}
}

@ -0,0 +1,42 @@
using ParionsCuite.Modeles;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestParionsCuite
{
public class TestBoissons
{
[Fact]
public void TestBoissonEquals()
{
// Arrange
Boisson boisson1 = new Boisson("Coca-Cola", 10);
Boisson boisson2 = new Boisson("Coca-Cola", 10);
Boisson boisson3 = new Boisson("Pepsi", 5);
Assert.Equal(boisson1, boisson2);
Assert.NotEqual(boisson1, boisson3);
Assert.NotEqual(boisson2, boisson3);
}
[Fact]
public void TestBoissonToString()
{
// Arrange
Boisson boisson = new Boisson("Sprite", 7);
string expectedToString = "nom : Sprite \n";
// Act
string actualToString = boisson.ToString();
// Assert
Assert.Equal(expectedToString, actualToString);
}
}
}

@ -0,0 +1,39 @@
using ParionsCuite.Modeles;
namespace TestParionsCuite
{
public class TestInviter
{
[Fact]
public void TestInviterConstructor()
{
// Arrange
string nom = "Muzard";
string prenom = "Thomas";
// Act
Inviter i1 = new Inviter(nom, prenom);
// Assert
Assert.Equal(nom, i1.Nom);
Assert.Equal(prenom, i1.Prenom);
}
[Fact]
public void TestAutreToString()
{
// Arrange
Inviter i1 = new Inviter("Fages", "Tony");
string expectedToString = "nom : Fages, prenom : Tony \n";
// Act
string actualToString = i1.ToString();
// Assert
Assert.Equal(expectedToString, actualToString);
}
}
}

@ -0,0 +1,90 @@
using ParionsCuite.Modeles;
namespace TestParionsCuite
{
public class TestManageur
{
[Fact]
public void TestAjoutEvenement()
{
// Arrange
Manageur manageur = new Manageur();
Evenement evenement = new Evenement("EventName", "2023-06-10", "EventLocation", "EventTime", null);
// Act
bool result = manageur.Ajout_evenement(evenement);
// Assert
Assert.True(result);
Assert.Contains(evenement, manageur.Evenement);
}
[Fact]
public void TestSupprimerEvenement()
{
// Arrange
Manageur manageur = new Manageur();
Evenement evenement = new Evenement("EventName", "2023-06-10", "EventLocation", "EventTime", null);
manageur.Ajout_evenement(evenement);
// Act
bool result = manageur.Supprimer_evenement(evenement);
// Assert
Assert.True(result);
Assert.DoesNotContain(evenement, manageur.Evenement);
}
[Fact]
public void TestAddInvite()
{
// Arrange
Manageur manageur = new Manageur();
Inviter invite1 = new Inviter("John");
Inviter invite2 = new Inviter("Jane");
// Act
manageur.AddInvite(invite1);
manageur.AddInvite(invite2);
// Assert
Assert.Contains(invite1, manageur.Invites);
Assert.Contains(invite2, manageur.Invites);
}
[Fact]
public void TestRemoveInviter()
{
// Arrange
Manageur manageur = new Manageur();
Inviter invite1 = new Inviter("John");
Inviter invite2 = new Inviter("Jane");
manageur.AddInvite(invite1);
manageur.AddInvite(invite2);
// Act
manageur.RemoveInviter(invite1);
// Assert
Assert.DoesNotContain(invite1, manageur.Invites);
Assert.Contains(invite2, manageur.Invites);
}
[Fact]
public void TestLenListInvite()
{
// Arrange
Manageur manageur = new Manageur();
Inviter invite1 = new Inviter("John");
Inviter invite2 = new Inviter("Jane");
manageur.AddInvite(invite1);
manageur.AddInvite(invite2);
// Act
int len = manageur.LenListInvite(manageur.Invites);
// Assert
Assert.Equal(2, len);
}
}
}

@ -0,0 +1,39 @@
using ParionsCuite.Modeles;
namespace TestParionsCuite
{
public class TestNourriture
{
[Fact]
public void TestNourritureConstructor()
{
// Arrange
string nom = "chaise";
int quantite = 15;
// Act
Nourriture autre = new Nourriture(nom, quantite);
// Assert
Assert.Equal(nom, autre.Nom);
Assert.Equal(quantite, autre.Quantite);
}
[Fact]
public void TestNourritureToString()
{
// Arrange
Nourriture nourriture = new Nourriture("chaise", 15);
string expectedToString = "nom : chaise \n";
// Act
string actualToString = nourriture.ToString();
// Assert
Assert.Equal(expectedToString, actualToString);
}
}
}

@ -0,0 +1,48 @@
using ParionsCuite.Modeles;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestParionsCuite
{
public class TestPari
{
[Fact]
public void TestParierToString()
{
// Arrange
Inviter i1 = new Inviter("John");
Inviter i2 = new Inviter("Jane");
string but = "Who will score the first goal?";
string enjeu = "50 dollars";
Parier parier = new Parier(i1, i2, but, enjeu);
string expectedToString = "joueur n°1 : John, \njoueur n°2 : Jane, \nbut : Who will score the first goal?, enjeux : 50 dollars";
// Act
string actualToString = parier.ToString();
// Assert
Assert.Equal(expectedToString, actualToString);
}
[Fact]
public void TestParierEquals()
{
// Arrange
Inviter i1 = new Inviter("John");
Inviter i2 = new Inviter("Jane");
string but = "Who will score the first goal?";
string enjeu = "50 dollars";
Parier parier1 = new Parier(i1, i2, but, enjeu);
Parier parier2 = new Parier(i1, i2, but, enjeu);
Parier parier3 = new Parier(i2, i1, but, enjeu);
// Act & Assert
Assert.NotEqual(parier1, parier3);
Assert.NotEqual(parier2, parier3);
}
}
}

@ -0,0 +1,53 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SSDTUnitTestPath Condition="'$(SSDTUnitTestPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB</SSDTUnitTestPath>
</PropertyGroup>
<PropertyGroup>
<SSDTPath Condition="'$(SSDTPath)' == ''">$(VsInstallRoot)\Common7\IDE\Extensions\Microsoft\SQLDB\DAC</SSDTPath>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Modeles\Modeles.csproj" />
</ItemGroup>
<ItemGroup />
<ItemGroup Condition="$(VisualStudioVersion) == '17.0'">
<Reference Include="Microsoft.Data.Tools.Schema.Sql, Version=16.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTPath)\Microsoft.Data.Tools.Schema.Sql.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTesting, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>$(SSDTUnitTestPath)\Microsoft.Data.Tools.Schema.Sql.UnitTestingAdapter.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<PropertyGroup>
<SsdtUnitTestVersion>3.1</SsdtUnitTestVersion>
</PropertyGroup>
<Import Project="$(SQLDBExtensionsRefPath)\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\SSDT\Microsoft.Data.Tools.Schema.Sql.UnitTesting.targets" Condition="$(VisualStudioVersion) != '15.0' And '$(SQLDBExtensionsRefPath)' == ''" />
</Project>

@ -0,0 +1,116 @@
using ParionsCuite.Modeles;
namespace TestParionsCuite
{
public class TestParticipation
{
[Fact]
public void TestAjoutNourriture()
{
// Arrange
Participation p1 = new Participation();
Nourriture n = new Nourriture("Chips", 2);
// Act
bool result = p1.Ajout_Nourriture(n);
// Assert
Assert.True(result);
Assert.Contains(n, p1.Nourriture);
}
[Fact]
public void TestSupprimerNourriture()
{
// Arrange
Participation p1 = new Participation();
Nourriture n = new Nourriture("Chips", 2);
bool test = p1.Ajout_Nourriture(n);
Nourriture food = new Nourriture("Tomate", 1);
// Act
bool result = p1.Sup_Nourriture(n,1);
// Assert
Assert.True(test);
Assert.True(result);
Assert.Contains(n, p1.Nourriture);
Assert.DoesNotContain(food, p1.Nourriture);
}
[Fact]
public void TestAjoutBoisson()
{
// Arrange
Participation p1 = new Participation();
Boisson b = new Boisson("Limonade", 2);
// Act
bool result = p1.Ajout_Boissons(b);
// Assert
Assert.True(result);
Assert.Contains(b, p1.Boissons);
}
[Fact]
public void TestSupprimerBoisson()
{
// Arrange
Participation p1 = new Participation();
Boisson b = new Boisson("Limonade", 2);
bool test = p1.Ajout_Boissons(b);
Boisson drink = new Boisson("Coca", 1);
// Act
bool result = p1.Sup_Boissons(b, 1);
// Assert
Assert.True(test);
Assert.True(result);
Assert.DoesNotContain(drink, p1.Boissons);
Assert.Contains(b, p1.Boissons);
}
[Fact]
public void TestAjoutAutre()
{
// Arrange
Participation p1 = new Participation();
Autre a = new Autre("Chaise", 2);
// Act
bool result = p1.Ajout_Autre(a);
// Assert
Assert.True(result);
Assert.Contains(a, p1.Autre);
}
[Fact]
public void TestSupprimerAutre()
{
// Arrange
Participation p1 = new Participation();
Autre a = new Autre("Chaise", 2);
bool test = p1.Ajout_Autre(a);
Autre chose = new Autre("Chaise", 1);
// Act
bool result = p1.Sup_Autre(a, 1);
// Assert
Assert.True(test);
Assert.True(result);
Assert.DoesNotContain(chose, p1.Autre);
Assert.Contains(a, p1.Autre);
}
}
}

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.data>
<DbProviderFactories>
<add name="Microsoft SqlClient Data Provider"
invariant="Microsoft.Data.SqlClient"
description="Microsoft SqlClient Data Provider for SqlServer"
type="Microsoft.Data.SqlClient.SqlClientFactory, Microsoft.Data.SqlClient" />
</DbProviderFactories>
</system.data>
</configuration>
Loading…
Cancel
Save