Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(string id, [Bind("GameID,SearchID,DisplayName,Description,Password")] EditGame egame)
        {
            if (id != egame.SearchID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    Game game = egame.ToGame(_context);
                    _context.Update(game);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GameExists(egame.SearchID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(egame));
        }
Ejemplo n.º 2
0
        public bool SaveGame(EditGame editGame, int?id)
        {
            Game game = null;

            if (id.HasValue)
            {
                game = _dbContext.Games.Include(g => g.Tags).FirstOrDefault(g => g.Id == id.Value);
            }
            else
            {
                game = new Game();
                _dbContext.Games.Add(game);
            }

            if (game == null)
            {
                return(false);
            }

            game.Update(editGame);

            _dbContext.SaveChanges();

            editGame.Id = game.Id;

            return(true);
        }
 private void EditGameStart(EditGame obj)
 {
     if (IsEditControl)
     {
         this.Game = obj.Game;
         this.BeginEdit();
         RaisePropertyChangedEvent("");
     }
 }
Ejemplo n.º 4
0
 private void CancelBtn_Click(object sender, RoutedEventArgs e)
 {
     if (isFromAdd)
     {
         AddGame.Close();
     }
     else
     {
         EditGame.Close();
     }
 }
Ejemplo n.º 5
0
    public AddEditPage2(EditGame editGame, GameCard gameCard)
    {
        InitializeComponent();
        EditGame  = editGame;              // Set
        isFromAdd = false;
        GameCard  = EditGame.GameCard;     // Set

        RAWGID = GameCard.GameInfo.RAWGID; // Set value
        old    = gameCard.GameInfo;
        InitUI();
    }
Ejemplo n.º 6
0
 private void BackBtn_Click(object sender, RoutedEventArgs e)
 {
     if (isFromAdd)
     {
         AddGame.ChangePage(0);             // Go back to last page
     }
     else
     {
         EditGame.ChangePage(0);             // Go back to last page
     }
 }
Ejemplo n.º 7
0
    private void NextBtn_Click(object sender, RoutedEventArgs e)
    {
        try
        {
            if (isFromAdd)
            {
                Definitions.Games.Add(new()
                {
                    Name             = AddGame.GameName,         // Set value
                    Version          = AddGame.GameVersion,      // Set value
                    Description      = DescriptionTextBox.Text,  // Set value
                    FileLocation     = AddGame.GameLocation,     // Set value
                    IconFileLocation = AddGame.GameIconLocation, // Set value
                    IsFavorite       = false,                    // Set value
                    RAWGID           = RAWGID,                   // Set value
                    LastTimePlayed   = 0,                        // Set value
                    TotalTimePlayed  = 0,                        // Set value
                    ProcessName      = "",                       // Set value
                    Platforms        = (Platforms.Count == 0) ? new List <SDK.RAWG.Platform> {
                        Definitions.DefaultPlatform
                    } : Platforms,                                                                                                                    // Get platforms
                    Stores = Stores,
                    AlwaysCheckIfRunning = false,
                    IsUWP   = AddGame.IsUWP,
                    IsSteam = AddGame.IsSteam
                });

                GameSaver.Save(Definitions.Games);       // Save
                Global.ReloadAllPages();                 // Refresh UI

                AddGame.Close();
            }
            else
            {
                GameCard.GameInfo.RAWGID      = RAWGID;                                // Set
                GameCard.GameInfo.Description = DescriptionTextBox.Text;               // Set
                GameCard.GameInfo.Platforms   = Platforms;                             // Set
                GameCard.GameInfo.Stores      = Stores;                                // Set

                Definitions.Games[Definitions.Games.IndexOf(old)] = GameCard.GameInfo; // Update
                GameSaver.Save(Definitions.Games);                                     // Save

                Global.ReloadAllPages();                                               // Refresh UI

                EditGame.Close();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message, Properties.Resources.MainWindowTitle, MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }
Ejemplo n.º 8
0
    public AddEditPage(EditGame editGame, GameCard gameCard)
    {
        InitializeComponent();

        EditGame  = editGame;                  // Set
        isFromAdd = false;
        RAWGID    = gameCard.GameInfo.RAWGID;  // Set
        GameCard  = EditGame.GameCard;         // Set
        isUWP     = GameCard.GameInfo.IsUWP;   // Set
        isSteam   = GameCard.GameInfo.IsSteam; // Set

        InitUI();
    }
Ejemplo n.º 9
0
 public ActionResult Edit(EditGame eg)
 {
     if (this.ModelState.IsValid)
     {
         GameController gc = new GameController();
         gc.Put(eg);
         return(RedirectToAction("Index", "Home"));
     }
     else
     {
         return(View(eg));
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Changes details about a Game.
        /// </summary>
        public IHttpActionResult Put(EditGame game)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateGameService();

            if (!service.UpdateGame(game))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Ejemplo n.º 11
0
        // GET: Games/Edit/5
        public async Task <IActionResult> Edit(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var game = EditGame.GenerateAsync(_context, await _context.Games.FirstAsync((g) => g.SearchID == id));

            if (game == null)
            {
                return(NotFound());
            }
            return(View(game));
        }
Ejemplo n.º 12
0
 public bool UpdateGame(EditGame model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         var entity =
             ctx
             .Games
             .Single(e => e.GameID == model.GameID);
         entity.GameID        = model.GameID;
         entity.HomeTeamID    = model.HomeTeamID;
         entity.AwayTeamID    = model.AwayTeamID;
         entity.GameDate      = model.GameDate;
         entity.HomeTeamScore = model.HomeTeamScore;
         entity.AwayTeamScore = model.AwayTeamScore;
         return(ctx.SaveChanges() == 1);
     }
 }
Ejemplo n.º 13
0
    private void ConvertSteamBtn_Click(object sender, RoutedEventArgs e)
    {
        if (ConvertSteamPanel.Visibility == Visibility.Collapsed)
        {
            ConvertSteamBtn.Content      = Properties.Resources.ConvertToSteam; // Set new text of the button
            ConvertSteamPanel.Visibility = Visibility.Visible;                  // Show the panel
        }
        else
        {
            if (string.IsNullOrEmpty(SteamAppIdTextBox.Text))
            {
                MessageBox.Show(Properties.Resources.GameNeedsName, Properties.Resources.MainWindowTitle, MessageBoxButton.OK, MessageBoxImage.Exclamation);                 // Show message
                return;
            }

            // Ask a confirmation to the user
            if (MessageBox.Show(Properties.Resources.ConvertToSteamMsg, Properties.Resources.MainWindowTitle, MessageBoxButton.YesNoCancel, MessageBoxImage.Warning) == MessageBoxResult.Yes)
            {
                GameCard.GameInfo.IsSteam      = true;            // Convert to steam game
                GameCard.GameInfo.FileLocation = $"steam://rungameid/{SteamAppIdTextBox.Text}";
                GameCard.GameInfo.ProcessName  = !string.IsNullOrEmpty(GameProcessTextBox.Text) ? GameProcessTextBox.Text : GameCard.GameInfo.ProcessName;

                // Save other changes
                GameCard.GameInfo.RAWGID      = RAWGID;                                // Set
                GameCard.GameInfo.Description = DescriptionTextBox.Text;               // Set
                GameCard.GameInfo.Platforms   = Platforms;                             // Set
                GameCard.GameInfo.Stores      = Stores;                                // Set

                Definitions.Games[Definitions.Games.IndexOf(old)] = GameCard.GameInfo; // Update
                GameSaver.Save(Definitions.Games);                                     // Save

                Global.ReloadAllPages();                                               // Refresh UI

                EditGame.Close();
            }
        }
    }
 private void EditGameFinished(EditGame obj)
 {
     this.EditGameVisible    = false;
     this.DeckPreviewVisible = true;
     this.AllowCommands      = true;
 }
Ejemplo n.º 15
0
    private void NextBtn_Click(object sender, RoutedEventArgs e)
    {
        if (isUWP)
        {
            if (string.IsNullOrEmpty(PackageFamilyNameTextBox.Text) || string.IsNullOrEmpty(AppIdTextBox.Text))
            {
                MessageBox.Show(Properties.Resources.GameNeedsName, Properties.Resources.AddGame, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;                 // Stop
            }
        }
        else if (isSteam)
        {
            if (string.IsNullOrEmpty(NameTextBox.Text) || string.IsNullOrEmpty(SteamAppIdTextBox.Text))
            {
                MessageBox.Show(Properties.Resources.GameNeedsName, Properties.Resources.AddGame, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;                 // Stop
            }
        }
        else
        {
            if (!string.IsNullOrEmpty(NameTextBox.Text) && !string.IsNullOrEmpty(LocationTxt.Text))
            {
                // OK
            }
            else
            {
                MessageBox.Show(Properties.Resources.GameNeedsName, Properties.Resources.AddGame, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;                 // Stop
            }
        }

        if (isFromAdd)
        {
            AddGame.RAWGID      = RAWGID;              // Set
            AddGame.GameVersion = VersionTextBox.Text; // Set
            AddGame.GameName    = NameTextBox.Text;    // Set
            if (isUWP)
            {
                AddGame.GameLocation = $@"shell:appsFolder\{PackageFamilyNameTextBox.Text}!{AppIdTextBox.Text}";                 // Set
            }
            else if (isSteam)
            {
                AddGame.GameLocation = $"steam://rungameid/{SteamAppIdTextBox.Text}";                 // Set
            }
            else
            {
                AddGame.GameLocation = GameLocation;                 // Set
            }


            AddGame.GameIconLocation = GameIconLocation; // Set
            AddGame.ChangePage(1);                       // Change page
        }
        else
        {
            GameCard.GameInfo.Name             = NameTextBox.Text;    // Set
            GameCard.GameInfo.Version          = VersionTextBox.Text; // Set
            GameCard.GameInfo.IconFileLocation = GameIconLocation;    // Set

            if (isUWP)
            {
                GameCard.GameInfo.FileLocation = $@"shell:appsFolder\{PackageFamilyNameTextBox.Text}!{AppIdTextBox.Text}";                 // Set
            }
            else if (isSteam)
            {
                GameCard.GameInfo.FileLocation = $"steam://rungameid/{SteamAppIdTextBox.Text}";                 // Set
            }
            else
            {
                GameCard.GameInfo.FileLocation = LocationTxt.Text;                 // Set
            }

            EditGame.GameCard = GameCard;       // Set

            EditGame.ChangePage(1);             // Change page
        }
    }
Ejemplo n.º 16
0
        public void OnGet(int?id)
        {
            _id = id;

            Game = _gamesService.GetEditGame(id);
        }