Final_Appli
Tony Fages 2 years ago
parent ed80f4fec5
commit 3d6a787ec4

@ -1,28 +1,49 @@
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; }
public string Nom { get; set; }
/// <summary>
/// Gets or sets the quantity of the item.
/// </summary>
[DataMember]
public int Quantite { get; set; }
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;
@ -31,15 +52,22 @@ namespace ParionsCuite.Modeles
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);
}
}
}

@ -1,29 +1,50 @@
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; }
public string Nom { get; set; }
/// <summary>
/// Gets or sets the quantity of the beverage.
/// </summary>
[DataMember]
public int Quantite { get; set; }
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;
@ -32,15 +53,22 @@ namespace ParionsCuite.Modeles
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);
}
}
}

@ -12,33 +12,76 @@ 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));
/* Déclaration */
/* 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; }
@ -48,19 +91,24 @@ namespace ParionsCuite.Modeles
{
listParier = value;
OnPropertyChanged();
OnPariAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement
OnPariAdded(value.LastOrDefault());
}
}
}
/* Methods */
private void OnPariAdded(Parier parier)
private void OnPariAdded(Parier parier)
{
// Logique à exécuter lorsque un événement est ajouté
Debug.WriteLine("Événement ajouté : ");
// 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);
@ -68,8 +116,14 @@ namespace ParionsCuite.Modeles
PariAdd?.Invoke(pari);
return true;
}
/* Constructeur */
/// <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;
@ -80,6 +134,15 @@ namespace ParionsCuite.Modeles
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;
@ -91,12 +154,13 @@ namespace ParionsCuite.Modeles
ListParier = new ObservableCollection<Parier>();
}
public Evenement(List<Inviter> inviters, List<Participation> participations, List<Parier> pariers)
{
/* Inviter methods */
}
/* Méthode Inviter */
/// <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);
@ -108,11 +172,21 @@ namespace ParionsCuite.Modeles
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;
@ -123,12 +197,22 @@ namespace ParionsCuite.Modeles
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;
}
/* Méthode Parie */
/* 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);
@ -140,12 +224,25 @@ namespace ParionsCuite.Modeles
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 */
/* 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;
@ -155,6 +252,10 @@ namespace ParionsCuite.Modeles
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} ";

@ -2,12 +2,25 @@
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
{
public ObservableCollection<Evenement> chargeDonnees();
public void sauvegardeDonnees(ObservableCollection<Evenement> evenements);
/// <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);
}
}

@ -1,38 +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";
}
}
}

@ -11,19 +11,58 @@ 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; }
@ -33,38 +72,79 @@ namespace ParionsCuite.Modeles
{
evenement = value;
OnPropertyChanged();
OnEvenementAdded(value.LastOrDefault()); // Appel de la fonction après ajout d'un événement
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)
{
// Logique à exécuter lorsque un événement est ajouté
Debug.WriteLine("Événement ajouté : ");
// Logic to execute when an event is added
Debug.WriteLine("Event added: ");
}
public List<Inviter> Invites { get; set; }
public IPersistanceManager Persistance { get; set; }
/**
* @brief Gets or sets the list of invitees.
*/
public List<Inviter> Invites { get; set; }
public Manageur(IPersistanceManager Pers) {
/**
* @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;
}
public Manageur()
/**
* @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);
@ -73,23 +153,55 @@ namespace ParionsCuite.Modeles
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;
@ -100,13 +212,17 @@ namespace ParionsCuite.Modeles
return len;
}
public List<Inviter> ReturnListInvite()
{
return Invites;
}
/**
* @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)
{
@ -115,9 +231,16 @@ namespace ParionsCuite.Modeles
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);
}
}
}

@ -6,24 +6,42 @@ namespace ParionsCuite.Modeles
[DataContract]
public class Nourriture
{
/// <summary>
/// Gets or sets the name of the food.
/// </summary>
[DataMember]
public string Nom { get; set; }
public string Nom { get; set; }
/// <summary>
/// Gets or sets the quantity of the food.
/// </summary>
[DataMember]
public int Quantite { get; set; }
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;
@ -32,15 +50,22 @@ namespace ParionsCuite.Modeles
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);
}
}
}

@ -8,18 +8,40 @@ using System.Threading.Tasks;
namespace ParionsCuite.Modeles
{
[DataContract]
public class Parier
public class Parier
{
/// <summary>
/// Gets or sets the first player involved in the bet.
/// </summary>
[DataMember]
public Inviter i1;
public Inviter i1 { get; set; }
/// <summary>
/// Gets or sets the second player involved in the bet.
/// </summary>
[DataMember]
public Inviter i2;
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; }
public Parier(Inviter i1, Inviter i2, string but, string enjeu)
/// <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;
@ -27,6 +49,10 @@ namespace ParionsCuite.Modeles
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}, \njoueur n°2 : {i2}, \nbut : {But}, enjeux : {Enjeu}";

@ -15,28 +15,44 @@ namespace ParionsCuite.Modeles
{
[DataMember]
public List<Boisson> Boissons { get; private set; }
[DataMember]
public List<Nourriture> Nourriture { get; private set; }
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;
}
/// <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>();
}
/* Boisson */
public bool Ajout_Boissons(Boisson boisson)
/// <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)
{
@ -44,21 +60,28 @@ namespace ParionsCuite.Modeles
{
if (boisson.Quantite > 0)
{
obj.Quantite = obj.Quantite + boisson.Quantite;
obj.Quantite += boisson.Quantite;
return true;
}
return false;
}
}
Boissons.AddRange((IEnumerable<Boisson>)boisson);
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)
foreach (var obj in Boissons)
{
if (obj.Equals(boisson))
{
if (quantite > 0)
{
if (quantite >= boisson.Quantite)
@ -67,17 +90,22 @@ namespace ParionsCuite.Modeles
return true;
}
obj.Quantite = obj.Quantite + boisson.Quantite;
obj.Quantite -= quantite;
return true;
}
return false;
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)
@ -86,21 +114,28 @@ namespace ParionsCuite.Modeles
{
if (food.Quantite > 0)
{
obj.Quantite = obj.Quantite + food.Quantite;
obj.Quantite += food.Quantite;
return true;
}
return false;
}
}
Nourriture.AddRange((IEnumerable<Nourriture>)food);
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 Boissons)
foreach (var obj in Nourriture)
{
if (obj.Equals(food))
{
if (quantite > 0)
{
if (quantite >= food.Quantite)
@ -109,16 +144,22 @@ namespace ParionsCuite.Modeles
return true;
}
obj.Quantite = obj.Quantite + food.Quantite;
obj.Quantite -= quantite;
return true;
}
return false;
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)
@ -127,21 +168,28 @@ namespace ParionsCuite.Modeles
{
if (autre.Quantite > 0)
{
obj.Quantite = obj.Quantite + autre.Quantite;
obj.Quantite += autre.Quantite;
return true;
}
return false;
}
}
Autre.AddRange((IEnumerable<Autre>)autre);
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)
@ -150,13 +198,14 @@ namespace ParionsCuite.Modeles
return true;
}
obj.Quantite = obj.Quantite + autre.Quantite;
obj.Quantite -= quantite;
return true;
}
return false;
return false;
}
}
return false;
}
}
}

