Esempio n. 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var selectedItem = places.SelectedItem as Place;

            var page = new PlaceWindow(selectedItem.Id.ToString());

            page.Show();

            this.Close();
        }
Esempio n. 2
0
        private void DeleteRateBtn_Click(object sender, RoutedEventArgs e)
        {
            using (var db = new PointsOfInterestContext())
            {
                var currentUser = db.Users.SingleOrDefault(x => x.Email == this.UserEmail);
                var currentRate = db.Rates_Users_Places
                                  .SingleOrDefault(x => x.UserId == currentUser.Id && x.PlaceId == this.Plc.Id);

                db.Rates_Users_Places.Remove(currentRate);
                db.SaveChanges();
            }

            var page = new PlaceWindow(this.Plc.Id.ToString());

            page.Show();
            this.Close();
        }
Esempio n. 3
0
        private void AddRate_Button(object sender, RoutedEventArgs e)
        {
            var parsedRateNumber = 0;

            var parsedRate = Int32.TryParse(PlaceRate.Value.ToString(), out parsedRateNumber);

            if (parsedRate)
            {
                if (parsedRateNumber < 1 || parsedRateNumber > 5)
                {
                    MessageBox.Show("rate must be between 1 and 5");
                }
                else
                {
                    using (var db = new PointsOfInterestContext())
                    {
                        var currentUser = db.Users.SingleOrDefault(x => x.Email == this.UserEmail);

                        if (!this.IsRated)
                        {
                            var ratePlace = new Rates_Users_Places
                            {
                                UserId  = currentUser.Id,
                                PlaceId = this.Plc.Id,
                                Rate    = parsedRateNumber
                            };

                            db.Rates_Users_Places.Add(ratePlace);
                            db.SaveChanges();
                        }
                    }

                    var page = new PlaceWindow(this.Plc.Id.ToString());
                    page.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("rate must be a number");
            }
        }