コード例 #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                              VouchersDBContext dbcontext)
        {
            //Logging
            loggerFactory.AddNLog();
            env.ConfigureNLog("nlog.config");

            var jsnlogConfiguration = new JsnlogConfiguration();

            app.UseJSNLog(new LoggingAdapter(loggerFactory), jsnlogConfiguration);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }

            //Startup File for serving a *.html as default

            // DefaultFilesOptions options = new DefaultFilesOptions();
            // options.DefaultFileNames.Clear();
            // options.DefaultFileNames.Add("crud.html");
            // app.UseDefaultFiles(options);

            if (env.IsDevelopment())
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    OnPrepareResponse = context =>
                    {
                        context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store";
                        context.Context.Response.Headers["Pragma"]        = "no-cache";
                        context.Context.Response.Headers["Expires"]       = "-1";
                    }
                });
            }
            else
            {
                app.UseStaticFiles();
            }

            //Cors
            app.UseCors("AllowAll");

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Vouchers API V1");
                c.RoutePrefix = string.Empty;
            });

            //Auth
            app.UseAuthentication();

            app.UseMvc();
        }
コード例 #2
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                              VouchersDBContext dbcontext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }


            //Startup File for serving a *.html as default

            DefaultFilesOptions options = new DefaultFilesOptions();

            options.DefaultFileNames.Clear();
            options.DefaultFileNames.Add("index.html");
            app.UseDefaultFiles(options);

            if (env.IsDevelopment())
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    OnPrepareResponse = context =>
                    {
                        context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store";
                        context.Context.Response.Headers["Pragma"]        = "no-cache";
                        context.Context.Response.Headers["Expires"]       = "-1";
                    }
                });
            }
            else
            {
                app.UseStaticFiles();
            }

            //Cors
            app.UseCors("AllowAll");

            //Auth
            // app.UseAuthentication();

            app.UseHttpsRedirection();
            app.UseMvc();
        }
コード例 #3
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, VouchersDBContext dbcontext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }

            DefaultFilesOptions options = new DefaultFilesOptions();

            options.DefaultFileNames.Clear();
            options.DefaultFileNames.Add("app.html");
            app.UseDefaultFiles(options);

            if (env.IsDevelopment())
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    OnPrepareResponse = context =>
                    {
                        context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store";
                        context.Context.Response.Headers["Pragma"]        = "no-cache";
                        context.Context.Response.Headers["Expires"]       = "-1";
                    }
                });
            }
            else
            {
                app.UseStaticFiles();
            }

            //Cors
            app.UseCors("AllowAll");

            app.UseMvcWithDefaultRoute();
        }
コード例 #4
0
        public static void Initialize(VouchersDBContext context)
        {
            context.Database.EnsureCreated();

            if (context.BalanceAccounts.FirstOrDefault() == null)
            {
                var a1 = new BalanceAccount {
                    Name = "Depreciation", Expense = true
                };
                var a2 = new BalanceAccount {
                    Name = "Car Maintenance", Expense = true
                };
                var a3 = new BalanceAccount {
                    Name = "Development", Expense = false
                };
                var a4 = new BalanceAccount {
                    Name = "Consulting", Expense = false
                };
                var a5 = new BalanceAccount {
                    Name = "Training", Expense = false
                };
                var a6 = new BalanceAccount {
                    Name = "Software", Expense = true
                };
                var a7 = new BalanceAccount {
                    Name = "Hosting & Internet", Expense = true
                };
                var a8 = new BalanceAccount {
                    Name = "Büromaterial", Expense = true
                };

                context.BalanceAccounts.AddRange(a1, a2, a3, a4, a5, a6, a7, a8);
                context.SaveChanges();

                var v1 = new Voucher
                {
                    Date    = DateTime.Now.AddDays(-2),
                    Amount  = 800,
                    Text    = "Bogus AG",
                    Paid    = false,
                    Expense = false,
                    Remark  = true
                };
                var v2 = new Voucher
                {
                    Date    = DateTime.Now.AddDays(-2),
                    Amount  = 65,
                    Text    = "BP Tankstelle",
                    Paid    = false,
                    Expense = true,
                    Remark  = true
                };
                var v3 = new Voucher
                {
                    Date    = DateTime.Now.AddDays(-2),
                    Amount  = 56,
                    Text    = "Amazon",
                    Paid    = false,
                    Expense = true
                };
                var v4 = new Voucher
                {
                    Date    = DateTime.Now.AddDays(-3),
                    Amount  = 100,
                    Text    = "Media Markt",
                    Paid    = true,
                    Expense = true
                };
                context.Vouchers.AddRange(v1, v2, v3, v4);
                context.SaveChanges();

                var vd1 = new VoucherDetail {
                    VoucherID = v4.ID, Text = "Ladekabel", Amount = 100, Account = a1
                };
                var vd7 = new VoucherDetail
                {
                    VoucherID = v3.ID,
                    Text      = "Game of Thrones, Season 6",
                    Amount    = 29,
                    Account   = a6
                };
                var vd2 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "USB Stick", Amount = 11, Account = a1
                };
                var vd3 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "DVI Kabel", Amount = 45, Account = a1
                };
                var vd4 = new VoucherDetail {
                    VoucherID = v2.ID, Text = "Diesel", Amount = 45, Account = a2
                };
                var vd6 = new VoucherDetail {
                    VoucherID = v2.ID, Text = "Reifenwechsel", Amount = 20, Account = a2
                };
                var vd5 = new VoucherDetail {
                    VoucherID = v1.ID, Text = "Remote Support", Amount = 800, Account = a4
                };

                context.VoucherDetails.AddRange(vd1, vd2, vd3, vd4, vd5, vd6, vd7);
                context.SaveChanges();
            }
        }