@ -2,21 +2,54 @@
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 Manageur MyManager { get; private set; } = new Manageur(new Stub.Stub());
/**
* @brief Gets or sets the file name for data persistence.
*/
public string FileName { get; set; } = "A_Save_Data.xml";
public Manageur MyManager { get; private set; } = new Manageur(new DataContractPersistance.DataContractPersistance());
/**
* @brief Gets or sets the file path for data persistence.
*/
public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory);
public App()
{
/**
* @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();
MyManager.Persistance = new DataContractPersistance.DataContractPersistance();
// 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();
}
}
}

@ -8,15 +8,35 @@ 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);
//public string FilePath2 { get; private set; } = Path.Combine(Directory.GetCurrentDirectory(), "//Doss1_XML");
/**
* @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>));
@ -29,7 +49,13 @@ namespace ParionsCuite.DataContractPersistance
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>));
@ -42,15 +68,15 @@ namespace ParionsCuite.DataContractPersistance
}
var settings = new XmlWriterSettings() { Indent = true };
using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName))) {
using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName)))
{
using (XmlWriter writer = XmlWriter.Create(tw, settings))
{
serializer.WriteObject(writer, evenements);
}
}
}
}
}

@ -8,8 +8,18 @@ using ParionsCuite.Modeles;
namespace ParionsCuite.DataContractPersistance
{
/**
* @brief DataToPersists Class
*
* Represents the data to be persisted.
*/
public class DataToPersists
{
public ObservableCollection<Evenement> e = new();
/**
* @brief Gets or sets the collection of events to persist.
*/
public ObservableCollection<Evenement> e { get; set; } = new ObservableCollection<Evenement>();
}
}

