public static GameReview FromDictionary(IDictionary <string, object> dictionary) { var result = new GameReview(); 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 "ReviewId": result.ReviewId = Convert.ToInt32(dictionary[key]); break; } } } } catch (Exception ex) { Log.Error(ex); } return(result); }
public static Dictionary <string, object> ToDictionary(GameReview gamerating) { var result = new Dictionary <string, object>(); try { if (gamerating != null) { result.Add("Id", gamerating.Id); result.Add("GameId", gamerating.GameId); result.Add("ReviewId", gamerating.ReviewId); } } catch (Exception ex) { Log.Error(ex); } return(result); }
public static GameReviewList FromDictionaryList(List <Dictionary <string, object> > dictionaryList) { var result = new GameReviewList(); try { if (dictionaryList?.Count > 0) { foreach (var dataDictionary in dictionaryList.Where(dataDictionary => dataDictionary?.Count > 0)) { result.List.Add(GameReview.FromDictionary(dataDictionary)); } } } catch (Exception ex) { Log.Error(ex); } return(result); }
public bool Add(GameReview gamereview) { var result = false; try { if (gamereview != null) { if (!Exists(gamereview.Id)) { List.Add(gamereview); result = Exists(gamereview.Id); } } } catch (Exception ex) { Log.Error(ex); } return(result); }
public static List <Dictionary <string, object> > ToDictionaryList(GameReviewList gameGenreList) { var result = new List <Dictionary <string, object> >(); try { if (gameGenreList?.List?.Count > 0) { result = (from gamereview in gameGenreList.List where gamereview != null select GameReview.ToDictionary(gamereview) into dictionary where dictionary?.Count > 0 select dictionary).ToList(); } } catch (Exception ex) { Log.Error(ex); } return(result); }