You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Projet_IHM/Sources/Stim/ReviewPopUp.xaml.cs

35 lines
917 B

using CommunityToolkit.Maui.Views;
using Model;
using System.Globalization;
namespace Stim;
public partial class ReviewPopUp : Popup
{
Game CurrGame { get; set; }
public ReviewPopUp(Game currGame)
{
InitializeComponent();
CurrGame = currGame;
}
public void CloseButton(object sender, EventArgs e)
{
Close();
}
private void Valider(object sender, EventArgs e)
{
if (CurrGame == null)
{
throw new Exception();
}
bool IsFloat = float.TryParse(Val.Text, NumberStyles.Float, CultureInfo.InvariantCulture, out float rate);
if (!string.IsNullOrWhiteSpace(Entrytxt.Text) && IsFloat)
{
((App)App.Current).Manager.CurrentUser.AddReview(CurrGame, rate, Entrytxt.Text);
Close();
}
else Error.Children.Add(new Label { Text="Champ vide ou invalide", TextColor=Colors.Red });
}
}