コード例 #1
0
        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();

        }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
        public async Task<ActionResult> EditGroup(ShareathonGroupViewModel shareathon)
        {
            string groupId = "";
            string nameId = "";
            for (int i = 0; i < shareathon.FacebookGroupId.Length; i++)
            {
                string dataid = shareathon.FacebookGroupId[i];
                string[] grpid = Regex.Split(dataid, "###");
                groupId = grpid[0] + "," + groupId;
                nameId = shareathon.FacebookGroupId[i] + "," + nameId;
            }
            User objUser = (User)Session["User"];
            List<KeyValuePair<string, string>> Parameters = new List<KeyValuePair<string, string>>();
            Parameters.Add(new KeyValuePair<string, string>("Facebookaccountid", shareathon.Facebookaccountid.ToString()));
            Parameters.Add(new KeyValuePair<string, string>("Id", shareathon.Id.ToString()));
            Parameters.Add(new KeyValuePair<string, string>("Userid", objUser.Id.ToString()));
            Parameters.Add(new KeyValuePair<string, string>("FacebookPageUrl", shareathon.FacebookPageUrl));
            Parameters.Add(new KeyValuePair<string, string>("FacebookGroupId", groupId));
            Parameters.Add(new KeyValuePair<string, string>("Facebooknameid", nameId));
            Parameters.Add(new KeyValuePair<string, string>("Timeintervalminutes", shareathon.Timeintervalminutes.ToString()));
            string accesstoken = string.Empty;
            string UserId = objUser.Id.ToString();
            if (Session["access_token"] != null)
            {
                accesstoken = Session["access_token"].ToString();
            }

            HttpResponseMessage response = await WebApiReq.PostReq("api/ApiShareathon/EditShareathonGroup", Parameters, "Bearer", accesstoken);
            if (response.IsSuccessStatusCode)
            {
                return RedirectToAction("GroupIndex");
            }
            List<FacebookAccount> lstFacebookAccount = new List<FacebookAccount>();
            Api.FacebookAccount.FacebookAccount ApiobjFacebookAccount = new Api.FacebookAccount.FacebookAccount();
            List<FacebookAccount> facebookaccounts = (List<FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookAccountsByUserIdAndGroupId(objUser.Id.ToString(), System.Web.HttpContext.Current.Session["group"].ToString()), typeof(List<FacebookAccount>)));
            List<FacebookAccount> facebookpages = (List<FacebookAccount>)(new JavaScriptSerializer().Deserialize(ApiobjFacebookAccount.GetAllFacebookPageByUserIdAndGroupId(objUser.Id.ToString(), System.Web.HttpContext.Current.Session["group"].ToString()), typeof(List<FacebookAccount>)));

            foreach (FacebookAccount item in facebookpages)
            {
                if (item != null)
                {
                    lstFacebookAccount.Add(item);
                }
            }
            if (lstFacebookAccount.Count > 0)
            {
                ViewBag.FbPages = lstFacebookAccount;
                Session["FbPages"] = ViewBag.FbPages;
            }
            else
            {
                ViewBag.FbPages = null;
            }
            ViewBag.FbAccounts = facebookaccounts.Where(t => t.FbUserId != "").ToList();
            ViewBag.UserId = objUser.Id;
            return View();
        }