Example #1
0
        public static AuthorViewModelMinified ConvertToAuthorViewModel(Author author)
        {
            string authorName = string.Format("{0} {1}", author.FirstName, author.LastName);

            AuthorViewModelMinified authorViewModel = new AuthorViewModelMinified
            {
                Id         = author.Id,
                AuthorName = authorName
            };

            return(authorViewModel);
        }
        public static AuthorViewModelMinified ConvertToAuthorViewModel(Author author)
        {
            string authorName = string.Format("{0} {1}", author.FirstName, author.LastName);

            AuthorViewModelMinified authorViewModel = new AuthorViewModelMinified
            {
                Id = author.Id,
                AuthorName = authorName
            };

            return authorViewModel;
        } 
        public static BookViewModel ConvertToBookViewModel(Book book)
        {
            BookViewModel bookViewModel = new BookViewModel
            {
                Id             = book.Id,
                Author         = AuthorViewModelMinified.ConvertToAuthorViewModel(book.Author),
                Categories     = book.Categories.Select(c => c.Name),
                Copies         = book.Copies,
                Description    = book.Description,
                EditionType    = book.EditionType,
                Price          = book.Price,
                Title          = book.Title,
                AgeRestriction = book.AgeRestriction,
                ReleaseDate    = book.ReleaseDate.Date
            };

            return(bookViewModel);
        }