public void PostData(ShareathonGroup item) { FacebookAccount facebookAccount = sharegrprepo.getFbAccount(item.Facebookaccountid); string feedId = string.Empty; string[] pageid = item.Facebookpageid.Split(','); foreach (string item_str in pageid) { string feeds = FacebookHelper.getFacebookRecentPost(item.AccessToken, item_str); try { if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]")) { JObject fbpageNotes = JObject.Parse(feeds); foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString())) { try { string feedid = obj["id"].ToString(); feedid = feedid.Split('_')[1]; feedId = feedid + "," + feedId; } catch { } } } } catch (Exception ex) { } } FacebookHelper.postfeedGroup(item.AccessToken, item.Facebookgroupid, feedId, facebookAccount.FbUserId, item.Timeintervalminutes); }
public IHttpActionResult EditShareathon(ShareathonGroupViewModel sharethon) { string groupId = ""; string nameId = ""; ShareathonGroup eidtShareathon = sharegrprepo.getShareathon(sharethon.Id); FacebookAccount facebookAccount = sharepo.getFbAccount(sharethon.Facebookaccountid); string pageid = FacebookHelper.GetFbPageDetails(sharethon.FacebookPageUrl, facebookAccount.AccessToken); eidtShareathon.Facebookaccountid = facebookAccount.Id; eidtShareathon.Facebookpageid = pageid; eidtShareathon.FacebookPageUrl = sharethon.FacebookPageUrl; eidtShareathon.Timeintervalminutes = sharethon.Timeintervalminutes; for (int i = 0; i < sharethon.FacebookGroupId.Length; i++) { string dataid = sharethon.FacebookGroupId[i]; string[] grpid = Regex.Split(dataid, "###"); groupId = grpid[0] + "," + groupId; nameId = sharethon.FacebookGroupId[i] + "," + nameId; } eidtShareathon.Facebookgroupid = groupId.TrimEnd(','); eidtShareathon.Facebooknameid = nameId.TrimEnd(','); if (sharegrprepo.updateShareathon(eidtShareathon)) { return(Ok()); } else { return(BadRequest()); } }
public bool AddShareathon(ShareathonGroup shareathon) { bool IsSuccess = false; //Creates a database connection and opens up a session using (NHibernate.ISession session = SessionFactory.GetNewSession()) { //After Session creation, start Transaction. using (NHibernate.ITransaction transaction = session.BeginTransaction()) { //Proceed action, to Save data. try { session.Save(shareathon); transaction.Commit(); IsSuccess = true; return(IsSuccess); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); return(IsSuccess); } } //End Transaction } //End Session }
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)); }
public IHttpActionResult AddGroupSharethon(ShareathonGroupViewModel sharethon) { Domain.Socioboard.Domain.ShareathonGroup _ShareathonGroup = new ShareathonGroup(); string groupId = ""; string nameId = ""; Domain.Socioboard.Domain.FacebookAccount facebookAccount = sharegrprepo.getFacebookAccountDetailsByUserProfileId(sharethon.Facebookaccountid, sharethon.Userid); string pageid = FacebookHelper.GetFbPageDetails(sharethon.FacebookPageUrl, facebookAccount.AccessToken); _ShareathonGroup.Id = Guid.NewGuid(); _ShareathonGroup.Facebookpageid = pageid.TrimEnd(','); _ShareathonGroup.FacebookPageUrl = sharethon.FacebookPageUrl; _ShareathonGroup.AccessToken = facebookAccount.AccessToken; _ShareathonGroup.Facebookaccountid = facebookAccount.FbUserId; _ShareathonGroup.Userid = sharethon.Userid; _ShareathonGroup.Timeintervalminutes = sharethon.Timeintervalminutes; _ShareathonGroup.IsHidden = false; _ShareathonGroup.FacebookStatus = 1; for (int i = 0; i < sharethon.FacebookGroupId.Length; i++) { string dataid = sharethon.FacebookGroupId[i]; string[] grpid = Regex.Split(dataid, "###"); groupId = grpid[0] + "," + groupId; } _ShareathonGroup.Facebooknameid = sharethon.Facebooknameid.TrimEnd(','); _ShareathonGroup.Facebookgroupid = groupId.TrimEnd(','); if (!sharegrprepo.IsShareathonExist(sharethon.Userid, groupId, pageid)) { if (sharegrprepo.AddShareathon(_ShareathonGroup)) { return(Ok()); } else { return(BadRequest()); } } else { return(BadRequest("Shareathon exist")); } return(Ok()); }
public void PostData(ShareathonGroup item) { Domain.Socioboard.Domain.FacebookAccount facebookAccount = sharegrprepo.getFacebookAccountDetailsByUserProfileId(item.Facebookaccountid, item.Userid); string feedId = string.Empty; string[] pageid = item.Facebookpageid.Split(','); foreach (string item_str in pageid) { string feeds = FacebookHelper.getFacebookRecentPost(facebookAccount.AccessToken, item_str); try { if (!string.IsNullOrEmpty(feeds) && !feeds.Equals("[]")) { JObject fbpageNotes = JObject.Parse(feeds); foreach (JObject obj in JArray.Parse(fbpageNotes["data"].ToString())) { try { string feedid = obj["id"].ToString(); feedid = feedid.Split('_')[1]; feedId = feedid + "," + feedId; } catch { } } FacebookHelper.postfeedGroup(item.AccessToken, item.Facebookgroupid, feedId, facebookAccount.FbUserId, item.Timeintervalminutes, item.Id); } else { facebookAccount.IsActive = 2; facebookrepo.updateFacebookUserStatus(facebookAccount); sharegrprepo.UpadteShareathonByFacebookUserId(facebookAccount.FbUserId, facebookAccount.UserId); } } catch (Exception ex) { } } }
public IHttpActionResult GetGroupShareaton(string Id) { Guid id = Guid.Empty; try { id = Guid.Parse(Id); } catch (Exception ex) { return(BadRequest()); } if (id == Guid.Empty) { return(BadRequest()); } else { ShareathonGroup sharegrp = sharegrprepo.getShareathon(id); return(Ok(sharegrp)); } }