Exemple #1
0
 public static string RIDE_REQ_REQUESTS_BY_USER(FacebookUser inFacebookUser_, Boolean isHost)
 {
     if (isHost)
         return string.Format("SELECT * FROM rh_riderequests WHERE requestedtoid = {0}", inFacebookUser_.FbId);
     else
         return string.Format("SELECT * FROM rh_riderequests WHERE requestedbyid = {0}", inFacebookUser_.FbId);
 }
Exemple #2
0
 public List<RideHostSession> GetPostedRides(int inAmt_, Enums.SortRideBy inSortRideBy_, FacebookUser inFacebookUser_ = null)
 {
     if (inFacebookUser_ != null)
         return _rideManager.GetRideSessions(inFacebookUser_);
     else
         return _rideManager.GetRideSessions(inSortRideBy_, inAmt_);
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.QueryString["error"] == "access_denied")
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('User has denied access.')", true);
                    Response.Redirect("/Front.aspx");
                    return;
                }

                string code = Request.QueryString["code"];
                if (!string.IsNullOrEmpty(code))
                {
                    string access_token_data = Fetch_Access_Token(code);
                    string user_token = access_token_data.Split("=".ToCharArray())[1].Split("&".ToCharArray())[0];
                    FacebookClient fb = new FacebookClient(user_token);
                    fb.AppSecret = FacebookHelper.API_Secret;
                    fb.AppId = FacebookHelper.API_Key;

                    var result = (IDictionary<string, object>)fb.Get("/me");
                    string name = (string)result["name"];
                    long fb_id = long.Parse((string)result["id"]);
                    string email = (string)result["email"];
                    string pictureurl = string.Format("https://graph.facebook.com/{0}/picture", fb_id);

                    RideHop.Data.Lib.Entity.FacebookUser faceBookUser = new FacebookUser() { Name = name, FbId = fb_id, Email = email, PictureUrl = pictureurl };
                    DataService ds = new DataService();
                    //var test = ds.AuthenticateUser(faceBookUser);
                    Session.Add("logged_in", true);
                    Session.Add("rh_user", faceBookUser);
                }
                Response.Redirect("/Front.aspx");
            }
        }
Exemple #4
0
 public List<RideHostSession> GetRideSessions(FacebookUser inFacebookUser_)
 {
     if (this._sqlData.OpenConnection() == true)
         return ParseRideSessionByQuery(Queries.RIDE_SESSION_LOOKUP_BY_USERID(inFacebookUser_));
     else
         throw new Exception("Can't connect to MySQL server");
 }
Exemple #5
0
 public List<RideRequest> GetRideRequestsByUser(FacebookUser inFacebookUser_, Boolean isHost_)
 {
     if (this._sqlData.OpenConnection() == true)
         return ParseRideRequestByQuery(Queries.RIDE_REQ_REQUESTS_BY_USER(inFacebookUser_, isHost_));
     else
         throw new Exception("Can't connect to MySQL server");
 }
Exemple #6
0
 //REVIEwS
 public static string REVIEWS_LOOKUP_BY_USER_ID(FacebookUser User_, Boolean isHost_)
 {
     if (isHost_)
         return string.Format("SELECT * FROM rh_reviews WHERE reviewtoid = {0}", User_.FbId);
     else
         return string.Format("SELECT * FROM rh_reviews WHERE reviewerid = {0}", User_.FbId);
 }
Exemple #7
0
 public List<Review> GetReviewsByUser(FacebookUser inUser_, Boolean isHost_)
 {
     if (this._sqlData.OpenConnection() == true)
     {
         return ParseReviewsByQuery(Queries.REVIEWS_LOOKUP_BY_USER_ID(inUser_, isHost_));
     }
     else
     {
         throw new Exception("Can't connect to MySQL server");
     }
 }
