// Add new route to the saved route in the DB. private void addToSavedRoute(smart_trip_dbEntities se, List <sites> newRoute, int cityId) { var route = new routes(); route.name = "Route number " + (se.routes.Count() + 1).ToString(); route.city_id = cityId; route.user_id = ADMIN_ID; route.sites = getSitesString(newRoute); route.image_url = NEW_YORK_IMAGE_URL; route.rate = DEFAULT_RATE; route.description = DEFAULT_DESCRIPTION; se.routes.Add(route); se.SaveChanges(); }
public HttpResponseMessage login(UserConnection user) { using (smart_trip_dbEntities se = new smart_trip_dbEntities()) { var user_ = getUserIfExists(se, user.userName, user.password, user.deviceToken); if (user_ == null) { user_ = new users(); user_.uname = user.userName; user_.password = user.password; user_.device_token = user.deviceToken; se.users.Add(user_); se.SaveChanges(); } var cities = se.cities.ToList(); var sites = se.sites.Where(s => s.city_id == 1).ToList(); var categories = se.sites_types.ToList(); var recommandedRoutes = se.routes.Where(s => s.rate != null && s.rate >= 4).ToList(); return(rh.HandleResponse(new { user = user_, sites = sites, cities = cities, categories = categories, recommanded_routes = recommandedRoutes })); } }