public void AddRoute(Models.Route route) { DodgingBranches.Data.Route myRoute = MapRouteModelToDb(route); using (var db = new RouteContext()) { db.Routes.Add(myRoute); db.SaveChanges(); } }
public Models.Route GetRoute(int id) { Models.Route returnRoute; using (var db = new RouteContext()) { var routeFromDb = db.Routes.Find(id); returnRoute = MapDbToRouteModel(routeFromDb); } return returnRoute; }
public List<Models.Route> GetRoutesForLocation(int latitude, int longitude) { var returnList = new List<Models.Route>(); var routesFromDb = new List<Route>(); using (var db = new RouteContext()) { routesFromDb = db.Routes.Select(x=>x).ToList(); foreach (var route in routesFromDb) { returnList.Add(MapDbToRouteModel(route)); } } return returnList; }