Пример #1
0
        public async Task <IActionResult> Create(GamesCreateViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            Game game = new()
            {
                Name              = model.Game.Name,
                Description       = model.Game.Description,
                Language          = model.Game.Language,
                Genre             = model.Game.Genre,
                Publisher         = model.Game.Publisher,
                Developer         = model.Game.Developer,
                Features          = model.Game.Features,
                Region            = model.Game.Region,
                WhereKeyActivated = model.Game.WhereKeyActivated,
                ReleaseDate       = model.Game.ReleaseDate,
            };

            await AddGameTags(game, model.TagsDictionary);

            _db.GameImages.Add(AddUpdateGameImage(game, model.MainImage, model.InnerImage, model.ImageInCatalog));
            _db.GamePrices.Add(PriceCalculation(game, model.Price));
            await _db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Пример #2
0
        public IActionResult Create()
        {
            var tags = _db.Tags.ToList();

            var gameCreate = new GamesCreateViewModel()
            {
                Tags = tags,
            };

            return(View(gameCreate));
        }