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 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;
        }