// mappings for tag objects // mapping DB entity to library class public static Library.Tag Map(DataAccess.Tag tag) => new Library.Tag { TagId = tag.TagId, Name = tag.GenreName };
// Note that this method is not in the repository interface because // because the interface does not reference this DataAccess folder... // Similarly, the above method is not implemented because it takes // a collection of Library games... //public ICollection<Library.Game> GetGamesHelper(ICollection<DataAccess.Game> oldGames, int sort = 0) //{ // switch (sort) // { // case 0: // ICollection<Game> games0 = oldGames.OrderBy(g => g.GameId).ToList(); // return games0 == null ? null : Mapper.Map(games0).ToList(); // case 1: // ICollection<Game> games1 = oldGames.OrderBy(g => g.Name).ToList(); // return games1 == null ? null : Mapper.Map(games1).ToList(); // case 2: // ICollection<Game> games2 = oldGames.OrderBy(g => g.Price).ToList(); // return games2 == null ? null : Mapper.Map(games2).ToList(); // case 3: // ICollection<Game> games3 = oldGames.OrderByDescending(g => g.Price).ToList(); // return games3 == null ? null : Mapper.Map(games3).ToList(); // default: // ICollection<Game> gamesD = oldGames.OrderBy(g => g.GameId).ToList(); // return gamesD == null ? null : Mapper.Map(gamesD).ToList(); // } //} public Library.Tag GetTag(int tagid) { DataAccess.Tag tag = _db.Tag.Find(tagid); return(tag == null ? null : Mapper.Map(tag)); }