public Distances GetClosestOffice(double longitude, double latitude) { List <Distances> distances = new List <Distances> (); List <Office> offices = new List <Office> (); bool checky = _cxt.Offices.Any(); DataSeed seed = new DataSeed(_cxt); if (!checky) { if (seed.CreateOffices()) { offices = _cxt.Offices.ToList(); } } else { offices = _cxt.Offices.ToList(); } foreach (Office office in offices) { double dist = DistanceBetweenPlaces(longitude, latitude, office.longitude, office.latitude); Distances distance = new Distances { OfficeId = office.OfficeId, distance = dist, description = office.Description }; distances.Add(distance); } List <Distances> distos = distances.OrderBy(disto => disto.distance).ToList(); return(distos.First()); }
public List <Product> GetProducts() { List <Product> products = new List <Product>(); bool prods = _cxt.Products.Any(); if (prods) { products = _cxt.Products.ToList(); } else { bool create = new DataSeed(_cxt).CreateProducts(); if (create) { products = _cxt.Products.ToList(); } } return(products); }