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