/// <summary> /// Gets the media. /// </summary> /// <param name="rootUrl">The root URL.</param> /// <param name="album">The album.</param> /// <param name="results">The results.</param> private static void GetMedia(string rootUrl, Album album, List<IGroupItem> results) { var momento = (album.Momentos != null ? album.Momentos.FirstOrDefault() : null); //get random image for Album cover image. if (momento != null) { var media = (momento.Media != null ? momento.Media.Single(s => s.MediaType == MomentoMediaType.MediumImage) : null); if (media != null) { string url = string.Format("{0}/{1}", rootUrl, media.Url); var item = PopulateAlbumResult(album, url); results.Add(item); } } else // default album without image { const string url = "/content/images/defaultalbum.png"; var item = PopulateAlbumResult(album, url); results.Add(item); } }
/// <summary> /// Populates the album result. /// </summary> /// <param name="album">The album.</param> /// <param name="url">The URL.</param> /// <returns>AlbumResult.</returns> private static AlbumResult PopulateAlbumResult(Album album, string url) { var item = new AlbumResult { Id = album.Id, Name = album.Name, Username = album.Username, CreateDate = album.CreateDate, Url = url }; return item; }
/// <summary> /// News the specified command. /// </summary> /// <param name="parameters">The command.</param> /// <exception cref="System.NotImplementedException"></exception> public void New(NewAlbumParameters parameters) { using (ITransaction trans = _session.BeginTransaction()) { var album = new Album { Name = parameters.Name, Story = parameters.Story, Username = parameters.Username, CreateDate = DateTime.UtcNow }; _session.Save(album); trans.Commit(); } }