public async Task <IActionResult> Edit(int id, [Bind("ID,Breed,adaptability,friendliness,health,grooming,training,exercise")] BreedInfo breedInfo) { if (id != breedInfo.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(breedInfo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BreedInfoExists(breedInfo.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(breedInfo)); }
public List <Dog> SendDogs() { List <BreedInfo> bi = GetBreedInfo(); List <Dogintelligence> di = GetDogIntelligences(); List <Dog> dogs = new List <Dog>(); foreach (Dogintelligence item in di) { Dog dog = new Dog(); dog.breed = item.breed; dog.classification = item.classification; if (item.obey < 29) { dog.obey = 0; } else { dog.obey = item.obey; } dog.lowRep = item.lowReps; dog.highRep = item.highReps; BreedInfo bInf = bi.FirstOrDefault(x => x.breed == item.breed) as BreedInfo; if (bInf != null) { dog.medianInch = (bInf.lowInches + bInf.highInches) / 2; dog.medianLbs = (bInf.lowLbs + bInf.highLbs) / 2; } dogs.Add(dog); } return(dogs); }
public List <BreedInfo> GetBreedInfo() { List <BreedInfo> bi = new List <BreedInfo>(); try { cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "Select * from AKCBreedInfo"; conn.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { BreedInfo bInf = new BreedInfo(); bInf.breed = reader[0].ToString(); bInf.lowInches = int.Parse(reader[1].ToString()); bInf.highInches = int.Parse(reader[2].ToString()); bInf.lowLbs = int.Parse(reader[3].ToString()); bInf.highLbs = int.Parse(reader[4].ToString()); bi.Add(bInf); } reader.Close(); } catch (Exception e) { Console.Write(e); } cmd.Connection.Close(); return(bi); }
public async Task <IActionResult> Create([Bind("ID,Breed,adaptability,friendliness,health,grooming,training,exercise")] BreedInfo breedInfo) { if (ModelState.IsValid) { _context.Add(breedInfo); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(breedInfo)); }
public static EggSource6[] Validate(int generation, int species, int form, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource6>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var index = table.GetFormIndex(species, form); var learnset = learn[index]; var egg = MoveEgg.GetEggMoves(generation, species, form, version); var actual = new EggSource6[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource6>(actual, possible, learnset, moves, level); if (species is (int)Species.Pichu && moves[count - 1] is (int)Move.VoltTackle) { actual[--count] = VoltTackle; } if (count == 0) { valid = VerifyBaseMoves(value); } else { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(value.Actual); }
public static EggSource2[] Validate(int species, GameVersion version, ReadOnlySpan <int> moves, out bool valid) { var count = moves.IndexOf(0); if (count == 0) { valid = false; // empty moveset return(Array.Empty <EggSource2>()); } if (count == -1) { count = moves.Length; } var learn = GameData.GetLearnsets(version); var table = GameData.GetPersonal(version); var learnset = learn[species]; var pi = table[species]; var egg = (version == GameVersion.C ? Legal.EggMovesC : Legal.EggMovesGS)[species].Moves; var actual = new EggSource2[count]; Span <byte> possible = stackalloc byte[count]; var value = new BreedInfo <EggSource2>(actual, possible, learnset, moves, level); { bool inherit = Breeding.GetCanInheritMoves(species); MarkMovesForOrigin(value, egg, count, inherit, pi, version); valid = RecurseMovesForOrigin(value, count - 1); } if (!valid) { CleanResult(actual, possible); } return(actual); }