public ActionResult Edit(ModeratorGameServiceModel model) { if (!ModelState.IsValid) { return(this.View()); } this.games.EditGame(model); TempData.AddSuccessMessage($"Game {model.Title} was edited successful!"); return(this.RedirectToAction( nameof(HomeController.Index), "Home", new { area = string.Empty })); }
public void Create(ModeratorGameServiceModel model) { var game = new Game { Title = model.Title, Price = model.Price, Size = model.Size, VideoUrl = model.VideoUrl, ThumbnailUrl = model.ThumbnailUrl, Description = model.Description, ReleaseDate = model.ReleaseDate }; this.data.Games.Add(game); this.data.Games.SaveChanges(); }
public void EditGame(ModeratorGameServiceModel model) { var gameExist = this.data.Games.Find(model.Id); if (gameExist == null) { return; } gameExist.Title = model.Title; gameExist.Price = model.Price; gameExist.Size = model.Size; gameExist.VideoUrl = model.VideoUrl; gameExist.ThumbnailUrl = model.ThumbnailUrl; gameExist.Description = model.Description; gameExist.ReleaseDate = model.ReleaseDate; this.data.Games.Update(gameExist); this.data.Games.SaveChanges(); }