Beispiel #1
0
        public static async Task ResetDatabase(this DbContext v, ResetDatabase request)
        {
            try
            {
                if (!request.IKnowWhatIAmDoing)
                {
                    throw new BadRequestException("");
                }

                if (request.DeleteDatabase)
                {
                    await v.Database.EnsureDeletedAsync();
                }

                await v.Database.MigrateAsync();

                if (request.AfterCreated != null)
                {
                    await request.AfterCreated.Invoke();
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Beispiel #2
0
        public async Task <Unit> Handle(ResetDatabase request, CancellationToken cancellationToken)
        {
            await ctx.ResetDatabase(request);

            await SeedDatabase(ctx);

            return(Unit.Value);
        }