Esempio n. 1
0
        public SocialMediaProfile UpdateProfile(SocialMediaProfile profile)
        {
            SocialMediaProfile tempProfile = ctx.SocialMediaProfiles.Find(profile.Id);

            tempProfile.Url = profile.Url;
            ctx.Entry(tempProfile).State = System.Data.Entity.EntityState.Modified;
            ctx.SaveChanges();
            return(tempProfile);
        }
 public void AddItem(string name, string type, int selectedOrganizationId, string keywords, string twitterUrl)
 {
     if (type == "Person")
     {
         Organization tempOrganization = itemRepository.ReadOrganization(selectedOrganizationId);
         Person       person           = new Person()
         {
             Name = name, Organization = tempOrganization
         };
         Item tempPerson = itemRepository.CreateItem(person);
         if (twitterUrl != null && twitterUrl != " " && twitterUrl != "")
         {
             SocialMediaProfile socialMediaProfile = new SocialMediaProfile()
             {
                 Url = twitterUrl, Source = "Twitter", Item = tempPerson
             };
             SocialMediaProfile tempSocialMediaProfile = itemRepository.CreateSocialmediaprofile(socialMediaProfile);
             ((Person)tempPerson).SocialMediaProfiles.Add(tempSocialMediaProfile);
         }
         itemRepository.UpdateItem(tempPerson);
     }
     else if (type == "Organization")
     {
         Organization organization = new Organization()
         {
             Name = name
         };
         Item tempOrganization = itemRepository.CreateItem(organization);
         if (twitterUrl != null && twitterUrl != " " && twitterUrl != "")
         {
             SocialMediaProfile socialMediaProfile = new SocialMediaProfile()
             {
                 Url = twitterUrl, Source = "Twitter", Item = tempOrganization
             };
             SocialMediaProfile tempSocialMediaProfile = itemRepository.CreateSocialmediaprofile(socialMediaProfile);
             ((Organization)tempOrganization).SocialMediaProfiles.Add(tempSocialMediaProfile);
         }
         itemRepository.UpdateItem(tempOrganization);
     }
     else if (type == "Theme")
     {
         List <string>  keywordsStringList = (keywords.Replace(" ", "").Split(',').ToList <string>());
         List <Keyword> keywordsList       = new List <Keyword>();
         Theme          theme = new Theme()
         {
             Name = name
         };
         Item item = itemRepository.CreateItem(theme);
         foreach (var keyword in keywordsStringList)
         {
             Keyword keywordTemp = itemRepository.CreateKeyword(item, keyword);
             keywordsList.Add(keywordTemp);
         }
         ((Theme)item).Keywords = keywordsList;
         itemRepository.UpdateItem(item);
     }
 }
 public void EditProfiles(List <int> profileIds, string url)
 {
     if (profileIds != null && profileIds.Count != 0 && url != null && url != " ")
     {
         foreach (var profileId in profileIds)
         {
             SocialMediaProfile tempProfile = itemRepository.ReadProfiles(profileId);
             tempProfile.Url = url;
             itemRepository.UpdateProfile(tempProfile);
         }
     }
 }
        public void AddProfileToItem(Item item, string TwitterUrl)
        {
            SocialMediaProfile tempProfile = new SocialMediaProfile()
            {
                Source = "Twitter", Url = TwitterUrl, Item = item
            };

            itemRepository.CreateSocialmediaprofile(tempProfile);
            if (item.GetType().ToString().Contains("Person"))
            {
                ((Person)item).SocialMediaProfiles.Add(tempProfile);
            }
            else if (item.GetType().ToString().Contains("Organization"))
            {
                ((Organization)item).SocialMediaProfiles.Add(tempProfile);
            }
            itemRepository.UpdateItem(item);
        }
Esempio n. 5
0
 public void Visit(SocialMediaProfile profile)
 {
     profile.Views += 350;
     profile.Likes += 1;
 }
 public void Visit(SocialMediaProfile profile)
 {
     profile.Views += 100;
     profile.Likes += 100;
 }
