Beispiel #1
0
        public async Task <IActionResult> ModifyHealth(string name)
        {
            await this.userService.CheckIfUserExists(name);

            HealthModifyInputModel inputModel = await this.heroService.GetHeroViewModelByName <HealthModifyInputModel>(name);

            return(this.View(inputModel));
        }
Beispiel #2
0
        public async Task <IActionResult> ModifyHealth(HealthModifyInputModel inputModel)
        {
            await this.userService.CheckIfUserExists(inputModel.Name);

            await this.healthService.UpdateHealth(inputModel);

            return(this.RedirectToAction("ModifyHero", new { inputModel.Name }));
        }
        public async Task UpdateHealth(HealthModifyInputModel inputModel)
        {
            Hero hero = await this.heroService.GetHeroByName(inputModel.Name);

            hero.Health.Current = inputModel.HealthCurrent;
            hero.Health.Maximum = inputModel.HealthMaximum;

            await this.context.SaveChangesAsync();
        }