예제 #1
0
        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)),
            };
        }
예제 #2
0
        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;
            }
        }
예제 #3
0
 public bool Insert(Album album)
 {
     try
     {
         _ctx.Albums.Add(album);
         return true;
     }
     catch
     {
         return false;
     }
 }