Ejemplo 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);
 }
Ejemplo 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");
        }
Ejemplo n.º 3
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;
     }
 }
Ejemplo n.º 4
0
        public void SendThankYouMail(Gift gift)
        {
            var subject = gift.User[1].name  + " says thanks for the gift";
               var body = "Dear " + gift.User[0].name + " " + gift.User[1].name + " has now redeemed your gift and is very happy. Best wishes, the Ziftly team";
               var toAddress = gift.User[0].email;

               var mail = new Mail(subject,body, toAddress);
               mail.SendMail();
        }