public PokemonViewModel(int id) { if (id > 0 && id < 720) { PokedexEntities context = new PokedexEntities(); Starttime = DateTime.Now.Millisecond; detail = context.GetPokemonDetail(id).FirstOrDefault(); Endtime = DateTime.Now.Millisecond; BL.AddLog(new LogData() { nombre = "GetPokemonDetail", tipo = "SP", fecha = DateTime.Now, UserId = SharedInstance.AppUser.UserId, exec_time = (Endtime - Starttime) }); evo = (from e in context.Evolucions where e.PokeID == id select e).FirstOrDefault(); if (evo != null) { ant = (from a in context.Pokemons where a.PokemonID == evo.AntID select a).FirstOrDefault(); sig = (from a in context.Pokemons where a.PokemonID == evo.SigId select a).FirstOrDefault(); } Starttime = DateTime.Now.Millisecond; moves = context.GetMoveRelation(id).ToList(); Endtime = DateTime.Now.Millisecond; BL.AddLog(new LogData() { nombre = "GetMoveRelation", tipo = "SP", fecha = DateTime.Now, UserId = SharedInstance.AppUser.UserId, exec_time = (Endtime - Starttime) }); nameTipo1 = (from t in context.Tipoes where t.TipoID == detail.TpID select t.Nombre).FirstOrDefault(); nameTipo2 = (from t in context.Tipoes where t.TipoID == detail.TpID2 select t.Nombre).FirstOrDefault(); nameHab = (from t in context.Habilidads where t.HabilidadID == detail.HabID select t.Name).FirstOrDefault(); } else { detail = null; } }
public GetTypesViewModel(int id) { PokedexEntities context = new PokedexEntities(); Starttime = DateTime.Now.Millisecond; listPok = context.GetPokemonByType(id).ToList(); Endtime = DateTime.Now.Millisecond; BL.AddLog(new LogData() { nombre = "GetPokemonByType", tipo = "SP", fecha = DateTime.Now, UserId = SharedInstance.AppUser.UserId, exec_time = (Endtime - Starttime) }); Starttime = DateTime.Now.Millisecond; typeRelation = context.GetTypeRelations(id).FirstOrDefault(); Endtime = DateTime.Now.Millisecond; BL.AddLog(new LogData() { nombre = "GetTypeRelations", tipo = "SP", fecha = DateTime.Now, UserId = SharedInstance.AppUser.UserId, exec_time = (Endtime - Starttime) }); }
public ActionResult GetDetails(string SearchString, string Selectedid) { if (SearchString != "") { int id; if (Int32.TryParse(SearchString, out id)) { var pokemon = new PokemonViewModel(id); return(View(pokemon)); } else { Starttime = DateTime.Now.Millisecond; var pokemon = context.GetPokemonByName(SearchString).FirstOrDefault(); Endtime = DateTime.Now.Millisecond; BL.AddLog(new LogData() { nombre = "GetPokemonByName", tipo = "SP", fecha = DateTime.Now, UserId = SharedInstance.AppUser.UserId, exec_time = (Endtime - Starttime) }); if (pokemon != null) { var det = new PokemonViewModel(pokemon.PokemonID); return(View(det)); } else { return(View(new PokemonViewModel())); } } } else { StatsViewModel temp = new StatsViewModel(); temp.Selectedid = int.Parse(Selectedid); return(RedirectToAction("Index", "Stats", temp)); } }