From c229a49f2ccafaf6fab424fef455b8c2c36ebf77 Mon Sep 17 00:00:00 2001 From: "ismail.taha_janan" Date: Sat, 28 Jan 2023 10:24:55 +0100 Subject: [PATCH] simple commit --- cat_cafe/Program.cs | 2 +- cat_cafe/Repositories/CustomerContext.cs | 18 ++++++++++++++++-- cat_cafe/log.txt | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/cat_cafe/Program.cs b/cat_cafe/Program.cs index 307d218..e39c7e3 100644 --- a/cat_cafe/Program.cs +++ b/cat_cafe/Program.cs @@ -18,7 +18,7 @@ builder.Services.AddControllers(); builder.Services.AddDbContext(opt => opt.UseInMemoryDatabase("CatCafe")); builder.Services.AddDbContext(opt => -opt.UseInMemoryDatabase("CatCafe")); +opt.UseSqlite("CatCafe")); builder.Services.AddDbContext(opt => opt.UseInMemoryDatabase("CatCafe")); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle diff --git a/cat_cafe/Repositories/CustomerContext.cs b/cat_cafe/Repositories/CustomerContext.cs index a96292f..a8f9406 100644 --- a/cat_cafe/Repositories/CustomerContext.cs +++ b/cat_cafe/Repositories/CustomerContext.cs @@ -5,9 +5,23 @@ namespace cat_cafe.Repositories { public class CustomerContext:DbContext { - public CustomerContext(DbContextOptions options) + + public readonly IConfiguration configuration; + + public CustomerContext(IConfiguration _configuration) + { + configuration = _configuration; + } + + protected override void OnConfiguring(DbContextOptionsBuilder opts) + { + opts.UseSqlite(configuration.GetConnectionString(@"Data Source=CatCafe.db")); + } + + + /*public CustomerContext(DbContextOptions options) : base(options) - { } + { }*/ public DbSet Customers { get; set; } = null!; } } diff --git a/cat_cafe/log.txt b/cat_cafe/log.txt index 241e869..a524769 100644 --- a/cat_cafe/log.txt +++ b/cat_cafe/log.txt @@ -87,3 +87,21 @@ 2023-01-18 16:21:45.996 +01:00 [INF] program start 2023-01-18 16:21:58.069 +01:00 [INF] POST => post customer 2023-01-18 16:21:58.244 +01:00 [INF] POST => 201 cat_cafe.Entities.Customer {"Id":1,"FullName":"string","Age":0} +2023-01-18 16:24:20.049 +01:00 [INF] PUT => put by ID 1 +2023-01-18 16:24:20.052 +01:00 [INF] PUT => 400 IDs not matching +2023-01-18 16:24:29.668 +01:00 [INF] PUT => put by ID 1 +2023-01-18 16:24:29.705 +01:00 [INF] PUT => 200 cat_cafe.Entities.Customer {"Id":1,"FullName":"string","Age":0} +2023-01-18 16:24:41.242 +01:00 [INF] GET => get All customers +2023-01-18 16:24:41.331 +01:00 [INF] GET => 200 System.Collections.Generic.List`1[cat_cafe.Entities.Customer] length[1] +2023-01-18 16:24:50.036 +01:00 [INF] PUT => put by ID 1 +2023-01-18 16:24:50.038 +01:00 [INF] PUT => 200 cat_cafe.Entities.Customer {"Id":1,"FullName":"stringdfdfdf","Age":0} +2023-01-18 16:25:01.929 +01:00 [INF] GET => get All customers +2023-01-18 16:25:01.930 +01:00 [INF] GET => 200 System.Collections.Generic.List`1[cat_cafe.Entities.Customer] length[1] +2023-01-18 16:26:22.655 +01:00 [INF] program start +2023-01-21 08:07:49.648 +01:00 [INF] program start +2023-01-21 08:22:24.735 +01:00 [INF] program start +2023-01-21 08:45:51.715 +01:00 [INF] program start +2023-01-21 08:46:50.522 +01:00 [INF] program start +2023-01-21 08:51:20.382 +01:00 [INF] program start +2023-01-21 09:52:51.283 +01:00 [INF] program start +2023-01-21 09:53:00.966 +01:00 [INF] POST => post customer