public void AddRate(UserRating rate) { CafeRates.Ratings.Add(rate); switch (rate.UserRate) { case Rate.one: CafeRates.CountsOfRates[1]++; break; case Rate.two: CafeRates.CountsOfRates[2]++; break; case Rate.three: CafeRates.CountsOfRates[3]++; break; case Rate.four: CafeRates.CountsOfRates[4]++; break; case Rate.five: CafeRates.CountsOfRates[5]++; break; } }
//Rate public static void Rate(User currentUser, Cafe selectedBuilding, string rateLine) { if (selectedBuilding != null) { if (currentUser == null) { MessageBox.Show("Please log in"); return; } if (rateLine[0] - '0' > 5 || rateLine[0] - '0' < 1) { MessageBox.Show("Your rate must be from 1 to 5."); return; } UserRating rate = new UserRating(currentUser, (Rate)(rateLine[0] - '0'), rateLine.Trim()); selectedBuilding.AddRate(rate); return; } MessageBox.Show("There is no selected building."); }
public virtual void AddRate(UserRating rate) { }