Esempio n. 1
0
 public JsonResult Redeem(Gift gift)
 {
     var o = new orm(_data);
     var return_gift = o.GetObject(gift) as Gift;
     var ret_gift = new Gift();
     ret_gift.redeem_token = return_gift.redeem_token;
     var dict = new Dictionary<string, object>();
     dict.Add("gift", ret_gift);
     SendThankYouMail(return_gift);
     return Json(dict);
 }
Esempio n. 2
0
        public ActionResult Claim(string id)
        {
            var gift = new Gift();
            gift.token = id;
            var o = new orm(_data);
            var return_gift = o.GetObject(gift) as Gift;
            var product = new Product();
            product.id = return_gift.product_id;
            product.name = return_gift.name;
            product.picture = return_gift.picture;
            product.token = return_gift.token;
            var dict = new Dictionary<string, object>();
            dict.Add("product", product);
            dict.Add("sender", return_gift.User[0]);
            dict.Add("recipient", return_gift.User[1]);

            TempData["GiftJson"] = JsonConvert.SerializeObject(dict);
            return RedirectToRoute("Home");
        }
Esempio n. 3
0
 public string user(FacebookUser facebookuser)
 {
     try
     {
         var user = new User();
         user.access_token = facebookuser.session.access_token;
         user.name = facebookuser.profile.name;
         user.facebook_id = facebookuser.profile.uid ?? facebookuser.profile.id;
         user.email = facebookuser.profile.email;
         user.picture = facebookuser.profile.pic_square;
         var o = new orm(_data);
         var returned_user = o.SetObject(user).o as User;
         _session.user = returned_user;
         _session.userToken = returned_user.user_token;
         return "\"Result\":{\"status\":0";
     }
     catch (Exception exp)
     {
         log.Error(exp);
         throw;
     }
 }
Esempio n. 4
0
        public static string accessToken(ISession _session, IData _data)
        {
            string _accessToken;
            try
            {

                if (_session.user == null)
                {
                    if (_session.userToken == "" || _session.userToken == null)
                    {
                        //this bloke needs to login before we are going to set any cookie.
                       _accessToken = "NOTOKEN";
                        log.Info("Some user with no token");
                    }
                    else
                    {
                        //get the  user into the session from their cookie
                        var user = new User();
                        user.user_token = _session.userToken;
                        var o = new orm(_data);
                        _session.user = (User)o.GetObject(user);
                        _accessToken = _session.user.access_token;
                    }
                }
                else
                {
                    _accessToken = _session.user.access_token;
                }
            }
            catch (Exception exp)
            {
                log.Error(exp);
                throw;
            }
            return _accessToken;
        }
Esempio n. 5
0
 public JsonResult Send(GiftWrapper gift)
 {
     try
     {
         var sender = new User();
         sender = _session.user;
         sender.role = "SENDER";
         var recipient = new User();
         recipient.facebook_id = gift.recipient.uid;
         recipient.role = "RECIPIENT";
         recipient.name = gift.recipient.name;
         var myGift = new Gift();
         myGift.product_id = "1";
         myGift.User = new User[2];
         myGift.User[0] = sender;
         myGift.User[1] = recipient;
         var o = new orm(_data);
         var returned_gift = o.SetObject(myGift).o as Gift;
         var fb = new FacebookService();
         var port  = (_session._context.Request.Url.Port == 80) ? "" : ":"+_session._context.Request.Url.Port.ToString();
         var hostname = _session._context.Request.Url.Host + port;
         var link = "http://" + hostname + "/gift/claim/?id=" + returned_gift.token;
         fb.StreamPublish(_session.user.access_token, _session.user.name, link, recipient.facebook_id);
         var result = new Result();
         result.status = 0;
         return Json(result);
     }
     catch (Exception exp)
     {
         log.Error(exp.ToString());
         throw;
     }
 }