Ejemplo n.º 1
0
        public async Task <IdentityResult> RemoveUserAsync(Guid id)
        {
            var user = _UserManager.Users.FirstOrDefault(u => u.Id == id);

            if (user == null)
            {
                return(IdentityResult.Failed(new IdentityError
                {
                    Code = "UserNotFound",
                    Description = "User not found!"
                }));
            }

            if (IntegratedUsers.All().Select(u => u.UserName).Contains(user.UserName))
            {
                return(IdentityResult.Failed(new IdentityError()
                {
                    Code = "CannotRemoveSystemUser",
                    Description = "You cannot remove system user!"
                }));
            }

            var removeUserResult = await _UserManager.DeleteAsync(user);

            if (!removeUserResult.Succeeded)
            {
                return(removeUserResult);
            }


            return(removeUserResult);
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
                app.UseHttpsRedirection();
            }

            app.UseMiddleware <LogHeadersMiddleware>();

            // Enable swagger
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "ProductOwnerSimGame API v1");
            });

            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseCors(
                options => options
                .WithOrigins("http://*****:*****@"./variant_data/1/overallmarkdowntext.md"),
                        GamePhases          = new List <GamePhase>
                        {
                            new GamePhase
                            {
                                Sequence            = 1,
                                Duration            = PhaseDuration.Infinite,
                                ProductOwnerMission = new Mission
                                {
                                    MarkdownText = File.ReadAllText(@"./variant_data/1/po_mission_1.md")
                                },
                                StakeholderMissions = new List <Mission>
                                {
                                    new Mission
                                    {
                                        MarkdownText = File.ReadAllText(@"./variant_data/1/sh_mission_1.md")
                                    },
                                    new Mission
                                    {
                                        MarkdownText = File.ReadAllText(@"./variant_data/1/sh_mission_2.md")
                                    },
                                },
                                Decisions = new List <Decision>
                                {
                                    new Decision
                                    {
                                        DecisionMarkdownText    = File.ReadAllText(@"./variant_data/1/ph_1_dec_1.md"),
                                        ExplanationMarkdownText = File.ReadAllText(@"./variant_data/1/ph_1_exp_1.md"),
                                        Effects = new List <Effect>
                                        {
                                            new Effect
                                            {
                                                EffectCategory = EffectCategory.StakeHolderSatisfaction,
                                                Value          = +0
                                            }
                                        }
                                    },
                                    new Decision
                                    {
                                        DecisionMarkdownText    = File.ReadAllText(@"./variant_data/1/ph_1_dec_2.md"),
                                        ExplanationMarkdownText = File.ReadAllText(@"./variant_data/1/ph_1_exp_2.md"),
                                        Effects = new List <Effect>
                                        {
                                            new Effect
                                            {
                                                EffectCategory = EffectCategory.StakeHolderSatisfaction,
                                                Value          = +50
                                            }
                                        }
                                    },
                                }
                            },
                            new GamePhase
                            {
                                Sequence            = 2,
                                Duration            = PhaseDuration.Timeout,
                                DurationInSeconds   = 15,
                                ProductOwnerMission = new Mission
                                {
                                    MarkdownText = "PO Mission 2"
                                },
                                StakeholderMissions = new List <Mission>
                                {
                                    new Mission
                                    {
                                        MarkdownText = File.ReadAllText(@"./variant_data/1/sh_mission_3.md")
                                    },
                                    new Mission
                                    {
                                        MarkdownText = File.ReadAllText(@"./variant_data/1/sh_mission_4.md")
                                    },
                                },
                                Decisions = new List <Decision>
                                {
                                    new Decision
                                    {
                                        DecisionMarkdownText    = File.ReadAllText(@"./variant_data/1/ph_2_dec_1.md"),
                                        ExplanationMarkdownText = File.ReadAllText(@"./variant_data/1/ph_2_exp_1.md"),
                                        Effects = new List <Effect>
                                        {
                                            new Effect
                                            {
                                                EffectCategory = EffectCategory.Budget,
                                                Value          = +10
                                            }
                                        }
                                    },
                                    new Decision
                                    {
                                        DecisionMarkdownText    = File.ReadAllText(@"./variant_data/1/ph_2_dec_2.md"),
                                        ExplanationMarkdownText = File.ReadAllText(@"./variant_data/1/ph_2_exp_2.md"),
                                        Effects = new List <Effect>
                                        {
                                            new Effect
                                            {
                                                EffectCategory = EffectCategory.Budget,
                                                Value          = +10
                                            }
                                        }
                                    },
                                }
                            },
                            new GamePhase
                            {
                                Sequence            = 3,
                                Duration            = PhaseDuration.Infinite,
                                ProductOwnerMission = new Mission
                                {
                                    MarkdownText = File.ReadAllText(@"./variant_data/1/po_mission_3.md")
                                },
                                StakeholderMissions = new List <Mission>
                                {
                                    new Mission
                                    {
                                        MarkdownText = File.ReadAllText(@"./variant_data/1/sh_mission_5.md")
                                    },
                                    new Mission
                                    {
                                        MarkdownText = File.ReadAllText(@"./variant_data/1/sh_mission_6.md")
                                    },
                                },
                                Decisions = new List <Decision>
                                {
                                    new Decision
                                    {
                                        DecisionMarkdownText    = File.ReadAllText(@"./variant_data/1/ph_3_dec_1.md"),
                                        ExplanationMarkdownText = File.ReadAllText(@"./variant_data/1/ph_3_exp_1.md"),
                                        Effects = new List <Effect>
                                        {
                                            new Effect
                                            {
                                                EffectCategory = EffectCategory.Budget,
                                                Value          = +10
                                            }
                                        }
                                    },
                                    new Decision
                                    {
                                        DecisionMarkdownText    = File.ReadAllText(@"./variant_data/1/ph_3_dec_2.md"),
                                        ExplanationMarkdownText = File.ReadAllText(@"./variant_data/1/ph_3_exp_2.md"),
                                        Effects = new List <Effect>
                                        {
                                            new Effect
                                            {
                                                EffectCategory = EffectCategory.Budget,
                                                Value          = +10
                                            }
                                        }
                                    },
                                }
                            }
                        }
                    };

                    gvDataAccess.CreateGameVariantAsync(gv).Wait();
                }
                catch (Exception ex)
                {
                }
            }

            // Start game processing
            var gameManager = app.ApplicationServices.GetService <IGameManager>();

            gameManager.Start();
        }