Exemplo n.º 1
0
 public static void AddSubscription(Subscription model)
 {
     using (var context = new NewsFeedDBEntities())
     {
         context.Subscription.Add(model);
         context.SaveChanges();
     }
 }
Exemplo n.º 2
0
 public static void AddFeed(Feed model)
 {
     using (var context = new NewsFeedDBEntities())
     {
         context.Feed.Add(model);
         context.SaveChanges();
     }
 }
Exemplo n.º 3
0
 public static void AddNewsFeed(NewsFeed newsFeed)
 {
     using (var context = new NewsFeedDBEntities())
     {
         context.NewsFeed.Add(newsFeed);
         context.SaveChanges();
     }
 }
Exemplo n.º 4
0
 public static Users Register(Users user)
 {
     using (var context = new NewsFeedDBEntities())
     {
         context.Users.Add(user);
         context.SaveChanges();
         return(user);
     }
 }
Exemplo n.º 5
0
 public static void RemoveSubscription(Subscription model)
 {
     using (var context = new NewsFeedDBEntities())
     {
         var sub = context.Subscription.Where(x => x.UserId == model.UserId && x.FeedId == model.FeedId).FirstOrDefault();
         context.Subscription.Remove(sub);
         context.SaveChanges();
     }
 }
        public static void InsertDefaultData()
        {
            using (var context = new NewsFeedDBEntities())
            {
                var user = new Users {
                    Name = "Default", Password = "******"
                };
                context.Users.Add(user);
                context.SaveChanges();

                var feed = new Feed {
                    Name = "Sports", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true
                };
                context.Feed.Add(feed);
                context.SaveChanges();
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Football", Description = "World Cup Qatar 2022 is comming.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Baseball", Description = "The official news source of Major League Baseball.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Voleyball", Description = "Volleyball news, interviews, transfers, videos and more.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.SaveChanges();

                feed = new Feed {
                    Name = "Food", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true
                };
                context.Feed.Add(feed);
                context.SaveChanges();
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Chinese", Description = "Find out what Chinese dishes to try in China, soon!", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Mexican", Description = "All the latest breaking news on Mexican Food.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Fast food", Description = "KFC hints at plan for plant-based chicken alternative.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.SaveChanges();

                feed = new Feed {
                    Name = "Vacations", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true
                };
                context.Feed.Add(feed);
                context.SaveChanges();
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Costa Rica", Description = "All the latest breaking news on Costa Rica travel.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Grand Canyon", Description = "If you want to really explore the Grand Canyon, you need to plan a day trip on your next vacation in Vegas.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.NewsFeed.Add(new NewsFeed {
                    Title = "Mexico", Description = "Cancun ranks as the top international destination this holiday season for U.S. travelers.", CreateDate = DateTime.Now, CreatedBy = user.Id, Active = true, FeedId = feed.Id
                });
                context.SaveChanges();
            }
        }