public void update(TownsContext context) { //Ta ut alla svenska städer i en lista List <World> worldCities = context.World .Where(t => t.Country == "Sweden") .ToList(); //Hjälptal double latitude = Double.Parse(DDLatitude.Replace('.', ',')); double longitude = Double.Parse(DDLongitude.Replace('.', ',')); double min = 12345678; //Hitta närmsta staden foreach (var t in worldCities) { double katetA = (double)Math.Pow(latitude - t.DDLatitude, 2); double katetB = (double)Math.Pow(longitude - t.DDLongitude, 2); double hypotenusan = (double)Math.Sqrt(katetA + katetB); //Närmaste hittils if (hypotenusan < min) { Name = t.Name; Population = t.Population; min = hypotenusan; } } }
public ShowTown(TownsContext context) { allTowns = new List <TownViewModel>(); foreach (var town in context.Sweden) { allTowns.Add(new TownViewModel { ID = town.Id, Name = town.Town, Population = town.Population }); } }
public Sweden ValidateTown(TownViewModel town, TownsContext context) { Sweden sweTown = context.Sweden /* Use for Eager Loading commented because we r Lazy! * .Include(i => i.EmployeeTerritories) * .ThenInclude(i => i.Territory) **/ .Where(s => s.Town.StartsWith(town.Name.ToLower())) .FirstOrDefault(); return(sweTown); }
public GMapsController(TownsContext context) { this.context = context; }
public TownInputController(TownsContext context) { this.context = context; }
public WorldTownController(TownsContext context) { this.context = context; }