// POST public IHttpResponse Add(AdminAddGameViewModel model) { var redirectResponse = this.RedirectIfNotAdminOrNotAthenticated(); if (redirectResponse != null) { return(redirectResponse); } if (!this.ValidateModel(model)) { return(this.Add()); } this.gameService.Create( model.Title, model.Description, model.Image, model.Price, model.Size, model.VideoId, model.ReleaseDate.Value); return(new RedirectResponse(Routes.ListAllGamesPath)); }
public IHttpResponse Add(AdminAddGameViewModel model) { // is authenticated as admin ? if (!this.Authentication.IsAdmin) { return(this.RedirectResponse(HomePath)); } // are validations passed ? if (!this.ValidateModel(model)) { return(this.Add()); } this.games.Create( model.Title, model.Description, model.Image, model.Price, model.Size, model.VideoId, model.ReleaseDate); //.Value); return(this.RedirectResponse(AllGamesListPath)); }
public IActionResult AddGame([FromRoute] Game game) { var gameVM = new AdminAddGameViewModel { Name = game.Name, Price = game.Price, Description = game.Description, Stock = game.Stock, Category = game.Category }; return(View(gameVM)); }
public IHttpResponse AddGame(AdminAddGameViewModel model) { if (!ValidateModel(model)) { return(this.AddGame()); } games.Create(model.Title, model.Description, model.Image, model.Price, model.Size, model.VideoId, model.ReleaseDate); return(new RedirectResponse(HomePath)); }
public IHttpResponse Add(AdminAddGameViewModel model) { if (!this.Authentication.IsAdmin) { return(new RedirectResponse("/")); } if (!this.ValidateModel(model)) { return(this.Add()); } this.gameService.CreateGame(model.Title, model.Description, model.ImageUrl, model.Price, model.Size, model.TrailerId, model.ReleaseDate.Value); return(new RedirectResponse("/admin/games/list")); }
public IHttpResponse Add(AdminAddGameViewModel model) { if (!this.Authentication.IsAdmin) { return(this.RedirectResponse(HomePath)); } if (!this.ValidateModel(model)) { return(this.Add()); } this.games.Create( model.Title, model.Description, model.ThumbnailUrl, model.Price, model.Size, model.Trailer, model.ReleaseDate); return(this.RedirectResponse("/admin/games/list")); }
public IHttpResponse Add(AdminAddGameViewModel model) { // Accessed by Admins only - using Common.Authentication class: if (!this.Authentication.IsAdmin) { return(this.RedirectResponse(HomePath)); } // Validate model if (!this.ValidateModel(model)) { return(this.Add()); } // Create Game in db this.gameService.Create( model.Title, model.Description, model.ImageUrl, model.Price, model.Size, model.VideoId, (DateTime)model.ReleaseDate.Value); return(this.RedirectResponse("/admin/games/list")); }
public IHttpResponse Add(AdminAddGameViewModel model) { string title = model.Title; string description = model.Description; string imageUrl = model.ImageURL; decimal price = model.Price; double size = model.Size; DateTime releaseDate = model.ReleaseDate; string trailer = model.Trailer; bool isDataValid = ValidateGameInput(title, description, imageUrl, price, size, releaseDate, trailer); if (!isDataValid) { return(this.FileViewResponse(AddGame)); } using (var db = new GameStoreDbContext()) { Game gameToAdd = new Game { Title = title, Description = description, Price = price, Size = size, Trailer = trailer, ReleaseDate = releaseDate }; if (!string.IsNullOrWhiteSpace(imageUrl)) { gameToAdd.ImageURL = imageUrl; } db.Games.Add(gameToAdd); db.SaveChanges(); }; return(this.RedirectResponse(HomePath)); }
public IHttpResponse Add(AdminAddGameViewModel model) { if (!this.Authentication.IsAdmin) { return(this.RedirectResponse(HomePath)); } if (!this.ValidateModel(model)) { return(this.Add()); } this.games.Create(model.Title, model.Description, model.Image, model.Price, model.ReleaseDate.Value, model.Size, model.VideoId); return(this.List()); }
public IActionResult AddGame([FromForm] AdminAddGameViewModel model) { if (!ModelState.IsValid) { return(BadRequest()); } string image = ""; if (!ModelState.IsValid) { return(BadRequest()); } using (var memoryStream = new MemoryStream()) { model.ImageFile.CopyTo(memoryStream); image = Convert.ToBase64String(memoryStream.ToArray()); } var userId = userManager.GetUserId(User); adminServices.addGame(userId, model.Name, model.Price, model.Description, image, model.Stock, model.Category); return(RedirectToAction("Index")); }
public IHttpResponse Add(AdminAddGameViewModel model) { if (!this.Authentication.IsAdmin) { return(this.HomeRedirect()); } if (!this.ValidateModel(model)) { return(this.Add()); } this.gameService.Create( model.Title, model.Description, model.ImageUrl, model.Price, model.SizeGigabytes, model.TrailerId, model.ReleaseDate.Value); return(this.RedirectResponse(GameStoreApp.AdminAllGames)); }
public IHttpResponse Add(AdminAddGameViewModel model) { if (!this.Authentication.IsAdmin) { return(this.FileViewResponse(@"/")); } if (!this.ValidateModel(model)) { return(this.Add()); } this.games.Create( model.Title, model.Description, model.Image, model.Price, model.Size, model.VideoId, model.ReleaseDate.Value); //return this.FileViewResponse(@"/admin/list-games"); return(new RedirectResponse("/admin/games/list")); }