@ -11,76 +11,104 @@ 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
{
/**
* @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; }
/**
* @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 );
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) {
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) =>
{
// Appel de la méthode qui récupère l'événement associé
// Call the method that handles event selection
SelectEvent(ev);
var newPage = new Views.Accueil();
changeButton.Content = newPage;
};
// Ajout du bouton au ButtonStackLayout
// Add the button to the ButtonStackLayout
ButtonStackLayout.Children.Add(newButton); ;
}
mgr.Evenement = EventCharge;
Debug.WriteLine("Taille Event " + mgr.Evenement.Count());
//mgr.Save_Data();
}
/**
* @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)
{
// Logique à exécuter lorsque un événement est ajouté
Debug.WriteLine("Événement ajoutéz : " + evenement.Nom);
Button newButton = new Button
{
Text = evenement.Nom,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
};
Button newButton = new Button
{
Text = evenement.Nom,
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
};
newButton.Clicked += (sender, e) =>
{
// Appel de la méthode qui récupère l'événement associé
// Call the method that handles event selection
SelectEvent(evenement);
var newPage = new Views.Accueil();
changeButton.Content = newPage;
};
// Ajout du bouton au ButtonStackLayout
// Add the button to the ButtonStackLayout
ButtonStackLayout.Children.Add(newButton); ;
Debug.WriteLine("Taille Event " + mgr.Evenement.Count());
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);
@ -90,59 +118,62 @@ public partial class MainPage : ContentPage
EventSelect = evenement;
}
// Acces View Groupe
/**
* @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;
}
// Acces view Invite
/**
* @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;
}
// Acces view Participant
/**
* @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;
}
//Acces View Pari
/**
* @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;
}
// Acces View Information
/**
* @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;
}

@ -3,35 +3,46 @@ 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
{
public Stub()
{
}
/// <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 b = new("biere", 15);
boissons.Add(b);
Nourriture n = new("pain", 15);
nourritures.Add(n);
Autre a = new("chaise", 15);
autres.Add(a);
Participation p = new(boissons,nourritures, autres);
DateTime dt = new(2018, 7, 24);
Evenement e = new ("nom", "dt", "lieu", "12", p);
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();
}
}

@ -2,34 +2,51 @@
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
{
/**
* @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;
{
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);
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);
//EventSelect.ListParier.Add(newPari);
Modeles.Parier newPari = new Parier(NewParieur1, NewParieur2, but, enjeux);
Debug.WriteLine("PArieur ajouter" + newPari.But);
EventSelect.Ajout_Pari(newPari);
Debug.WriteLine("Taille Liste : " + EventSelect.ListParier.Count());
mgr.Save_Data();
}
}

@ -4,23 +4,46 @@ 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
{
/**
* @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>();
/**
* @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);
@ -36,6 +59,5 @@ public partial class Groupe : ContentView
{
Debug.WriteLine("Creation Event Error PLease Check!!!");
}
}
}
}

@ -3,36 +3,49 @@ 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
{
/**
* @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);
{
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)
{
//NomEvent.Detail = EventSelect.Nom;
//DateEvent.Detail = EventSelect.Date;
{
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;
AdresseEvent.Detail = EventSelect.Lieu;
HoraireEvent.Detail = EventSelect.Heure;
}
}
}

@ -2,41 +2,60 @@ 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
{
/**
* @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;
public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter();
/**
* @brief Gets or sets the Inviters object.
*/
public Modeles.Inviter Inviters { get; private set; } = new Modeles.Inviter();
/**
* @brief Initializes a new instance of the Inviter class.
* @param EventSelect The selected event.
*/
public Inviter(Evenement EventSelect)
{
{
this.EventSelect = EventSelect;
InitializeComponent();
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) {
foreach (Modeles.Inviter inviter in listInvite)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GrilleInvite.RowDefinitions.Add(row);
// AJout Prenom
// 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;
@ -44,8 +63,7 @@ public partial class Inviter : ContentView
Grid.SetColumn(nomLabel, 1);
GrilleInvite.Children.Add(nomLabel);
// Ajout Bouton
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -55,23 +73,22 @@ public partial class Inviter : ContentView
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)
{
//restoreListInvite();
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;
//if (len == 0 ) { len = 1; }
Debug.WriteLine("LA taille de la liste est de " + mgr.LenListInvite(EventSelect.ListInviter));
foreach (Modeles.Inviter inviter in EventSelect.ListInviter)
{
@ -79,14 +96,13 @@ public partial class Inviter : ContentView
row.Height = new GridLength(45);
GrilleInvite.RowDefinitions.Add(row);
// AJout Prenom
// 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;
@ -94,26 +110,27 @@ public partial class Inviter : ContentView
Grid.SetColumn(nomLabel, 1);
GrilleInvite.Children.Add(nomLabel);
// Ajout Bouton
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
Grid.SetRow(buttonMoins, len);
Grid.SetColumn(buttonMoins , 2);
GrilleInvite.Children.Add(buttonMoins );
//GrilleInvite.HeightRequest = Height + 2;
len = len +1 ;
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é

@ -3,35 +3,46 @@ 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;
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);
}
{
InitializeComponent();
this.PariSelect = PariSelect;
this.BindingContext = PariSelect;
MiseAJourInfo(PariSelect);
}
private void MiseAJourInfo(Modeles.Parier PariSelect)
{
//Debug.WriteLine("Pari Selectionner " + PariSelect);
Parieur1.Text = PariSelect.i1.Prenom;
/**
* @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;
//butPari.Text = PariSelect.But;
//enjeuxPari.Text = PariSelect.Enjeu;
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)
@ -43,11 +54,13 @@ public partial class InfoPAri : ContentView
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)
@ -58,9 +71,14 @@ public partial class InfoPAri : ContentView
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)
@ -71,11 +89,9 @@ public partial class InfoPAri : ContentView
mgr.Value2 = j1.IsToggled;
mgr.Value3 = j2.IsToggled;
Debug.WriteLine("Value " + mgr.Value2);
}
}

@ -10,13 +10,20 @@ 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 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();
@ -26,69 +33,71 @@ public partial class Parier : ContentView
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)
{
//if (EventSelect.ListParier.Count() == 0) { return; }
int len = 0;
Debug.WriteLine("Taille Liste Pari" + EventSelect.ListParier);
foreach(Modeles.Parier pari in 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); // Nommer le bouton en fonction du numéro de pari
button.Text = "Pari " + (len + 1);
Grid.SetRow(button, 0);
Grid.SetColumn(button, len); // Utiliser le numéro de colonne pour positionner le bouton dans la grille
Grid.SetColumn(button, len);
GridPari.Children.Add(button);
len++;
// Ajout du gestionnaire de pari au bouton
button.Clicked += (sender, e) =>
{
// Appel de la méthode qui récupère le pari associé
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; // Compter le nombre de colonnes déjà présentes (-1 pour ignorer la première colonne)
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); // Nommer le bouton en fonction du numéro de pari
button.Text = "Pari " + (pariCount + 1);
Grid.SetRow(button, 0);
Grid.SetColumn(button, pariCount + 1); // Utiliser le numéro de colonne pour positionner le bouton dans la grille
Grid.SetColumn(button, pariCount + 1);
GridPari.Children.Add(button);
// Ajout du gestionnaire de pari au bouton
button.Clicked += (sender, e) =>
{
// Appel de la méthode qui récupère le pari associé
Debug.WriteLine(obj.But);
var newPage = new Views.Pari.InfoPAri(obj);
changeButton.Content = newPage;
};
mgr.Save_Data();
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;
}
}
}

@ -4,24 +4,44 @@ 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
{
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;
@ -31,7 +51,7 @@ public partial class Autres : ContentView
row.Height = new GridLength(45);
GridAutre.RowDefinitions.Add(row);
// AJout Nourriture
// Ajout Nourriture
Label AutreLabel = new Label();
AutreLabel.Text = food.Nom.ToString();
Debug.WriteLine(AutreLabel);
@ -39,7 +59,6 @@ public partial class Autres : ContentView
Grid.SetColumn(AutreLabel, 0);
GridAutre.Children.Add(AutreLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food.Quantite.ToString();
@ -48,7 +67,6 @@ public partial class Autres : ContentView
GridAutre.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -58,12 +76,17 @@ public partial class Autres : ContentView
len++;
Debug.WriteLine("Test test");
}
}
private async void AddAutrelist(object sender, EventArgs e)
/**
* @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;
@ -88,7 +111,6 @@ public partial class Autres : ContentView
Grid.SetColumn(AutreLabel, 0);
GridAutre.Children.Add(AutreLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = autre2.Quantite.ToString();
@ -97,7 +119,6 @@ public partial class Autres : ContentView
GridAutre.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -108,16 +129,23 @@ public partial class Autres : ContentView
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é
@ -169,5 +197,7 @@ public partial class Autres : ContentView
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
mgr.Save_Data();
}
}

@ -4,24 +4,40 @@ 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;
@ -38,7 +54,6 @@ public partial class Drink : ContentView
Grid.SetColumn(DrinkLabel, 0);
GridDrink.Children.Add(DrinkLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food.Quantite.ToString();
@ -47,7 +62,6 @@ public partial class Drink : ContentView
GridDrink.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -57,14 +71,19 @@ public partial class Drink : ContentView
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)
{
//restoreListInvite();
string drink = DrinkInput.Text;
string qte = QteInput.Text;
if (int.TryParse(qte, out int value))
@ -73,7 +92,6 @@ public partial class Drink : ContentView
Modeles.Boisson drink1 = new Modeles.Boisson(drink, Int32.Parse(qte));
EventSelect.Participation.Boissons.Add(drink1);
int len = 1;
//if (len == 0 ) { len = 1; }
foreach (Modeles.Boisson food2 in EventSelect.Participation.Boissons)
{
RowDefinition row = new RowDefinition();
@ -87,7 +105,6 @@ public partial class Drink : ContentView
Grid.SetColumn(DrinkLabel, 0);
GridDrink.Children.Add(DrinkLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food2.Quantite.ToString();
@ -96,7 +113,6 @@ public partial class Drink : ContentView
GridDrink.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -110,13 +126,21 @@ public partial class Drink : ContentView
}
else
{
//await DisplayAlert("esv", "efds", "OK");
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é
@ -168,5 +192,7 @@ public partial class Drink : ContentView
parentGrid.RowDefinitions.RemoveAt(rowIndex);
}
}
mgr.Save_Data();
}
}

@ -3,25 +3,33 @@ 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;
@ -31,7 +39,6 @@ public partial class Nourri : ContentView
row.Height = new GridLength(45);
GridFood.RowDefinitions.Add(row);
// AJout Nourriture
Label foodLabel = new Label();
foodLabel.Text = food.Nom.ToString();
Debug.WriteLine(foodLabel);
@ -39,16 +46,12 @@ public partial class Nourri : ContentView
Grid.SetColumn(foodLabel, 0);
GridFood.Children.Add(foodLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridFood.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -58,14 +61,16 @@ public partial class Nourri : ContentView
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)
{
//restoreListInvite();
string food = FoodInput.Text;
string qte = QteInput.Text;
if (int.TryParse(qte, out int value))
@ -74,30 +79,24 @@ public partial class Nourri : ContentView
Modeles.Nourriture food1 = new Modeles.Nourriture(food, Int32.Parse(qte));
EventSelect.Participation.Nourriture.Add(food1);
int len = 1;
//if (len == 0 ) { len = 1; }
foreach (Modeles.Nourriture food2 in EventSelect.Participation.Nourriture)
{
RowDefinition row = new RowDefinition();
row.Height = new GridLength(45);
GridFood.RowDefinitions.Add(row);
// AJout Nourriture
Label foodLabel = new Label();
foodLabel.Text = food2.Nom;
Grid.SetRow(foodLabel, len);
Grid.SetColumn(foodLabel, 0);
GridFood.Children.Add(foodLabel);
// Ajout Quantite
Label qteLabel = new Label();
qteLabel.Text = food2.Quantite.ToString();
Grid.SetRow(qteLabel, len);
Grid.SetColumn(qteLabel, 1);
GridFood.Children.Add(qteLabel);
// Ajout Bouton
Button buttonMoins = new Button();
buttonMoins.Text = "-";
buttonMoins.Clicked += BoutonSupprimer_Clicked;
@ -109,33 +108,27 @@ public partial class Nourri : ContentView
Debug.WriteLine("Test test");
}
}
else {
//await DisplayAlert("esv", "efds", "OK");
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)
{
// 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 foodLabel = 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);
@ -151,19 +144,15 @@ public partial class Nourri : ContentView
if (foodLabel != null && qteLabel != null)
{
// Récupérer le prénom et le nom de l'invité à supprimer
string nom = foodLabel.Text;
string qte = qteLabel.Text;
// Rechercher l'invité correspondant dans la liste
Modeles.Nourriture nourriture = EventSelect.Participation.Nourriture.FirstOrDefault(i => i.Nom == nom && i.Quantite.ToString() == qte);
if (nourriture != null)
{
// Supprimer l'invité de la liste
EventSelect.Participation.Nourriture.Remove(nourriture);
// Supprimer les éléments de la ligne de la grille
parentGrid.Children.Remove(foodLabel);
parentGrid.Children.Remove(qteLabel);
parentGrid.Children.Remove(button);
@ -171,6 +160,5 @@ public partial class Nourri : ContentView
}
}
mgr.Save_Data();
}
}
}

@ -2,18 +2,30 @@
using ParionsCuite.Views.Participations;
namespace ParionsCuite.Views.Participations;
/**
* @brief Represents a ContentView for managing food-related actions.
*/
public partial class Nourriture : ContentView
{
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; }
@ -23,6 +35,11 @@ public partial class Nourriture : ContentView
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; }
@ -32,6 +49,11 @@ public partial class Nourriture : ContentView
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; }

Loading…
Cancel
Save