コード例 #1
0
        public static GameRatingList FromDictionaryList(List <Dictionary <string, object> > dictionaryList)
        {
            var result = new GameRatingList();

            try
            {
                if (dictionaryList?.Count > 0)
                {
                    foreach (var dataDictionary in dictionaryList.Where(dataDictionary => dataDictionary?.Count > 0))
                    {
                        result.List.Add(GameRating.FromDictionary(dataDictionary));
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return(result);
        }
コード例 #2
0
        public static Dictionary <string, object> ToDictionary(GameRating gamerating)
        {
            var result = new Dictionary <string, object>();

            try
            {
                if (gamerating != null)
                {
                    result.Add("Id", gamerating.Id);
                    result.Add("GameId", gamerating.GameId);
                    result.Add("RatingId", gamerating.RatingId);
                    result.Add("Notes", gamerating.Notes);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return(result);
        }
コード例 #3
0
        public bool Add(GameRating gamerating)
        {
            var result = false;

            try
            {
                if (gamerating != null)
                {
                    if (!Exists(gamerating.Id))
                    {
                        List.Add(gamerating);

                        result = Exists(gamerating.Id);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return(result);
        }
コード例 #4
0
        public static GameRating FromDictionary(IDictionary <string, object> dictionary)
        {
            var result = new GameRating();

            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 "RatingId":
                            result.RatingId = Convert.ToInt32(dictionary[key]);
                            break;

                        case "Notes":
                            result.Notes = dictionary[key] as string;
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return(result);
        }
コード例 #5
0
        public static List <Dictionary <string, object> > ToDictionaryList(GameRatingList gameGenreList)
        {
            var result = new List <Dictionary <string, object> >();

            try
            {
                if (gameGenreList?.List?.Count > 0)
                {
                    result = (from gamerating in gameGenreList.List where gamerating != null select GameRating.ToDictionary(gamerating) into dictionary where dictionary?.Count > 0 select dictionary).ToList();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }
            return(result);
        }