Exemplo n.º 1
0
        public IActionResult Details(int id)
        {
            var profession = _professionsService.ById(id);

            if (profession == null)
            {
                return(Redirect(Professions_Root_Path));
            }

            var viewModel = new ProfessionDetailsViewModel
            {
                Id           = profession.Id,
                Name         = profession.Name,
                UsableWeapon = profession.UsableWeapon.ToString(),
                CombatType   = profession.CombatType.ToString(),
                ClassRole    = profession.ClassRole.ToString()
            };

            if (profession.Races.Any())
            {
                foreach (var raceProfession in profession.Races)
                {
                    var race = _racesService.ById(raceProfession.RaceId);

                    viewModel.Races.Add(new RacesAllViewModel {
                        Id = race.Id, Name = race.Name
                    });
                }
            }

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> RemoveRace(ProfessionDetailsViewModel model)
        {
            var profession = _professionsService.ById(model.Id);

            var race = _racesService.ById(model.RaceId);

            if (race == null || profession == null)
            {
                return(Redirect(Professions_Root_Path));
            }

            await _professionsService.RemoveRace(profession, race);

            return(Redirect("/Professions/Details/" + profession.Id));
        }