Example #1
0
        public string ParseAllAuthors()
        {
            if (Authors is null || Authors.Count == 0)
            {
                return(string.Empty);
            }

            if (Authors.Count == 1)
            {
                var author      = Authors.First();
                var firstName   = !string.IsNullOrEmpty(author.FirstName) ? $" {author.FirstName}" : string.Empty;
                var fathersName = !string.IsNullOrEmpty(author.FathersName) ? $" {author.FathersName}" : string.Empty;
                var lastName    = !string.IsNullOrEmpty(author.LastName) ? $"{author.LastName}" : string.Empty;

                return($" / {lastName}{firstName}{fathersName}");
            }

            var result = " / ";

            for (int i = 0; i < Authors.Count - 1; i++)
            {
                var author = Authors[i];
                result += $"{ConvertAuthorToString(author)}, ";
            }

            var lastAuthor = Authors.Last();

            result += $"{ConvertAuthorToString(lastAuthor)}";

            return(result);
        }
Example #2
0
        public IEnumerator GetEnumerator()
        {
            yield return(ISBN);

            yield return(Title);

            yield return(Authors.First());

            yield return(PublishDate);

            yield return(Genre);
        }
Example #3
0
        public string ParseAuthor()
        {
            if (Authors is null || Authors.Count == 0)
            {
                return(string.Empty);
            }
            var author = Authors.First();

            var firstName   = !string.IsNullOrEmpty(author.FirstName) ? $" {author.FirstName.Substring(0, 1)}." : string.Empty;
            var fathersName = !string.IsNullOrEmpty(author.FathersName) ? $" {author.FathersName.Substring(0, 1)}. " : string.Empty;
            var lastName    = !string.IsNullOrEmpty(author.LastName) ? $"{author.LastName}" : string.Empty;

            return($"{lastName}{firstName}{fathersName}");
        }
Example #4
0
 public AuthorsMaster(ISubject <object> interaction)
 {
     interaction.OfType <AuthorChanged>()
     .Subscribe(x => {
         var author       = Authors.First(y => y.Id == x.Author.Id);
         author.Name      = x.Author.Name;
         author.Birthday  = x.Author.Birthday;
         author.Gender    = x.Author.Gender;
         author.IsChecked = x.Author.IsChecked;
         author.Books     = x.Author.Books;
     });
     this.Authors         = new ObservableCollection <Author>();
     this.Genders         = (GenderType[])Enum.GetValues(typeof(GenderType));
     this.IsCheckedHeader = false;
 }
        public void AddBooks()
        {
            var author = Authors.First();

            Books.AddRange(Enumerable.Range(0, 1000).Select(x => new Book
            {
                Title       = $"Book {x}",
                PageCount   = x,
                Author      = author,
                IsAvailable = true,
                Description = "Auto generated Book"
            }));

            SaveChanges();
        }