public static GameGenre FromDictionary(IDictionary <string, object> dictionary) { var result = new GameGenre(); try { if ((dictionary != null) && (dictionary.Count > 0)) { foreach (var key in dictionary.Keys) { switch (key.Trim()) { case "Id": result.Id = Convert.ToInt32(dictionary[key]); break; case "GameId": result.GameId = Convert.ToInt32(dictionary[key]); break; case "GenreId": result.GenreId = Convert.ToInt32(dictionary[key]); break; } } } } catch (Exception ex) { Log.Error(ex); } return(result); }
public static Dictionary <string, object> ToDictionary(GameGenre gamegenre) { var result = new Dictionary <string, object>(); try { if (gamegenre != null) { result.Add("Id", gamegenre.Id); result.Add("GameId", gamegenre.GameId); result.Add("GenreId", gamegenre.GenreId); } } catch (Exception ex) { Log.Error(ex); } return(result); }
public static GameGenreList FromDictionaryList(List <Dictionary <string, object> > dictionaryList) { var result = new GameGenreList(); try { if (dictionaryList?.Count > 0) { foreach (var dataDictionary in dictionaryList.Where(dataDictionary => dataDictionary?.Count > 0)) { result.List.Add(GameGenre.FromDictionary(dataDictionary)); } } } catch (Exception ex) { Log.Error(ex); } return(result); }
public bool Add(GameGenre gamegenre) { var result = false; try { if (gamegenre != null) { if (!Exists(gamegenre.Id)) { List.Add(gamegenre); result = Exists(gamegenre.Id); } } } catch (Exception ex) { Log.Error(ex); } return(result); }
public static List <Dictionary <string, object> > ToDictionaryList(GameGenreList gameGenreList) { var result = new List <Dictionary <string, object> >(); try { if (gameGenreList?.List?.Count > 0) { result = (from gamegenre in gameGenreList.List where gamegenre != null select GameGenre.ToDictionary(gamegenre) into dictionary where dictionary?.Count > 0 select dictionary).ToList(); } } catch (Exception ex) { Log.Error(ex); } return(result); }