// GET: Album/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Album album = AlbumDB.Find(id); if (album == null) { return(HttpNotFound()); } return(View(album)); }
public void SingleValuedReferenceTest() { // 'Find' function does two DB trips to get all info needed to return an album object. var albumRepo = new AlbumRepository(); Guid uniqueId; Guid.TryParse("5e26185b-3de9-478b-b764-48d50a8944b0", out uniqueId); var album = albumRepo.Find(uniqueId); Debug.Assert(album.Id != null); }
/// <summary> /// Determine the type of the gallery object (album, image, video, etc) specified by the ID. The object must exist /// in the data store. If no gallery object is found, or a media object (image, video, etc) is found but /// the file extension does not correspond to a supported MIME type by Gallery Server, /// <see cref="GalleryObjectType.Unknown"/> is returned. If both a media object and an album exist with the /// <paramref name="id"/>, the media object reference is returned. /// </summary> /// <param name="id">An integer representing a gallery object that exists in the data store (album, video, /// image, etc).</param> /// <returns>Returns a GalleryObjectType enum indicating the type of gallery object specified by ID.</returns> public static GalleryObjectType DetermineGalleryObjectType(int id) { if (id == Int32.MinValue) return GalleryObjectType.Unknown; #region Is ID a media object? GalleryObjectType goType = DetermineMediaObjectType(id); #endregion #region Is ID an album? if (goType == GalleryObjectType.Unknown) { // The ID does not represent a known MediaObject. Check to see if it's an album. using (var repo = new AlbumRepository()) { if (repo.Find(id) != null) { // If we get here, we found an album. goType = GalleryObjectType.Album; } } } #endregion // If ID is not a media object or album that exists in the data store, return GalleryObjectType.Unknown. return goType; }
public ActionResult Album(int id) { var model = albumRepository.Find(id); return(View(model)); }