public ArtistModel ConvertToModel(Artist artist) { MemberRepository mRepo = new MemberRepository(new yslDataContext()); PhotoRepository pRepo = new PhotoRepository(new yslDataContext()); ArtistModel result = new ArtistModel(); result.ArtistId = artist.ArtistId; result.Bio = artist.Bio; result.Name = artist.Name; result.Photo = pRepo.getPhotoAsModel(artist.Photo); result.Members = new List<MemberModel>(); foreach (var m in artist.ArtistMembers) { var mem = mRepo.ConvertToModel(m.Member); result.Members.Add(mem); } return result; }
public PhotoAlbumData getPhotoAlbumDataForJSON(int id) { PhotoAlbumData result; var pRepo = new PhotoRepository(new yslDataContext()); try { PhotoAlbum photoAlbum = this.db.PhotoAlbums.Single((PhotoAlbum a) => a.PhotoAlbumId == id); List<PhotoAlbumItemData> photos = ( from a in this.db.PhotoAlbums where a.PhotoAlbumId == id select a).Join(this.db.PhotoAlbumItems, (PhotoAlbum a) => a.PhotoAlbumId, (PhotoAlbumItem p) => p.PhotoAlbumId,(a,p) => new PhotoAlbumItemData{photo = pRepo.getPhotoAsModel(p.Photo), photoAlbumItemId = a.PhotoAlbumId}).ToList(); PhotoAlbumData photoAlbumData = new PhotoAlbumData { photoAlbumId = id, description = photoAlbum.Description, title = photoAlbum.Title, photos = photos }; result = photoAlbumData; } catch (Exception) { result = new PhotoAlbumData(); } return result; }
public AudioAlbumDataForJSON getLatestSingle(int artistId) { var pRepo = new PhotoRepository(new yslDataContext()); var aRepo = new AudioAlbumItemRepository(new yslDataContext()); AudioAlbumDataForJSON result; try { List<AudioAlbumDataForJSON> source = ( from b in this.db.AudioAlbums where b.ArtistId == artistId select b into s orderby s.Created descending select s).Join(this.db.Photos, (AudioAlbum a) => a.PhotoId, (Photo p) => p.PhotoId, (AudioAlbum, Photo) => new AudioAlbumDataForJSON { artist = AudioAlbum.Artist.Name, audioAlbumId = AudioAlbum.AudioAlbumId, photo = pRepo.getPhotoAsModel(Photo), title = AudioAlbum.Title, tracks = aRepo.getAudioAlbumItemAsModel(AudioAlbum.AudioAlbumItems.ToList()) }).ToList<AudioAlbumDataForJSON>(); result = source.First<AudioAlbumDataForJSON>(); } catch { result = new AudioAlbumDataForJSON(); } return result; }
public MemberModel ConvertToModel(Member member) { MemberModel result = new MemberModel(); PhotoRepository prepo = new PhotoRepository(new yslDataContext()); result.MemberId = member.MemberId; result.Name = member.Name; result.FirstName = member.Account.FirstName; result.LastName = member.Account.LastName; result.Email = member.Account.Email; result.Photo = prepo.getPhotoAsModel(member.Photo); return result; }