public AlbumModel Create(Album album) { if (album == null) return null; return new AlbumModel { Id = album.Id, CreatorId = album.CreatorId, Title = album.Title, CreatedDateTime = album.CreatedDateTime, Url = _urlHelper.Link("Albums", new { id = album.Id }), //Photos = album.Photos == null ? null : album.Photos.Select(p => Create(p)), Photos = _repo.GetPhotosForAlbum(album.Id).ToList().Select(p => Create(p)), }; }
public Album Parse(AlbumModel model) { try { var album = new Album(); if (!string.IsNullOrWhiteSpace(model.Title)) { album.Title = model.Title; } // should this happen in the albums controller? album.CreatedDateTime = DateTime.UtcNow; return album; } catch { return null; } }
public bool Insert(Album album) { try { _ctx.Albums.Add(album); return true; } catch { return false; } }