Esempio n. 7
0
 public SocialMediaProfile CreateSocialmediaprofile(SocialMediaProfile socialMediaProfile)
 {
     ctx.SocialMediaProfiles.Add(socialMediaProfile);
     ctx.SaveChanges();
     return(socialMediaProfile);
 }
Esempio n. 8
0
        public static void GenerateData()
        {
            ApplicationUser user1 = new ApplicationUser()
            {
                Id = "1", Admin = false, UserName = "******", Mail = "*****@*****.**"
            };
            ApplicationUser user2 = new ApplicationUser()
            {
                Id = "2", Admin = false, UserName = "******", Mail = "*****@*****.**"
            };

            SocialMediaProfile socialMediaProfile1 = new SocialMediaProfile()
            {
                ProfileId = 1, Url = "http://www.twitter.be/AnnouriImade", Source = "twitter"
            };
            SocialMediaProfile socialMediaProfile2 = new SocialMediaProfile()
            {
                ProfileId = 2, Url = "http://www.twitter.be/BastiaensCaroline", Source = "twitter"
            };
            SocialMediaProfile socialMediaProfile3 = new SocialMediaProfile()
            {
                ProfileId = 3, Url = "http://www.twitter.be/BertelsJan", Source = "twitter"
            };
            SocialMediaProfile socialMediaProfile4 = new SocialMediaProfile()
            {
                ProfileId = 4, Url = "http://www.twitter.be/DeRidderAnnick", Source = "twitter"
            };

            Organization organization1 = new Organization()
            {
                ItemId = 1, Name = "NVA"
            };

            Person person1 = new Person()
            {
                ItemId = 2, Name = "Annouri", FirstName = "Imade", Organization = organization1
            };

            person1.socialMediaProfiles.Add(socialMediaProfile1);
            socialMediaProfile1.Item = person1;
            Person person2 = new Person()
            {
                ItemId = 3, Name = "Bastiaens", FirstName = "Caroline", Organization = organization1
            };

            person2.socialMediaProfiles.Add(socialMediaProfile2);
            socialMediaProfile2.Item = person2;
            Person person3 = new Person()
            {
                ItemId = 4, Name = "Bertels", FirstName = "Jan", Organization = organization1
            };

            person3.socialMediaProfiles.Add(socialMediaProfile3);
            socialMediaProfile3.Item = person3;
            Person person4 = new Person()
            {
                ItemId = 5, Name = "De Ridder", FirstName = "Annick", Organization = organization1
            };

            person4.socialMediaProfiles.Add(socialMediaProfile4);
            socialMediaProfile4.Item = person4;

            organization1.persons.Add(person1);
            organization1.persons.Add(person2);
            organization1.persons.Add(person3);
            organization1.persons.Add(person4);

            Alert alert1 = new Alert(1, AlertType.notification, AlertParameter.tweets, ">", user1, person1);
            Alert alert2 = new Alert(2, AlertType.notification, AlertParameter.tweets, ">", user1, person2);
            Alert alert3 = new Alert(3, AlertType.notification, AlertParameter.tweets, ">", user2, person1);
            Alert alert4 = new Alert(4, AlertType.notification, AlertParameter.tweets, ">", user2, person4);

            person1.Alerts.Add(alert1);
            person1.Alerts.Add(alert3);
            person2.Alerts.Add(alert2);
            person4.Alerts.Add(alert4);
            user1.Alerts.Add(alert1);
            user1.Alerts.Add(alert2);
            user2.Alerts.Add(alert3);
            user2.Alerts.Add(alert4);

            users = new List <ApplicationUser>
            {
                user1,
                user2
            };

            SocialMediaProfiles = new List <SocialMediaProfile>
            {
                socialMediaProfile1,
                socialMediaProfile2,
                socialMediaProfile3,
                socialMediaProfile4
            };

            items = new List <Item>
            {
                organization1,
                person1,
                person2,
                person3,
                person4
            };

            organizations = new List <Organization>
            {
                organization1
            };

            persons = new List <Person>
            {
                person1,
                person2,
                person3,
                person4
            };

            alerts = new List <Alert>
            {
                alert1,
                alert2,
                alert3,
                alert4
            };
        }