Skip to content

Commit

Permalink
Added Preferred Genders to incomplete shiny hunt page
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMrDew committed Jun 8, 2024
1 parent cc78e98 commit fe73dc8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
17 changes: 14 additions & 3 deletions Pokedex/Pokedex/Controllers/ShinyHuntController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,17 @@ public IActionResult PhaseShinyFound(CompleteShinyHuntViewModel shinyHunt, int s
public IActionResult EditIncompleteShinyHunt(int shinyHuntId)
{
ShinyHunt shinyHunt = this.dataService.GetObjectByPropertyValue<ShinyHunt>("Id", shinyHuntId);
List<string> genders = this.dataService.GrabGenders(shinyHunt.PokemonId, "shinyHunt");
if (genders.First() == string.Empty)
{
genders.Remove(string.Empty);
}

EditShinyHuntViewModel model = new EditShinyHuntViewModel(shinyHunt)
{
AllPokemon = this.dataService.GetHuntablePokemon(),
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllGenders = genders,
AllGames = this.dataService.GetShinyHuntGames(shinyHunt.PokemonId),
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: shinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
AppConfig = this.appConfig,
Expand All @@ -445,11 +451,17 @@ public IActionResult EditIncompleteShinyHunt(EditShinyHuntViewModel shinyHunt)
if (!this.ModelState.IsValid)
{
ShinyHunt oldShinyHunt = this.dataService.GetObjectByPropertyValue<ShinyHunt>("Id", shinyHunt.Id);
List<string> genders = this.dataService.GrabGenders(oldShinyHunt.PokemonId, "shinyHunt");
if (genders.First() == string.Empty)
{
genders.Remove(string.Empty);
}

EditShinyHuntViewModel model = new EditShinyHuntViewModel(oldShinyHunt)
{
AllPokemon = this.dataService.GetHuntablePokemon(),
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllPokeballs = this.dataService.GetPokeballs(oldShinyHunt.GameId, oldShinyHunt.HuntingMethodId, this.User, this.appConfig),
AllGenders = genders,
AllGames = this.dataService.GetShinyHuntGames(oldShinyHunt.PokemonId),
AllHuntingMethods = this.dataService.GetObjects<HuntingMethodGameDetail>(includes: "HuntingMethod", whereProperty: "GameId", wherePropertyValue: oldShinyHunt.GameId).ConvertAll(x => x.HuntingMethod),
AppConfig = this.appConfig,
Expand All @@ -474,7 +486,6 @@ public IActionResult EditCompleteShinyHunt(int shinyHuntId)
{
ShinyHunt shinyHunt = this.dataService.GetObjectByPropertyValue<ShinyHunt>("Id", shinyHuntId, "Pokemon, Game");
List<Game> gamesList = this.dataService.GetShinyHuntGames(shinyHunt.PokemonId);
List<string> genders = this.dataService.GrabGenders(shinyHunt.PokemonId, "shinyHunt");

EditShinyHuntViewModel model = new EditShinyHuntViewModel(shinyHunt)
{
Expand All @@ -486,7 +497,7 @@ public IActionResult EditCompleteShinyHunt(int shinyHuntId)
AllPokeballs = this.dataService.GetPokeballs(shinyHunt.GameId, shinyHunt.HuntingMethodId, this.User, this.appConfig),
AllMarks = this.dataService.GetObjects<Mark>(),
AllSweets = this.dataService.GetObjects<Sweet>(),
AllGenders = genders,
AllGenders = this.dataService.GrabGenders(shinyHunt.PokemonId, "shinyHunt"),
AppConfig = this.appConfig,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@
@Html.ValidationMessageFor(x => x.PokeballId)
</div>

@if (Model.AllGenders.Count > 1)
{
<div class="form-group row hide">
@Html.LabelFor(x => x.Gender, "Preferred Gender", new { @class = "col-md-4" })
@Html.DropDownListFor(x => x.Gender, new SelectList(Model.AllGenders), "No Preferred Gender", new { @class = "form-control col-md-6 preferredGender" })
@Html.ValidationMessageFor(x => x.Gender)
</div>
}

<div class="form-group row gameSpecific currentPhaseEncounters">
@Html.LabelFor(x => x.CurrentPhaseEncounters, new { @class = "col-md-4" })
@Html.EditorFor(x => x.CurrentPhaseEncounters, new { htmlAttributes = new { @autocomplete = "off", @class = "form-control col-md-6", @min="0" } })
Expand Down
4 changes: 4 additions & 0 deletions Pokedex/Pokedex/Views/User/ShinyHunts.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@
{
<img loading="lazy" class="pokeball pokemonListPicture" title="Preferred Pokemon: @s.Pokeball.Name" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.OfficialPokeballImageUrl, @s.Pokeball.Id, ".png"))">
}
@if (s.Gender == "Male" || s.Gender == "Female")
{
<img loading="lazy" class="gender pokemonListPicture" title="@s.Gender" src="@Url.Content(string.Concat(@Model.AppConfig.WebUrl, @Model.AppConfig.GeneralImageUrl, @s.Gender.ToLower(), ".png"))">
}
</div>
<a href="@this.Url.Action("PokemonWithOnlyId", "Home", new { pokemonId = @s.Pokemon.Id, generationId = @s.Game.GenerationId })" target="_blank">
@if (Model.IsShared)
Expand Down

0 comments on commit fe73dc8

Please sign in to comment.