コード例 #5
0
 public AccountsController(VouchersDBContext context)
 {
     ctx = context;
 }
コード例 #6
0
        private static void SeedDatabase(VouchersDBContext context)
        {
            //To Create the Code First DB go to Package Manager Console ->
            //PM: Install-Package Microsoft.EntityFrameworkCore.Tools -Pre
            //Add-Migration MigrationName
            //Update-Database

            if (context.BalanceAccounts.FirstOrDefault() == null)
            {
                var a1 = new BalanceAccount {
                    Name = "Unclassified", Expense = true
                };
                var a2 = new BalanceAccount {
                    Name = "Car Maintenance", Expense = true
                };
                var a3 = new BalanceAccount {
                    Name = "Development", Expense = false
                };
                var a4 = new BalanceAccount {
                    Name = "Consulting", Expense = false
                };
                var a5 = new BalanceAccount {
                    Name = "Training", Expense = false
                };
                var a6 = new BalanceAccount {
                    Name = "Software", Expense = true
                };
                var a7 = new BalanceAccount {
                    Name = "Hosting & Internet", Expense = true
                };

                context.BalanceAccounts.AddRange(a1, a2, a3, a4, a5, a6, a7);
                context.SaveChanges();

                var v1 = new Voucher {
                    Date = DateTime.Now.AddDays(-2), Amount = 800, Text = "Bogus AG", Paid = false, Expense = false, Remark = true
                };
                var v2 = new Voucher {
                    Date = DateTime.Now.AddDays(-2), Amount = 65, Text = "BP Tankstelle", Paid = false, Expense = true, Remark = true
                };
                var v3 = new Voucher {
                    Date = DateTime.Now.AddDays(-2), Amount = 56, Text = "Amazon", Paid = false, Expense = true
                };
                var v4 = new Voucher {
                    Date = DateTime.Now.AddDays(-3), Amount = 100, Text = "Media Markt", Paid = true, Expense = true
                };
                context.Vouchers.AddRange(v1, v2, v3, v4);
                context.SaveChanges();

                var vd1 = new VoucherDetail {
                    VoucherID = v4.ID, Text = "Ladekabel", Amount = 100, Account = a1
                };
                var vd7 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "Game of Thrones, Season 6", Amount = 29, Account = a6
                };
                var vd2 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "USB Stick", Amount = 11, Account = a1
                };
                var vd3 = new VoucherDetail {
                    VoucherID = v3.ID, Text = "DVI Kabel", Amount = 45, Account = a1
                };
                var vd4 = new VoucherDetail {
                    VoucherID = v2.ID, Text = "Diesel", Amount = 45, Account = a2
                };
                var vd6 = new VoucherDetail {
                    VoucherID = v2.ID, Text = "Reifenwechsel", Amount = 20, Account = a2
                };
                var vd5 = new VoucherDetail {
                    VoucherID = v1.ID, Text = "Remote Support", Amount = 800, Account = a4
                };

                context.VoucherDetails.AddRange(vd1, vd2, vd3, vd4, vd5, vd6, vd7);
                context.SaveChanges();
            }
            ;
        }
コード例 #7
0
ファイル: Startup.cs プロジェクト: Neo5000/SmartAngular
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, VouchersDBContext dbcontext)
        {
            loggerFactory.AddNLog();
            env.ConfigureNLog("nlog.config");

            var jsnlogConfiguration = new JsnlogConfiguration();

            app.UseJSNLog(new LoggingAdapter(loggerFactory), jsnlogConfiguration);

            if (env.IsDevelopment())
            {
                loggerFactory.AddConsole();
                loggerFactory.AddDebug();
                app.UseDeveloperExceptionPage();
                app.UseStatusCodePages();
            }

            DefaultFilesOptions options = new DefaultFilesOptions();

            options.DefaultFileNames.Clear();
            options.DefaultFileNames.Add("crud.html");
            app.UseDefaultFiles(options);

            if (env.IsDevelopment())
            {
                app.UseStaticFiles(new StaticFileOptions
                {
                    OnPrepareResponse = context =>
                    {
                        context.Context.Response.Headers["Cache-Control"] = "no-cache, no-store";
                        context.Context.Response.Headers["Pragma"]        = "no-cache";
                        context.Context.Response.Headers["Expires"]       = "-1";
                    }
                });
            }
            else
            {
                app.UseStaticFiles();
            }

            app.UseCors("AllowAll");
            app.UseMvcWithDefaultRoute();
        }
コード例 #8
0
 public AccountController(VouchersDBContext dbcontext)
 {
     ctx = dbcontext;
 }
コード例 #9
0
 public VoucherDetailsController(VouchersDBContext context)
 {
     ctx = context;
 }
コード例 #10
0
 public VouchersRepository(VouchersDBContext context, ILogger <VouchersRepository> lg)
 {
     ctx    = context;
     logger = lg;
 }
コード例 #11
0
 public Demo(IVouchersRepository repository, VouchersDBContext dbcontext)
 {
     rep = repository;
     ctx = dbcontext;
 }
コード例 #12
0
 public RememberedVouchers(VouchersDBContext db)
 {
     ctx = db;
 }
コード例 #13
0
 public BalanceService(VouchersDBContext context)
 {
     ctx = context;
 }