Exemple #1
0
 public void game_Rating_add(GameRating char_Rating)
 {
     using (Course_workContext db = new Course_workContext())
     {
         db.GameRatings.Add(char_Rating);
         db.SaveChanges();
     }
 }
Exemple #2
0
        private void game_rating_menu()
        {
            while (1 == 1)
            {
                int char_rating_ = 0;
                Int32.TryParse(view.game_rating(), out char_rating_);
                if (char_rating_ == 1)
                {
                    string movies_ratings = model.game_Rating_print();
                    if (movies_ratings.Length == 0)
                    {
                        view.err_empty_table("Games - ratings");
                    }
                    else
                    {
                        view.print_game_ratings(movies_ratings);
                    }
                }
                else if (char_rating_ == 2)
                {
                    int id = 0;
                    Int32.TryParse(view.get_id(), out id);
                    string gr = model.game_Rating_get_by_id(id);
                    if (gr.Length == 0)
                    {
                        view.err_wrong_ID("Game - rating");
                    }
                    else
                    {
                        view.print_game_rating(gr);
                    }
                }
                else if (char_rating_ == 3)
                {
                    int game_id = 0;
                    Int32.TryParse(view.get_game_id(), out game_id);
                    while (model.Game_get_by_id(game_id) == null)
                    {
                        view.err_wrong_ID("Game");
                        Int32.TryParse(view.get_game_id(), out game_id);
                    }
                    int rating_id = 0;
                    Int32.TryParse(view.get_rating_id(), out rating_id);
                    while (model.Rating_get_by_id(rating_id) == null)
                    {
                        view.err_wrong_ID("Rating");
                        Int32.TryParse(view.get_rating_id(), out rating_id);
                    }
                    GameRating char_rating__ = new GameRating();
                    char_rating__.GameId   = game_id;
                    char_rating__.RatingId = rating_id;
                    model.game_Rating_add(char_rating__);
                    view.successfull_connection();
                }

                else if (char_rating_ == 4)
                {
                    int id = 0;
                    Int32.TryParse(view.get_id(), out id);
                    bool del = model.game_Rating_delete(id);
                    if (del == false)
                    {
                        view.err_wrong_ID("Games - ratings");
                    }
                    else
                    {
                        view.successfull_operation("Game - rating", id, "deleted");
                    }
                }

                else if (char_rating_ == 5)
                {
                    break;
                }
                else
                {
                    view.err_wrong_option();
                }
            }
        }