Exemple #8
0
        public Boolean RegisterUser(FacebookUser inUserAcc_)
        {
            if (this._sqlData.OpenConnection() == true)
            {
                using (MySqlCommand tmpCmd = new MySqlCommand(Queries.USER_EXISTS(inUserAcc_), this._sqlData.SQLConnection))
                {
                    using (MySqlDataReader dataReader = tmpCmd.ExecuteReader())
                        while (dataReader.Read()) { return false; }

                    tmpCmd.CommandText = Queries.USER_REGISTER(inUserAcc_);
                    tmpCmd.ExecuteNonQuery();
                }

                return true;
            }
            else
            {
                throw new Exception("Can't connect to MySQL server");
            }
        }
        static void Runn(string[] args)
        {
            DataService ds = new DataService();
            FacebookUser fb = new FacebookUser() { FbId = 666, AboutMe = "werwer", Email = "*****@*****.**", Name = "AHILAN", Phone = "911", PictureUrl = "YYYY" };
            FacebookUser fb2 = new FacebookUser() { FbId = 667, AboutMe = "werwer", Email = "*****@*****.**", Name = "AHILAN2", Phone = "911", PictureUrl = "YYYY" };
            FacebookUser fb3 = new FacebookUser() { FbId = 668, AboutMe = "werwer", Email = "*****@*****.**", Name = "AHILAN3", Phone = "911", PictureUrl = "YYYY" };
            ds.AuthenticateUser(fb);
            ds.AuthenticateUser(fb2);
            ds.AuthenticateUser(fb3);
            List<long> hi = new List<long> { 12, 12, 12, 12 };
            RideHostSession s1 = new RideHostSession() { RideHostID = 666, PostedTime = DateTime.Now, DepartTime = DateTime.Now, EstimatedArrivalTime = DateTime.Now, LocationTo = "Toronto", LocationFrom = "Waterloo", Riders = new long[] { 1, 1, 1 }, RideRequests = hi, Price = 12, AdditionalMessage = "no" };
            RideHostSession s2 = new RideHostSession() { RideHostID = 699, PostedTime = DateTime.Now, DepartTime = DateTime.Now, EstimatedArrivalTime = DateTime.Now, LocationTo = "Markham", LocationFrom = "Waterloo", Riders = new long[] { 1, 1, 1 }, RideRequests = hi, Price = 12, AdditionalMessage = "no" };
            RideHostSession s3 = new RideHostSession() { RideHostID = 698, PostedTime = DateTime.Now, DepartTime = DateTime.Now, EstimatedArrivalTime = DateTime.Now, LocationTo = "Ajax", LocationFrom = "Waterloo", Riders = new long[] { 1, 1, 1 }, RideRequests = hi, Price = 12, AdditionalMessage = "no" };
            RideHostSession s4 = new RideHostSession() { RideHostID = 697, PostedTime = DateTime.Now, DepartTime = DateTime.Now, EstimatedArrivalTime = DateTime.Now, LocationTo = "Weber", LocationFrom = "Waterloo", Riders = new long[] { 1, 1, 1 }, RideRequests = hi, Price = 12, AdditionalMessage = "no" };
            ds.StoreRideSession(s1);
            RideRequest r1 = new RideRequest() {RequestedById = 667, RequestedToId = 666, SessionId = s1.SessionID, AdditionalMessage = "hey", Accepted = false, SeenByHost = false, SeenByRequester = false };
            RideRequest r2 = new RideRequest() { RequestedById = 668, RequestedToId = 666, SessionId = s1.SessionID, AdditionalMessage = "heyyo", Accepted = false, SeenByHost = false, SeenByRequester = false };
            ds.StoreRideRequest(r1);
            ds.StoreRideRequest(r2);

            List<RideRequest> hi2 = ds.GetRequests(fb2, true, 10);
            ds.GetPostedRides(10, Lib.Enums.SortRideBy.Hot, fb);
        }
Exemple #10
0
 public List<RideRequest> GetRequests(FacebookUser inFacebookUser_, Boolean isHost_, int inAmt_)
 {
     return _rideManager.GetRideRequestsByUser(inFacebookUser_, isHost_);
 }
Exemple #11
0
 public List<Review> GetReviews(FacebookUser inUser_, bool isHost_)
 {
     return _reviewManager.GetReviewsByUser(inUser_, isHost_);
 }
Exemple #12
0
        public Tuple<List<RideHostSession>, List<RideRequest>> AuthenticateUser(FacebookUser inFacebookUser_)
        {
            _userManager.RegisterUser(inFacebookUser_);

            return new Tuple<List<RideHostSession>, List<RideRequest>>(_rideManager.GetRideSessions(Enums.SortRideBy.Recent, 3), _rideManager.GetRideRequestsByUser(inFacebookUser_, true));
        }
Exemple #13
0
 public static string RIDE_SESSION_LOOKUP_BY_USERID(FacebookUser inUserAccount_)
 {
     return string.Format("SELECT * FROM rh_ridehostsessions r WHERE r.ridehostid = {0}", inUserAccount_.Id);
 }
Exemple #14
0
 public Boolean UpdateUser(FacebookUser inFacebookUser_)
 {
     return _userManager.UpdateUser(inFacebookUser_);
 }
Exemple #15
0
 public Boolean UpdateUser(FacebookUser inUserAcc_)
 {
     return _sqlData.ExecuteNonQuery(Queries.USER_UPDATE(inUserAcc_));
 }
Exemple #16
0
 //USER QUERIES
 public static string USER_EXISTS(FacebookUser User_)
 {
     return string.Format("SELECT * FROM rh_users WHERE fbid = '{0}'", User_.FbId);
 }
Exemple #17
0
 public static string USER_REGISTER(FacebookUser inAccount_)
 {
     return string.Format("INSERT INTO rh_users VALUES (NULL, '{0}', '{1}', '{2}', '{3}', '{4}', '{5}')",
                             inAccount_.FbId,
                             inAccount_.Name,
                             inAccount_.Email,
                             inAccount_.Phone,
                             inAccount_.AboutMe,
                             inAccount_.PictureUrl);
 }
Exemple #18
0
 public static string USER_UPDATE(FacebookUser inUserToUpdate_)
 {
     return string.Format("UPDATE rh_users t SET t.`aboutme` = '{0}', t.`phone` = '{1}', t.`fbpictureurl` = '{2}', t.`name` = '{3}'  WHERE t.`fbid` = {4}",
                             inUserToUpdate_.AboutMe,
                             inUserToUpdate_.Phone,
                             inUserToUpdate_.PictureUrl,
                             inUserToUpdate_.Name,
                             inUserToUpdate_.FbId);
 }