public async Task UpdateGameById(int id, EditGameModel model) { Game game = _mapper.Map <EditGameModel, Game>(model); game.Genre = model.Genres.First(genre => decimal.Parse(genre.Value) == game.GenreId)?.Text; await _businessLogicGames.UpdateGame(id, game); await _businessLogicGames.SaveChangesAsync(); }
public IHttpActionResult EditGame(int id, EditGameModel model) { var game = Mapper.Map <EditGameModel, GameDTO>(model); game.Id = id; _gameService.Edit(game); return(Ok("Game edited")); }
public async Task <IActionResult> EditGames(int?id) { Games game = await db.Games.FirstOrDefaultAsync(x => x.IdGame == id); if (game == null) { return(NotFound()); } var model = new EditGameModel() { IdGame = game.IdGame, Image = game.Image, NameOfGame = game.NameOfGame, Cost = game.Cost, CountOfKeys = game.CountOfKeys, DateOfRelease = game.DateOfRelease, Description = game.Description, Developers = game.IdDeveloper, Publishers = game.IdPublisher, Developer = db.Developer.AsEnumerable(), Publisher = db.Publisher.AsEnumerable() }; return(View(model)); }
public bool EditGame(int idToEdit, EditGameModel editGame) { try { _repository.Edit(idToEdit, new SomeGame() { Name = editGame.Name, GenreId = editGame.GenreId, }); return(true); } catch (Exception) { return(false); } }
public async Task <IActionResult> EditGames(EditGameModel gamemod) { Games game = await db.Games.FirstOrDefaultAsync(x => x.IdGame == gamemod.IdGame); game.IdGame = gamemod.IdGame; game.IdPublisher = gamemod.Publishers; game.IdDeveloper = gamemod.Developers; game.Image = "/Images/" + gamemod.Image; game.Cost = gamemod.Cost; game.CountOfKeys = gamemod.CountOfKeys; game.DateOfRelease = gamemod.DateOfRelease; game.NameOfGame = gamemod.NameOfGame; game.Description = gamemod.Description; Console.WriteLine("EditGame: " + gamemod.IdGame + gamemod.Publishers); db.Games.Update(game); await db.SaveChangesAsync(); ViewData["MessageEditGame"] = "Запись '" + game.IdGame + " " + game.NameOfGame + "' была успешно отредактирована!"; return(RedirectToAction("ListGames")); }
public ActionResult EditGame(int id) { _gameId = id; SelectList categories = new SelectList(_gameLogic.GetCategories(), "CategoryId", "CategoryName"); ViewBag.Categories = categories; var game = _gameLogic.GetGame(id); var model = new EditGameModel() { Category = new Category() { CategoryId = game.CategoryId, CategoryName = game.Category }, Description = game.Description, Name = game.Name, Price = game.Price, Producer = game.Producer }; return(View(model)); }
public async Task <IActionResult> Edit(int id, EditGameModel game) { var genres = await _commonService.GetAllGenres(); List <SelectListItem> listItems = _mapper.Map <IEnumerable <Genre>, List <SelectListItem> >(genres); game.Genres = listItems; if (id != game.Id) { return(NotFound()); } if (ModelState.IsValid) { await _gamesService.UpdateGameById(id, game); return(RedirectToAction(nameof(GamesController.Index), new { pageNumber = 1 })); } return(View(game)); }
public ActionResult EditGame(EditGameModel model) { _gameLogic.EditGame(_gameId, model.Name, model.Category, model.Producer, model.Price, model.Discount, model.Description); return(RedirectToAction("GameProfile", new { id = _gameId })); }