Example #1
0
        private IEnumerable<BaseBeek> ParseToBeek(XDocument doc)
        {
            foreach (XElement bookData in doc.Descendants("BookData"))
            {
                IsbnDbBeek isbnDbBeek = new IsbnDbBeek(bookData);

                BaseBeek beek = new BaseBeek(BeekTypes.LongStory)
                {
                    Title = isbnDbBeek.Title,
                    Isbn = isbnDbBeek.Isbn
                };

                if (isbnDbBeek.Authors.Any())
                {
                    //For users that don't exist yet, we'll create them..
                    accountService.CreateUsersInBatch(
                        isbnDbBeek.Authors.Where(name => !accountService.DoesUserExist(name)), Contributions.Writer, Sources.IsbnDb);

                    //now add al those users!
                    IEnumerable<UserSearchbag> bags =
                        isbnDbBeek.Authors.Select(authorName => new UserSearchbag { UserNameContains = authorName });
                    var users = accountSearchService.SearchUsers(bags);
                    Parallel.ForEach(users, user => user.AddContribution(Contributions.Writer));
                    beek.InvolveUsers(users, Contributions.Writer);
                }
                yield return beek;
            }
        }
Example #2
0
        public void CanInvolveUsers()
        {
            BaseBeek story = new BaseBeek(BeekTypes.ShortStory);
            List<IUser> writers = GenerateWriters().ToList();

            story.InvolveUsers(writers, Contributions.Writer);
            CollectionAssert.AreEquivalent(story.GetInvolvedUsersForContribution(Contributions.Writer).ToArray(), writers.ToArray());
            // Duplicates should be ignored
            story.InvolveUsers(writers, Contributions.Writer);
            CollectionAssert.AreEquivalent(story.GetInvolvedUsersForContribution(Contributions.Writer).ToArray(), writers.ToArray());
        }