Пример #1
0
        public async Task <ActionResult> Build(uint id, string heroName = null)
        {
            var hero = await db.GetHeroDetailsAsync(id);

            if (heroName != hero.Url.ToLower())
            {
                return(RedirectToAction("hero", new { id = id, heroName = hero.Url.ToLower() }));
            }

            var viewModel = AutoMapperConfiguration.Mapper.Map <HeroDetailModel, HeroItemBuildViewModel>(hero);

            viewModel.ActiveTab = "ItemBuilds";

            try
            {
                var itemBuild = await db.GetItemBuildAsync(hero.NameInSchema);

                viewModel.Title      = itemBuild.Title;
                viewModel.Author     = itemBuild.Author;
                viewModel.ItemGroups = await GetItemGroupsAsync(itemBuild);
            }
            catch (FileNotFoundException)
            {
                ViewBag.ErrorMessage = "This hero doesn't have any item builds in the Dota 2 files yet.";
            }

            return(PartialView("_ItemBuildsPartial", viewModel));
        }