コード例 #1
0
ファイル: GameService.cs プロジェクト: ITHedgeHog/spms-net
        public byte[] GetGameKey(byte[] generateKey)
        {
            var game = GetGameAsync().Result;

            if (game.GameKey == null || game.GameKey.Length == 0)
            {
                game.GameKey = generateKey;
                _context.Game.Update(game);
                _context.SaveChanges();
                return(generateKey);
            }

            return(game.GameKey);
        }
コード例 #2
0
        public static void SeedDefaults(ISpmsContext context)
        {
            // Episode Status
            if (!context.EpisodeStatus.Any(n => n.Name == StaticValues.Draft))
            {
                context.EpisodeStatus.Add(new EpisodeStatus()
                {
                    Name = StaticValues.Draft
                });
            }
            if (!context.EpisodeStatus.Any(n => n.Name == StaticValues.Pending))
            {
                context.EpisodeStatus.Add(new EpisodeStatus()
                {
                    Name = StaticValues.Pending
                });
            }
            if (!context.EpisodeStatus.Any(n => n.Name == StaticValues.Published))
            {
                context.EpisodeStatus.Add(new EpisodeStatus()
                {
                    Name = StaticValues.Published
                });
            }
            if (!context.EpisodeStatus.Any(n => n.Name == StaticValues.Archived))
            {
                context.EpisodeStatus.Add(new EpisodeStatus()
                {
                    Name = StaticValues.Archived
                });
            }

            // EpisodeEntryType
            if (!context.EpisodeEntryType.Any(e => e.Name == StaticValues.Post))
            {
                context.EpisodeEntryType.Add(new EpisodeEntryType()
                {
                    Name = StaticValues.Post
                });
            }

            if (!context.EpisodeEntryType.Any(e => e.Name == StaticValues.PersonalLog))
            {
                context.EpisodeEntryType.Add(new EpisodeEntryType()
                {
                    Name = StaticValues.PersonalLog
                });
            }
            if (!context.EpisodeEntryType.Any(e => e.Name == StaticValues.Fiction))
            {
                context.EpisodeEntryType.Add(new EpisodeEntryType()
                {
                    Name = StaticValues.Fiction
                });
            }

            // Episode Status
            if (!context.EpisodeEntryStatus.Any(n => n.Name == StaticValues.Draft))
            {
                context.EpisodeEntryStatus.Add(new EpisodeEntryStatus()
                {
                    Name = StaticValues.Draft
                });
            }
            if (!context.EpisodeEntryStatus.Any(n => n.Name == StaticValues.Pending))
            {
                context.EpisodeEntryStatus.Add(new EpisodeEntryStatus()
                {
                    Name = StaticValues.Pending
                });
            }
            if (!context.EpisodeEntryStatus.Any(n => n.Name == StaticValues.Published))
            {
                context.EpisodeEntryStatus.Add(new EpisodeEntryStatus()
                {
                    Name = StaticValues.Published
                });
            }
            if (!context.EpisodeEntryStatus.Any(n => n.Name == StaticValues.Archived))
            {
                context.EpisodeEntryStatus.Add(new EpisodeEntryStatus()
                {
                    Name = StaticValues.Archived
                });
            }


            context.SaveChanges();
        }