Пример #1
0
 public static bool UpdateSocial(DBO.Social social)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Social t_social = bdd.T_Social.Where(x => x.id == social.Id).FirstOrDefault();
             if (t_social != null)
             {
                 t_social.id         = social.Id;
                 t_social.type       = social.Type;
                 t_social.account    = social.Account;
                 t_social.identifier = social.Identifier;
                 bdd.SaveChanges();
                 return(true);
             }
             else
             {
                 return(false);
             }
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
 public ActionResult Edit([Bind(Include = "Id,Type,Account,Identifier")] DBO.Social social)
 {
     if (ModelState.IsValid)
     {
         //Generated : db.Entry(social).State = EntityState.Modified;
         BusinessManagement.Social.UpdateSocial(social);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(social));
 }
Пример #3
0
        public static void TweetsToArticles(DBO.Social soc, List <DBO.TwitterSocialArticle> list)
        {
            foreach (DBO.TwitterSocialArticle tsa in list)
            {
                DBO.SocialArticle sa = new DBO.SocialArticle();
                sa.Image    = tsa.image;
                sa.Text     = tsa.text;
                sa.SocialId = soc.Id;

                BusinessManagement.SocialArticle.CreateSocialArticle(sa);
            }
        }
Пример #4
0
 public static bool ExecuteRequest(DBO.Social soc)
 {
     try
     {
         List <DBO.TwitterSocialArticle> tweets = getTweets(soc);
         TweetsToArticles(soc, tweets);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public ActionResult Create([Bind(Include = "Id,Type,Account,Identifier")] DBO.Social social)
        {
            if (ModelState.IsValid)
            {
                //Generated : db.Socials.Add(social);
                BusinessManagement.Social.CreateSocial(social);

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(social));
        }
Пример #6
0
        static public void ProcessResponse(DBO.Social s, DBO.FacebookSocialArticles Response)
        {
            Data[] data = Response.data;

            foreach (Data d in data)
            {
                DBO.SocialArticle sa = new DBO.SocialArticle {
                    Text  = d.name + d.message,
                    Image = d.picture, SocialId = s.Id
                };

                BusinessManagement.SocialArticle.CreateSocialArticle(sa);
            }
        }
        // GET: Socials/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //Generated : Social social = db.Socials.Find(id);
            DBO.Social social = BusinessManagement.Social.GetSocial((int)id);

            if (social == null)
            {
                return(HttpNotFound());
            }
            return(View(social));
        }
Пример #8
0
        public ActionResult HandleAccounts()
        {
            if (Request["action"] == "delete" && Request["id"] != null)
            {
                int id;
                if (int.TryParse(Request["id"], out id))
                {
                    BusinessManagement.Social.DeleteSocial(id);
                }
            }
            else if (Request["action"] == "Ajouter")
            {
                if (Request["pageName"] != null && Request["social"] != null && Request["pageIdentifier"] != null)
                {
                    DBO.Social newSocial = new DBO.Social()
                    {
                        Account    = Request["pageName"],
                        Identifier = Request["pageIdentifier"],
                        Type       = Request["social"]
                    };
                    BusinessManagement.Social.CreateSocial(newSocial);
                }
            }

            List <DBO.Social> socials = BusinessManagement.Social.GetListSocial();

            List <DBO.Social> socialsFB      = new List <DBO.Social>();
            List <DBO.Social> socialsTwitter = new List <DBO.Social>();

            foreach (DBO.Social social in socials)
            {
                if (social.Type == "facebook")
                {
                    socialsFB.Add(social);
                }
                if (social.Type == "twitter")
                {
                    socialsTwitter.Add(social);
                }
            }

            ViewBag.socialsFB      = socialsFB;
            ViewBag.socialsTwitter = socialsTwitter;
            return(View());
        }
Пример #9
0
        static public bool ExecuteRequest(DBO.Social s, string access_token)
        {
            try
            {
                string Request = CreateRequest(s, access_token);
                DBO.FacebookSocialArticles Response = MakeRequest(Request);

                if (Response == null)
                {
                    return(false);
                }

                ProcessResponse(s, Response);
                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Пример #10
0
 public static bool CreateSocial(DBO.Social social)
 {
     using (IziWatchEntities bdd = new IziWatchEntities())
     {
         try
         {
             T_Social t_social = new T_Social()
             {
                 id         = social.Id,
                 type       = social.Type,
                 account    = social.Account,
                 identifier = social.Identifier
             };
             bdd.T_Social.Add(t_social);
             bdd.SaveChanges();
             return(true);
         }
         catch (Exception e)
         {
             return(false);
         }
     }
 }
Пример #11
0
        public static List <DBO.TwitterSocialArticle> getTweets(DBO.Social soc)
        {
            List <DBO.TwitterSocialArticle> list = new List <DBO.TwitterSocialArticle>(10);

            Auth.SetUserCredentials(CONSUMER_KEY, CONSUMER_SECRET, ACCESS_TOKEN, ACCESS_TOKEN_SECRET);

            Tweetinvi.Core.Interfaces.IUser user2 = Tweetinvi.User.GetUserFromScreenName("@" + soc.Account);

            var userTimelineParam = new Tweetinvi.Core.Parameters.UserTimelineParameters
            {
                MaximumNumberOfTweetsToRetrieve = 10,
                IncludeRTS = true
            };

            List <Tweetinvi.Core.Interfaces.ITweet> tweets2 = new List <Tweetinvi.Core.Interfaces.ITweet>();

            tweets2 = Timeline.GetUserTimeline(user2, userTimelineParam).ToList();

            foreach (Tweetinvi.Core.Interfaces.ITweet prime2 in tweets2)
            {
                DBO.TwitterSocialArticle tsa = new DBO.TwitterSocialArticle();
                tsa.text = prime2.Text;
                if (prime2.Media.Any())
                {
                    tsa.image = prime2.Media.First().MediaURL;
                }
                else
                {
                    tsa.image = "";
                }

                list.Add(tsa);
            }

            return(list);
        }
 static public void ProcessResponse(DBO.Social s, DBO.FacebookSocialArticles Response)
 {
     DataAccess.FacebookSocialArticles.ProcessResponse(s, Response);
 }
Пример #13
0
        public static string CreateRequest(DBO.Social s, string access_token)
        {
            string UrlRequest = "https://graph.facebook.com/" + s.Identifier + "/feed?fields=message,picture,description,name&limit=10&access_token=" + access_token;

            return(UrlRequest);
        }
Пример #14
0
 public static List <DBO.TwitterSocialArticle> getTweets(DBO.Social soc)
 {
     return(DataAccess.TwitterSocialArticle.getTweets(soc));
 }
Пример #15
0
 public static bool ExecuteRequest(DBO.Social soc)
 {
     BusinessManagement.SocialArticle.DeleteSocialArticlesByType("twitter");
     return(DataAccess.TwitterSocialArticle.ExecuteRequest(soc));
 }
Пример #16
0
 public static void TweetsToArticles(DBO.Social soc, List <DBO.TwitterSocialArticle> list)
 {
     DataAccess.TwitterSocialArticle.TweetsToArticles(soc, list);
 }
Пример #17
0
 public static bool UpdateSocial(DBO.Social social)
 {
     return(DataAccess.Social.UpdateSocial(social));
 }
 static public bool ExecuteRequest(DBO.Social s, string access_token)
 {
     BusinessManagement.SocialArticle.DeleteSocialArticlesByType("facebook");
     return(DataAccess.FacebookSocialArticles.ExecuteRequest(s, access_token));
 }
 public static string CreateRequest(DBO.Social s, string access_token)
 {
     return(DataAccess.FacebookSocialArticles.CreateRequest(s, access_token));
 }