Exemple #1
0
        public BlogList Get()
        {
            BlogItemHandler itemHandler = new BlogItemHandler();

            BlogList list = new BlogList
            {
                Title = "A mixed blog",
            };

            list.Items = BlogDB.GetAll().Select(entry => new BlogItem
            {
                Id          = entry.AuthorId,
                Title       = entry.Title,
                Text        = entry.Text,
                CreatedDate = entry.CreatedDate,
                SelfLink    = typeof(BlogItem).CreateUri(new { Id = entry.Id })
            }).ToList();

            AuthorDB.AuthorEntry author = AuthorDB.Get(0);

            list.AuthorName = author.Name;
            list.AuthorLink = typeof(Author).CreateUri(new { Id = author.Id });
            list.EditLink   = typeof(BlogItemCreationDescriptor).CreateUri();

            // Use relative path to verify that Ramone Links/Follow/Select etc. works with rel. paths
            list.SearchDescriptionLink = BlogConstants.SearchDescriptionSubPath;

            return(list);
        }
Exemple #2
0
        public BlogItem Get(int id)
        {
            BlogDB.PostEntry     postEntry   = BlogDB.Get(id);
            AuthorDB.AuthorEntry authorEntry = AuthorDB.Get(postEntry.AuthorId);

            BlogItem item = new BlogItem
            {
                Id          = postEntry.Id,
                Title       = postEntry.Title,
                Text        = postEntry.Text,
                CreatedDate = postEntry.CreatedDate,
                AuthorName  = authorEntry.Name
            };

            item.SelfLink   = typeof(BlogItem).CreateUri(new { Id = postEntry.Id });
            item.UpLink     = typeof(BlogList).CreateUri();
            item.AuthorLink = typeof(Author).CreateUri(new { Id = authorEntry.Id });

            if (postEntry.ImageId != null)
            {
                item.ImageLink = typeof(Image).CreateUri(new { Id = postEntry.ImageId });
            }

            return(item);
        }
Exemple #3
0
 public static List <BookDB> GenerateBooks(int count, AuthorDB author, GenreDB genre)
 {
     return(Fixture.Build <BookDB>()
            .With(x => x.Author, author)
            .With(x => x.AuthorId, author.Id)
            .With(x => x.Genre, genre)
            .With(x => x.GenreId, genre.Id)
            .CreateMany(count)
            .ToList());
 }
Exemple #4
0
 public static bool Delete(Author myAuthor)
 {
     if (myAuthor != null)
     {
         return(AuthorDB.Delete(myAuthor.id));
     }
     else
     {
         return(false);
     }
 }
 internal Author Map(AuthorDB author)
 {
     if (author == null)
     {
         return(null);
     }
     return(new Author()
     {
         Id = author.Id, AuthorName = author.AuthorName, AuthorSurname = author.AuthorSurname
     });
 }
Exemple #6
0
 private Author Map(AuthorDB authorDB)
 {
     if (authorDB == null)
     {
         return(null);
     }
     return(new Author()
     {
         Id = authorDB.Id,
         AuthorName = authorDB.AuthorName,
         AuthorSurname = authorDB.AuthorSurname
     });
 }
Exemple #7
0
        public Author Get(int id)
        {
            AuthorDB.AuthorEntry entry = AuthorDB.Get(id);

            Author a = new Author
            {
                Id    = entry.Id,
                Name  = entry.Name,
                EMail = entry.EMail
            };

            a.SelfLink = typeof(Author).CreateUri(new { Id = a.Id });

            return(a);
        }
Exemple #8
0
 public static Author GetItem(string username)
 {
     return(AuthorDB.GetItem(username));
 }
Exemple #9
0
 public static Author GetItem(long id)
 {
     return(AuthorDB.GetItem(id));
 }
Exemple #10
0
 public static List <Author> GetList(int StartRow, int PageSize)
 {
     return(AuthorDB.GetList(StartRow, PageSize));
 }
Exemple #11
0
 public static List <Author> GetList()
 {
     return(AuthorDB.GetList());
 }
Exemple #12
0
        /// <summary>
        /// Returns the total number of authors in the database
        /// </summary>
        /// <param name="StartRow">
        /// The start position in the result set to retrieve records from
        /// </param>
        /// <param name="PageSize">
        /// The maximum number of records to retrieve from position StartRow
        /// </param>
        /// <returns>
        /// Returns the total number of authors in the database
        /// </returns>

        public static int Count(int StartRow, int PageSize)
        {
            return(AuthorDB.Count(StartRow, PageSize));
        }
Exemple #13
0
 public static long Save(Author myAuthor)
 {
     return(AuthorDB.Save(myAuthor));
 }