Beispiel #1
0
        public async Task UpdateShouldReturnWorkCorrectly()
        {
            await this.gamesLanguagesRepo.Object.AddAsync(new()
            {
                Id         = 1,
                GameId     = 21,
                LanguageId = 23,
            });

            await this.gamesLanguagesRepo.Object.AddAsync(new()
            {
                Id         = 2,
                GameId     = 11,
                LanguageId = 13,
            });

            GameLanguageAdminInputModel input = new GameLanguageAdminInputModel
            {
                GameId     = 21,
                LanguageId = 24,
            };

            await this.service.UpdateAsync(1, input);

            var result = this.service.GetById <GameLanguageAdminInputModel>(1);

            Assert.Equal(24, result.LanguageId);
        }
        // GET: Administration/GameLanguages/Create
        public IActionResult Create(GameLanguageAdminInputModel input)
        {
            input.LanguagesItems = this.languagesService.GetAllAsKeyValuePairs();
            input.GamesItems     = this.gamesService.GetAllAsKeyValuePairs()
                                   .OrderBy(x => x.Value);

            this.ViewData["GameId"]     = new SelectList(this.gamesRepository.All(), "Id", "Id");
            this.ViewData["LanguageId"] = new SelectList(this.languagesRepository.All(), "Id", "Id");
            return(this.View(input));
        }
Beispiel #3
0
        public async Task UpdateAsync(int id, GameLanguageAdminInputModel input)
        {
            var gameLanguage = this.gamesLanguagesRepository
                               .All()
                               .FirstOrDefault(x => x.Id == id);

            gameLanguage.GameId     = input.GameId;
            gameLanguage.LanguageId = input.LanguageId;

            await this.gamesLanguagesRepository.SaveChangesAsync();
        }
        public async Task <IActionResult> Edit(int id, [Bind("GameId,LanguageId,Id,CreatedOn,ModifiedOn")] GameLanguageAdminInputModel input)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.View());
            }

            await this.languagesService.UpdateAsync(id, input);

            return(this.RedirectToAction(nameof(this.Edit), new { id }));
        }