Esempio n. 1
0
        public async Task <ActionResult> GroupShareathonEdit(string Id)
        {
            User   objuser     = (User)Session["User"];
            string accesstoken = string.Empty;

            if (Session["access_token"] != null)
            {
                accesstoken = Session["access_token"].ToString();
            }
            List <KeyValuePair <string, string> > param = new List <KeyValuePair <string, string> >();
            List <KeyValuePair <string, string> > lst   = new List <KeyValuePair <string, string> >();

            ShareathonGroup sharethons = null;

            HttpResponseMessage response = await WebApiReq.GetReq("api/ApiShareathon/GetGroupShareaton?Id=" + Id, "Bearer", accesstoken);

            if (response.IsSuccessStatusCode)
            {
                sharethons = await response.Content.ReadAsAsync <Domain.Socioboard.Domain.ShareathonGroup>();

                //FacebookClient fb = new FacebookClient();
                //fb.AccessToken = sharethons.AccessToken;
                //System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls;
                //dynamic profile = fb.Get("v2.0/" + sharethons.Facebookgroupid + "?fields=id,name");
                //ViewBag.GroupId = (Convert.ToString(profile["id"]));
                //ViewBag.Groupname = (Convert.ToString(profile["name"]));
                string [] nameId = sharethons.Facebooknameid.Split(',');
                string    id     = "";
                for (int i = 0; i < nameId.Length; i++)
                {
                    string [] name = Regex.Split(nameId[i], "###");
                    id = name[0] + "," + id;
                    //lst.Add(new KeyValuePair<string,string>(nameId[i], name[1]));
                }
                ViewBag.GroupId = id;
                Api.Facebook.Facebook   ApiFacebook      = new Api.Facebook.Facebook();
                List <AddFacebookGroup> lstFacebookGroup = new List <AddFacebookGroup>();
                string fcebookgrp = ApiFacebook.GetAllFacebookGroups(sharethons.AccessToken);
                lstFacebookGroup = (List <AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(fcebookgrp, typeof(List <AddFacebookGroup>)));
                if (lstFacebookGroup.Count > 0)
                {
                    ViewBag.facebbokgroup = lstFacebookGroup;
                }
                else
                {
                    ViewBag.facebbokgroup = null;
                }
            }
            Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
            List <FacebookAccount> facebookaccounts = (List <FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookAccountsByUserIdAndGroupId(objuser.Id.ToString(), Session["group"].ToString()), typeof(List <FacebookAccount>)));

            ViewBag.FbAccounts = facebookaccounts;
            ViewBag.UserId     = objuser.Id;
            ViewBag.Group      = lst;
            return(View(sharethons));
        }
Esempio n. 2
0
        public ActionResult GetAllFacebookGroups(string accesstoken)
        {
            Api.Facebook.Facebook   ApiFacebook      = new Api.Facebook.Facebook();
            List <AddFacebookGroup> lstFacebookGroup = new List <AddFacebookGroup>();
            string fcebookgrp = ApiFacebook.GetAllFacebookGroups(accesstoken);

            lstFacebookGroup = (List <AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(fcebookgrp, typeof(List <AddFacebookGroup>)));
            if (lstFacebookGroup.Count > 0)
            {
                ViewBag.facebbokgroup = lstFacebookGroup;
            }
            else
            {
                ViewBag.facebbokgroup = null;
            }
            return(PartialView("_facebookgrouppartial"));
        }
        public async Task<ActionResult> GroupShareathonEdit(string Id)
        {
            User objuser = (User)Session["User"];
            string accesstoken = string.Empty;
            if (Session["access_token"] != null)
            {
                accesstoken = Session["access_token"].ToString();
            }
            List<KeyValuePair<string, string>> param = new List<KeyValuePair<string, string>>();
            List<KeyValuePair<string, string>> lst = new List<KeyValuePair<string, string>>();

            ShareathonGroup sharethons = null;

            HttpResponseMessage response = await WebApiReq.GetReq("api/ApiShareathon/GetGroupShareaton?Id=" + Id, "Bearer", accesstoken);
            if (response.IsSuccessStatusCode)
            {
                sharethons = await response.Content.ReadAsAsync<Domain.Socioboard.Domain.ShareathonGroup>();
                    string [] nameId=sharethons.Facebooknameid.Split(',');
                    string id = "";
                    for (int i = 0; i < nameId.Length; i++)
			        {
                    string [] name=Regex.Split(nameId[i],"###");
                    id = name[0] + "," + id;
			         //lst.Add(new KeyValuePair<string,string>(nameId[i], name[1]));
			        }
                    ViewBag.GroupId = id;
                    Api.Facebook.Facebook ApiFacebook = new Api.Facebook.Facebook();
                    List<AddFacebookGroup> lstFacebookGroup = new List<AddFacebookGroup>();
                    string fcebookgrp = ApiFacebook.GetAllFacebookGroups(sharethons.AccessToken);
                    lstFacebookGroup = (List<AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(fcebookgrp, typeof(List<AddFacebookGroup>)));
                    if (lstFacebookGroup.Count > 0)
                    {
                        ViewBag.facebbokgroup = lstFacebookGroup;
                    }
                    else { ViewBag.facebbokgroup = null; }
               
            }
            Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
            List<FacebookAccount> facebookaccounts = (List<FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookAccountsByUserIdAndGroupId(objuser.Id.ToString(), Session["group"].ToString()), typeof(List<FacebookAccount>)));
            ViewBag.FbAccounts = facebookaccounts.Where(t=>t.FbUserId!="").ToList();
            ViewBag.UserId = objuser.Id;
            ViewBag.Group = lst;
            return View(sharethons);
        }
 public ActionResult GetAllFacebookGroups(string accesstoken)
 {
     Api.Facebook.Facebook ApiFacebook = new Api.Facebook.Facebook();
     List<AddFacebookGroup> lstFacebookGroup = new List<AddFacebookGroup>();
     string fcebookgrp = ApiFacebook.GetAllFacebookGroups(accesstoken);
     lstFacebookGroup = (List<AddFacebookGroup>)(new JavaScriptSerializer().Deserialize(fcebookgrp, typeof(List<AddFacebookGroup>)));
     if (lstFacebookGroup.Count > 0)
     {
         ViewBag.facebbokgroup = lstFacebookGroup;
     }
     else { ViewBag.facebbokgroup = null; }
      return PartialView("_facebookgrouppartial");
 }