Beispiel #1
0
        private static GameSystemRequirement ParseGameSystemRequirement(XmlNode gameSystemRequirementNode)
        {
            var fieldsList = gameSystemRequirementNode.Cast <XmlNode>().ToList();

            var gameSystemRequirement = new GameSystemRequirement {
                MinCpu   = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.MinCpu)),
                MaxCpu   = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.MaxCpu)),
                MinRamMB = Convert.ToUInt32(
                    fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.MinRamMB)),
                    CultureInfo.CurrentCulture
                    ),
                MaxRamMB = Convert.ToUInt32(
                    fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.MaxRamMB)),
                    CultureInfo.CurrentCulture
                    ),
                DiskSpaceMB = Convert.ToUInt32(
                    fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.DiskSpaceMB)),
                    CultureInfo.CurrentCulture
                    ),
                DirectX = Convert.ToByte(
                    fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.DirectX)),
                    CultureInfo.CurrentCulture
                    ),
                MinGpu                  = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.MinGpu)),
                MaxGpu                  = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.MaxGpu)),
                SupportedOses           = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.SupportedOses)),
                ExtraInfo               = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.ExtraInfo)),
                SupportedVoiceLanguages = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.SupportedVoiceLanguages)),
                SupportedTextLanguages  = fieldsList.GetNodeInnerText(nameof(GameSystemRequirement.SupportedTextLanguages)),
            };

            return(gameSystemRequirement);
        }
Beispiel #2
0
        public IActionResult SaveAddedGame(AddGameModel data)
        {
            try
            {
                List <Genre>   genres   = data.Genres.Select(g => genresTable.GetGenreByUrlId(g) !).ToList();
                List <Feature> features = data.Features.Select(f => featuresTable.GetFeatureByUrlId(f) !).ToList();

                var gameFilter = new GameFilter {
                    Features = features,
                    Genres   = genres
                };

                var gameMedia = new GameMedia {
                    Screenshots = data.Screenshots,
                    Trailers    = data.Trailers
                };

                var gameSystemRequirements = new GameSystemRequirement {
                    MinCpu                  = data.MinCpu,
                    MaxCpu                  = data.MaxCpu,
                    MinRamMB                = data.MinRamMB,
                    MaxRamMB                = data.MaxRamMB,
                    MinGpu                  = data.MinGpu,
                    MaxGpu                  = data.MaxGpu,
                    DiskSpaceMB             = data.DiskSpaceMB,
                    DirectX                 = data.DirectX,
                    SupportedOses           = data.SupportedOses,
                    ExtraInfo               = data.ExtraInfo == null ? "" : data.ExtraInfo,
                    SupportedTextLanguages  = data.SupportedTextLanguages,
                    SupportedVoiceLanguages = data.SupportedVoiceLanguages
                };

                var discount = float.Parse(data.Discount.Replace('.', ','));

                DateTime discountEndDate = discount != 0 && !string.IsNullOrEmpty(data.DiscountEndDate)
                    ? Convert.ToDateTime(data.DiscountEndDate)
                    : DateTime.MinValue;

                var releaseDate = Convert.ToDateTime(data.ReleaseDate);

                var gameInfo = new GameInfo {
                    Cover               = data.Cover,
                    Price               = data.Price,
                    Discount            = discount,
                    DiscountEndDate     = discountEndDate,
                    ReleaseDate         = releaseDate,
                    Rating              = data.Rating,
                    ShortDescription    = data.ShortDescription,
                    DetailedDescription = data.DetailedDescription,
                    LegalInfo           = data.LegalInfo
                };

                var game = new Game {
                    Name      = data.Name,
                    Developer = data.Developer,
                    GameUrl   = data.GameUrl,
                    GameInfo  = gameInfo,
                    GameSystemRequirements = gameSystemRequirements,
                    GameMedia  = gameMedia,
                    GameFilter = gameFilter
                };

                var success = gamesTable.AddGame(game);

                if (!string.IsNullOrEmpty(success))
                {
                    return(Content(success));
                }
            }
            catch (Exception e)
            {
                return(Content($"{e.Message}\n{e.StackTrace}"));
            }

            return(Content(""));
        }