Esempio n. 1
0
        public static Guid SubmitNewRetweet(Guid AuthorKey, Guid tweetKey)
        {
            using (var db = new FHNWPrototypeDB())
            {
                Guid newGuid = Guid.NewGuid();

                var wall = db.ContentStreams.FirstOrDefault(x => x.Owner.ReferenceKey == AuthorKey);

                var tweet = db.Tweets.FirstOrDefault(x => x.Key == tweetKey);
                // var author = db.UserAccounts.Single(x => x.Key == AuthorKey);
                var author = db.BasicProfiles.FirstOrDefault(x => x.ReferenceKey == AuthorKey);

                Retweet newRetweet = new Retweet();
                newRetweet.Author = author;
                newRetweet.Key = newGuid;
                newRetweet.PublishDateTime = DateTime.Now;
                newRetweet.Tweet = tweet;
                newRetweet.Wall = wall;

                db.Retweets.Add(newRetweet);
                db.SaveChanges();
                return newGuid;
            }
        }
Esempio n. 2
0
        public static Retweet GetRetweet(Guid key)
        {
            Retweet thisRetweet = new Retweet();

            using (var db = new FHNWPrototypeDB())
            {

                var result = db.Retweets
                   .Include("Author")
                   .Include("Tweet")
                   .FirstOrDefault(x => x.Key == key);

                thisRetweet.Key = result.Key;
                thisRetweet.Tweet = result.Tweet;
                thisRetweet.PublishDateTime = result.PublishDateTime;
                thisRetweet.Author = result.Author;

            }

            return thisRetweet;
        }