public List <lodgedata> alllodges(int locationid) { TAmodel data = new TAmodel(); var dblodges = from i in data.Lodges where i.LOCATION_ID == locationid select i; List <lodgedata> lodges = new List <lodgedata>(); foreach (var i in dblodges) { lodgedata l = new lodgedata(); l.LODGE_ID = i.LODGE_ID; l.LODGE_NAME = i.LODGE_NAME; l.LODGE_ADD = i.LODGE_ADD; l.LOCATION_ID = i.LOCATION_ID; l.PRICE = i.PRICE; var ratings = (from k in data.ratings where k.itemtype == "lodge" && k.itemid == i.LODGE_ID select k.Rating); if (ratings.Any()) { l.rating = ratings.Average(); } else { l.rating = 0; } lodges.Add(l); } return(lodges); }
public List <placedata> locationplaces(int lid) { List <placedata> places = new List <placedata>(); TAmodel model = new TAmodel(); var ptvs = from i in model.Placestovisits where i.locationid == lid select i; foreach (var i in ptvs) { placedata place = new placedata(); place.address = i.address; place.locationid = i.locationid; place.placename = i.placename; place.ptvid = i.ptvid; var rating = (from k in model.ratings where k.itemtype == "placestovisit" && k.itemid == i.ptvid select k.Rating); if (rating.Any()) { place.rating = rating.Average(); } else { place.rating = 0; } places.Add(place); } return(places); }
public int Login(string username, string password) { TAmodel m = new TAmodel(); var uid = (from a in m.Registrations where a.USER_NAME == username && a.PASSWORD == password select a.USER_ID).FirstOrDefault(); int id = int.Parse(uid.ToString()); return(id); }
public void Register(string un, string pass, string eid) { TAmodel m = new TAmodel(); Registration r = new Registration(); r.USER_NAME = un; r.PASSWORD = pass; r.EMAILID = eid; m.Registrations.Add(r); m.SaveChanges(); }
public void addcomment(string itemtype, int itemid, int rating) { TAmodel data = new TAmodel(); rating r = new rating(); // r.Rating_ID = 2; r.itemid = itemid; r.itemtype = itemtype; r.Rating = rating; r.ratedby = 1; data.ratings.Add(r); data.SaveChanges(); }
public List <locationdata> travellocations() { TAmodel data = new TAmodel(); var databaselocations = from i in data.locations select i; List <locationdata> locations = new List <locationdata>(); foreach (var i in databaselocations) { locationdata ldata = new locationdata(); ldata.locationid = i.locationid; ldata.locationname = i.locationname; ldata.description = i.description; locations.Add(ldata); } return(locations); }
public List <Locationmenu> LocationSearch() { TAmodel t = new TAmodel(); List <Locationmenu> LocationList = new List <Locationmenu>(); var res = from a in t.locations select a; foreach (var rec in res) { Locationmenu loc = new Locationmenu(); loc.LID = rec.locationid; loc.LNAME = rec.locationname; loc.DESC = rec.description; LocationList.Add(loc); } return(LocationList); }
public List <routedata> routes(int fromlocation, int tolocation, string modeoftravel) { TAmodel data = new TAmodel(); var hops = from i in data.hops where i.hoplocation == fromlocation || i.hoplocation == tolocation select i; //var dbroutes = from i in data.routes.Include("location") select i; var dbroutes = data.routes.Include("fromloc").Include("toloc").Where(i => i.modeoftravel == modeoftravel).Select(i => i); List <routedata> routes = new List <routedata>(); bool flag = true; foreach (var i in hops) { foreach (var j in hops) { if (i.hopid != j.hopid) { if (i.routeid == j.routeid) { routedata route = new routedata(); var sroute = (from p in dbroutes where p.routeid == i.routeid select p).FirstOrDefault(); if (sroute != null) { route.routeid = sroute.routeid; route.fromlocation = sroute.fromloc.locationname; route.tolocation = sroute.toloc.locationname; foreach (var z in routes) { if (z.routeid == route.routeid) { flag = false; } } if (flag) { routes.Add(route); flag = true; } flag = true; } } } } } return(routes); }
public Restaurantdata restaurant(int restaurantid) { TAmodel data = new TAmodel(); var restaurant = (from i in data.Restaurants where i.RESTAURANT_ID == restaurantid select i).FirstOrDefault(); var ratings = (from i in data.ratings where i.itemtype == "Restaurant" && i.itemid == restaurantid select i.Rating); Restaurantdata r = new Restaurantdata(); r.RESTAURANT_ID = restaurant.RESTAURANT_ID; r.RESTAURANT_NAME = restaurant.RESTAURANT_NAME; r.ADRESS = restaurant.ADRESS; r.LOCATION_ID = restaurant.LOCATION_ID; r.PRICE = restaurant.PRICE; if (ratings.Any()) { r.rating = ratings.Average(); } return(r); }
public lodgedata lodge(int lodgeid) { TAmodel data = new TAmodel(); var lodge = (from i in data.Lodges where i.LODGE_ID == lodgeid select i).FirstOrDefault(); lodgedata l = new lodgedata(); var ratings = (from k in data.ratings where k.itemtype == "lodge" && k.itemid == lodgeid select k.Rating); if (ratings.Any()) { l.rating = ratings.Average(); } else { l.rating = 0; } l.LODGE_ID = lodge.LODGE_ID; l.LODGE_NAME = lodge.LODGE_NAME; l.LODGE_ADD = lodge.LODGE_ADD; l.LOCATION_ID = lodge.LOCATION_ID; l.PRICE = lodge.PRICE; //l.rating = rating; return(l); }
public List <Restaurantdata> allrestaurants(int locationid) { TAmodel data = new TAmodel(); var dbrestaurant = from i in data.Restaurants where i.LOCATION_ID == locationid select i; List <Restaurantdata> restaurants = new List <Restaurantdata>(); foreach (var i in dbrestaurant) { Restaurantdata r = new Restaurantdata(); r.RESTAURANT_ID = i.RESTAURANT_ID; r.RESTAURANT_NAME = i.RESTAURANT_NAME; r.ADRESS = i.ADRESS; r.LOCATION_ID = i.LOCATION_ID; r.PRICE = i.PRICE; var ratings = (from k in data.ratings where k.itemtype == "restaurant" && k.itemid == i.RESTAURANT_ID select k.Rating); if (ratings.Any()) { r.rating = ratings.Average(); } restaurants.Add(r); } return(restaurants); }