Beispiel #1
0
        public async Task <IActionResult> Details(string id)
        {
            if (id == null)
            {
                return(View("NotFound"));
            }

            var game = await GetGamesGreedy()
                       .SingleOrDefaultAsync(m => m.GameId == id);

            if (game == null)
            {
                return(View("NotFound"));
            }

            _context.Update(game);
            await _context.SaveChangesAsync();

            var viewModel = _mapper.Map <DetailsGameViewModel>(game);

            if (_signInManager.IsSignedIn(HttpContext.User))
            {
                var user = await GetCurrentUser();

                // make each offer edit-able when user is its author OR admin/moderator
                viewModel.CanEdit = (viewModel.Author.Id == user.Id) || UserIsAdministrator() || UserIsModerator();
            }

            return(View(viewModel));
        }
        public async Task <IActionResult> Create(CreateDeveloperViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var developer = new Developer {
                Name = model.Name
            };

            _context.Add(developer);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #3
0
        public async Task <IActionResult> Create(CreateGenreViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var genre = new Genre {
                Name = model.Name
            };

            _context.Add(genre);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }