public ActionResult ProductInGame([Bind(Include = "productID,Quantity,PriceInGame,ReferencePrice,CurrencyID")] ProductInGame data, string prevBtn, string nextBtn) { GameAdminViewModel game = GetGame(); if (prevBtn != null) { GameAdminViewModel g = new GameAdminViewModel(); g.Game = game.Game; g.Game.DateInserted = DateTime.Now; g.Game.DateUpdated = DateTime.Now; g.Game.USR = "******"; return(RedirectToAction("Create", g.Game)); } if (nextBtn != null) { if (ModelState.IsValid) { game.ProductInGames = data; game.ProductInGames.DateUpdated = DateTime.Now; game.ProductInGames.USR = "******"; Session["game"] = game; return(RedirectToAction("ProductLocation")); } } return(View()); }
public ActionResult Create([Bind(Include = "GameID,GameCode,GameTypeID,GameName,GameDescription,NumberOfWinners,Global")] Game game, string GameTypeID, string MemberSubscriptionType, string prevBtn, string nextBtn) { if (nextBtn != null) { if (ModelState.IsValid) { GameAdminViewModel g = GetGame(); game.GameTypeID = Convert.ToInt32(GameTypeID); game.MemberSubscriptionType = Convert.ToInt32(MemberSubscriptionType); g.Game = game; g.Game.DateInserted = DateTime.Now; g.Game.DateUpdated = DateTime.Now; // g.Game.restart = true; g.Game.USR = "******"; Session["game"] = g; return(RedirectToAction("ProductInGame")); } ViewBag.GameTypeID = new SelectList(db.GameTypes, "GameTypeID", "GameTypeCode", game.GameTypeID); ViewBag.NextGameID = new SelectList(db.Games, "NextGameID", "USR", game.NextGameID); ViewBag.GameID = new SelectList(db.Games, "GameID", "GameCode", game.GameID); ViewBag.MemberSubscriptionType = new SelectList(db.MemberSubscriptionTypes, "MemberSubscriptionTypeID", "MemberSubscriptionTypeCode", game.MemberSubscriptionType); } return(View(game)); }
private GameAdminViewModel GetGame() { if (Session["game"] == null) { Session["game"] = new GameAdminViewModel(); } return((GameAdminViewModel)Session["game"]); }
private void SetGameViewData(GameAdminViewModel game) { this.ViewModel["title"] = game.Title; this.ViewModel["description"] = game.Description; this.ViewModel["thumbnailUrl"] = game.ThumbnailUrl; this.ViewModel["price"] = game.Price.ToString("F2"); this.ViewModel["size"] = game.Size.ToString("F1"); this.ViewModel["videoId"] = game.VideoId; this.ViewModel["releaseDate"] = game.ReleaseDate.ToString("yyyy-MM-dd"); }
public IActionResult Edit(int id) { if (!this.IsAdmin) { return(this.RedirectToHome()); } GameAdminViewModel model = this.gameService.GetGameById(id); if (model == null) { return(this.NotFound()); } this.SetGameViewData(model); return(this.View()); }
public IActionResult Add(GameAdminViewModel model) { if (!this.IsAdmin) { return(this.RedirectToHome()); } if (!this.IsValidModel(model)) { this.DisplayError(ErrorHelper.GameError); return(this.View()); } this.gameService.Create(model.Title, model.Description, model.ThumbnailUrl, model.Price, model.Size, model.VideoId, model.ReleaseDate); return(this.RedirectToAdminAll()); }
public ActionResult ProductLocation(ProductLocation data, string prevBtn, string nextBtn) { GameAdminViewModel game = GetGame(); if (prevBtn != null) { GameAdminViewModel g = new GameAdminViewModel(); g.ProductLocations = game.ProductLocations; g.ProductLocations.DateInserted = DateTime.Now; g.ProductLocations.DateUpdated = DateTime.Now; g.ProductLocations.USR = "******"; return(RedirectToAction("ProductInGames", g)); } if (nextBtn != null) { if (ModelState.IsValid) { game.ProductLocations = data; game.ProductLocations.DateInserted = DateTime.Now; game.ProductLocations.DateUpdated = DateTime.Now; game.ProductLocations.USR = "******"; if (db.Games.Count(g => g.GameID == game.Game.GameID) > 0) { db.Games.Remove(game.Game); } db.Games.Add(game.Game); db.SaveChanges(); game.Game.ProductInGames = new List <ProductInGame> (); game.ProductInGames.GameID = game.Game.GameID; game.Game.ProductInGames.Add(game.ProductInGames); db.SaveChanges(); game.ProductLocations.ProductInGameID = game.ProductInGames.ProductInGameID; db.ProductLocations.Add(game.ProductLocations); db.SaveChanges(); return(RedirectToAction("Rules")); } } return(View()); }
public ActionResult Rules(String excecuteTime, String hours, String minutes, String seconds) { GameAdminViewModel gameVM = GetGame(); DateTime executeTime = DateTime.ParseExact(excecuteTime, "yyyy/MM/dd", System.Globalization.CultureInfo.InvariantCulture); executeTime = executeTime.AddHours(Convert.ToDouble(hours)).AddMinutes(Convert.ToDouble(minutes)).AddSeconds(Convert.ToDouble(seconds)); List <GameRule> rules = new List <GameRule>(); GameRule prepareRule = toRule("PrepareGameRule", gameVM.Game.GameID, "PrepareGameRule", DateTime.Now, 1); GameRule startRule = toRule("StartGame", gameVM.Game.GameID, "StartGame", executeTime, 2); GameRule potentialRule = toRule("ResolvePotentialWinners", gameVM.Game.GameID, "ResolvePotentialWinners", executeTime.AddSeconds(10), 3); GameRule resolveRule = toRule("ResolveActualWinners", gameVM.Game.GameID, "ResolveActualWinners", executeTime.AddMinutes(1), 4); rules.Add(prepareRule); rules.Add(startRule); rules.Add(potentialRule); rules.Add(resolveRule); gameVM.GameRules = rules; db.GameRules.AddRange(rules); db.SaveChanges(); gameVM.GameRules = rules; return(RedirectToAction("FiveMinDeal")); }