Ejemplo n.º 1
0
        private void ConfirmReview_Click(object sender, RoutedEventArgs e)
        {
            if (Rating.SelectedValue != null)
            {
                Score.TextAlignment = TextAlignment.Left;
                Score.FontSize      = 15;
                Score.Text          = "Review added: ";

                bool Exists = false;
                //Käy läpi kaikki pelin arvostelut. JOs käyttäjä on jo antanut arvostelun ei hän voi sitä uudestaan
                //antaa.

                foreach (Review rew in Selection.Reviews.Values)
                {
                    if (rew.Username == Statistics.Userloggedin)
                    {
                        Exists = true;
                        break;
                    }
                }

                if (Exists != true && Statistics.Userloggedin != null)
                {
                    int i = Selection.Reviews.Values.Count + 1;
                    if (Statistics.IsCustomer == true)
                    {
                        float x = float.Parse(Rating.SelectedValue.ToString());

                        Review review = new Review(i, Statistics.LoggedInUser.Username, x);
                        Selection.AddReview(i, review);
                    }
                    else
                    {
                        float x = float.Parse(Rating.SelectedValue.ToString());

                        Review review = new Review(i, Statistics.LoggedInEmployee.Username, x);
                        Selection.AddReview(i, review);
                    }
                }
                else
                {
                }
            }
        }