public List <Object[]> GetBusinessCheckinDays(Classes.Business business) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECTDIST, c.CHK_day }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.CHK_table }); query.Add(sq.SQL_WHERE, new List <string>() { c.B_id }); query.Add(sq.SQL_COND, new List <string>() { business.business_id }); query.Add(sq.SQL_ORDER, new List <string>() { sq.SQL_ORDER, ";", c.CHK_day }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); return(newObject); }
public Classes.Checkins GetBusinessCheckins(Classes.Business business, String checkinsDay) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECT, "SUM(" + c.CHK_count + ")" }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.CHK_table }); query.Add(sq.SQL_WHERE, new List <string>() { c.B_id, c.CHK_day }); query.Add(sq.SQL_COND, new List <string>() { business.business_id, checkinsDay }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); if (newObject != null && newObject.Count > 0) { return(new Classes.Checkins() { checkin_day = checkinsDay, checkin_count = Int32.Parse(newObject[0][0].ToString()) }); } return(null); }
public void InsertReview(String reviewText, Classes.Business currBuss, String rating) { if (newUser != null) { if (reviewText.Length > 0) { DateTime rightNow = DateTime.Now; query = new Dictionary <string, List <string> >(); String reviewID = new StringHasher.SimpleStringHasher().GetHash(); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_INSERT, c.R_table, "(review_id, business_id, user_id, review_stars, review_date, review_text, funny_vote, useful_vote, cool_vote)" }); query.Add(sq.SQL_VAL, new List <string>() { sq.SQL_VAL, reviewID, currBuss.business_id, newUser.user_Id, rating, rightNow.ToString("MM/dd/yyyy"), reviewText, "0", "0", "0" }); int updated = newQuery.SQLNonQuery(query); ShowStatusUpdate(updated, "Add Review"); } else { ShowStatusUpdate(0, "Please add text, Add Review"); } } }
public List <Classes.Business> GetUserFavorites() { if (newUser != null) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECT, c.FAV_bid }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.FAV_table }); query.Add(sq.SQL_WHERE, new List <String>() { c.FAV_uid }); query.Add(sq.SQL_COND, new List <String>() { newUser.user_Id }); var newObject = newQuery.SQLSelectQuery(query); var businessList = new List <Classes.Business>(); foreach (var item in newObject) { var tempBusiness = new Classes.Business() { business_id = item[0].ToString() }; businessList.Add(tempBusiness); } return(businessList); } return(null); }
public List <Classes.Business> GetBusiness(String BUsername) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECT, c.B_id }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.B_table }); query.Add(sq.SQL_WHERE, new List <string>() { c.B_name }); query.Add(sq.SQL_COND, new List <string>() { BUsername }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); var businessList = new List <Classes.Business>(); foreach (var item in newObject) { var tempBusiness = new Classes.Business() { business_id = item[0].ToString() }; businessList.Add(tempBusiness); } return(businessList); }
public void InsertCheckins(Classes.Business business) { DateTime rightNow = DateTime.Now; query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_UPDATE, c.CHK_table }); query.Add(sq.SQL_SET, new List <string>() { sq.SQL_SET, c.CHK_count }); query.Add(sq.SQL_VAL, new List <string>() { "I", c.CHK_count + " + 1" }); query.Add(sq.SQL_WHERE, new List <string>() { sq.SQL_WHERE, c.CHK_day, c.CHK_time, c.B_id }); query.Add(sq.SQL_COND, new List <string>() { rightNow.ToString("dddd"), rightNow.ToString("hh:mm"), business.business_id }); int updated = newQuery.SQLNonQuery(query); //Does not exist in table so do an insert. if (updated == 0) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_INSERT, c.CHK_table }); query.Add(sq.SQL_VAL, new List <string>() { sq.SQL_VAL, rightNow.ToString("dddd"), rightNow.ToString("hh:mm"), "1", business.business_id }); int newUpdate = newQuery.SQLNonQuery(query); ShowStatusUpdate(newUpdate, "Check In"); } else { ShowStatusUpdate(updated, "Check In"); } }
public void InsertToFavorites(Classes.Business currBuss) { if (newUser != null) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_INSERT, c.FAV_table }); query.Add(sq.SQL_VAL, new List <string>() { sq.SQL_VAL, newUser.user_Id, currBuss.business_id }); int updated = newQuery.SQLNonQuery(query); ShowStatusUpdate(updated, "Add to Favorites"); } }
public List <Classes.Review> GetBusinessReviews(Classes.Business business) { List <Classes.Review> reviewList = new List <Classes.Review>(); query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECT, c.R_date, c.R_reviewStars, c.R_text, c.R_funny, c.R_useful, c.R_cool, c.R_user }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.R_table }); query.Add(sq.SQL_WHERE, new List <string>() { c.B_id }); query.Add(sq.SQL_COND, new List <string>() { business.business_id }); query.Add(sq.SQL_ORDER, new List <string>() { sq.SQL_ORDER, sq.SQL_DESC, c.R_date }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); foreach (Object[] review in newObject) { Classes.Review newReview = new Classes.Review() { review_date = DateTime.Parse(review[0].ToString()).ToString("d"), review_stars = Int32.Parse(review[1].ToString()), review_text = review[2].ToString(), funny_vote = Int32.Parse(review[3].ToString()), useful_vote = Int32.Parse(review[4].ToString()), cool_vote = Int32.Parse(review[5].ToString()), review_username = GetUserDetails(review[6].ToString()).username }; reviewList.Add(newReview); } return(reviewList); }
public Classes.Business GetBusinessDetails(String businessID) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECT, c.B_id, c.B_name, c.B_stars, c.B_city, c.B_zipcode, c.B_address, c.B_latitude, c.B_longitude, c.B_reviewCount, c.B_reviewRating , c.B_numCheckins, c.B_state }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.B_table }); query.Add(sq.SQL_WHERE, new List <string>() { c.B_id }); query.Add(sq.SQL_COND, new List <string>() { businessID }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); Classes.Business tempBusiness = new Classes.Business() { business_id = newObject[0][0].ToString(), name = newObject[0][1].ToString(), stars = Double.Parse(newObject[0][2].ToString()), city = newObject[0][3].ToString(), zipcode = newObject[0][4].ToString(), address = newObject[0][5].ToString(), latitute = Double.Parse(newObject[0][6].ToString()), longtitude = Double.Parse(newObject[0][7].ToString()), review_count = Int32.Parse(newObject[0][8].ToString()), review_rating = Double.Parse(newObject[0][9].ToString()), num_checkins = Int32.Parse(newObject[0][10].ToString()), state = newObject[0][11].ToString() }; return(tempBusiness); }
public List <Classes.Checkins> GetBusinessCheckinDays(Classes.Business business) { query = new Dictionary <string, List <string> >(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECTDIST, c.CHK_day }); query.Add(sq.SQL_FROM, new List <string>() { sq.SQL_FROM, c.CHK_table }); query.Add(sq.SQL_WHERE, new List <string>() { c.B_id }); query.Add(sq.SQL_COND, new List <string>() { business.business_id }); query.Add(sq.SQL_ORDER, new List <string>() { sq.SQL_ORDER, ";", c.CHK_day }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); var checkinList = new List <Classes.Checkins>(); foreach (var item in newObject) { var newCheckin = new Classes.Checkins() { checkin_day = item[0].ToString() }; checkinList.Add(newCheckin); } return(checkinList); }
public List <Classes.Business> GetBusinesses(List <Classes.Attributes> tempAttr, List <string> location, List <string> catArray, List <string> order) { query = new Dictionary <string, List <string> >(); List <String> test = new List <String>(); List <String> test2 = new List <String>(); List <Classes.Business> tempBusinessList = new List <Classes.Business>(); query.Add(sq.SQL_PROJECT, new List <string>() { sq.SQL_SELECTDIST, c.SPEC_id, c.B_name, c.B_address, c.B_city, c.B_state, c.B_latitude, c.B_longitude, c.B_stars, c.B_reviewCount, c.B_reviewRating, c.B_numCheckins }); if (tempAttr.Count > 0) { foreach (Classes.Attributes attr in tempAttr) { test.Add(attr.attribute_name); test2.Add(attr.attribute_value); } query.Add(sq.SQL_ATTR, test); query.Add(sq.SQL_VAL, test2); } if (catArray.Count > 0) { query.Add(sq.SQL_CAT, catArray); } query.Add(sq.SQL_WHERE, new List <string>() { c.B_state, c.B_city, c.B_zipcode }); query.Add(sq.SQL_COND, new List <string>() { location[0], location[1], location[2] }); String origOrder = order[0]; order[0] = order[0].Equals(c.ORD_distance) ? order[0] = c.ORD_name : order[0]; query.Add(sq.SQL_ORDER, new List <string>() { sq.SQL_ORDER, order[1], order[0] }); List <Object[]> newObject = newQuery.SQLSelectQuery(query); Double ratingParse; for (int i = 0; i < newObject.Count; i++) { Double.TryParse(Double.Parse(newObject[i][9].ToString()).ToString("#.##"), out ratingParse); Classes.Business tempBusiness = new Classes.Business() { business_id = newObject[i][0].ToString(), name = newObject[i][1].ToString(), address = newObject[i][2].ToString(), city = newObject[i][3].ToString(), state = newObject[i][4].ToString(), latitute = Double.Parse(newObject[i][5].ToString()), longtitude = Double.Parse(newObject[i][6].ToString()), stars = Double.Parse(newObject[i][7].ToString()), review_count = Int32.Parse(newObject[i][8].ToString()), review_rating = ratingParse, num_checkins = Int32.Parse(newObject[i][10].ToString()), business_distance = "0" }; if (newUser != null) { map.CalculateDistance(new Microsoft.Maps.MapControl.WPF.Location(tempBusiness.latitute, tempBusiness.longtitude), new Microsoft.Maps.MapControl.WPF.Location(newUser.user_latitude, newUser.user_longitude)); double dist = map.GetDistance(); tempBusiness.business_distance = dist.ToString(".## "); } tempBusinessList.Add(tempBusiness); } if (newUser != null && origOrder.Equals(c.ORD_distance)) { tempBusinessList.Sort(delegate(Classes.Business x, Classes.Business y) { return(x.business_distance.CompareTo(y.business_distance)); }); } return(tempBusinessList); }
public void SetLoggedInBusiness(Classes.Business business) { currBusiness = business; }
public void SetCurrentBusiness(Classes.Business business) { newBusiness = business; }