public override void CreateDatabase() { var context = new SqlLiteDbContext(DataAccess.GetDefaultSqliteConnection(), false); if (!context.Set <Weapon>().Any()) { context.Set <Weapon>().AddRange(new DefaultDataFactory().GetWeaponSeed()); context.SaveChanges(); } if (!context.Set <WeaponAttribute>().Any()) { context.Set <WeaponAttribute>().AddRange(new DefaultDataFactory().GetWeaponAttributeSeed()); context.SaveChanges(); } context.Dispose(); }
public static void WriteCommit(string folder, string commit, string caption) { try { LoggerDirectory = folder; if (!Directory.Exists(LoggerDirectory)) { Directory.CreateDirectory(LoggerDirectory); } TodayLoggerFile = Path.Combine(LoggerDirectory, "dlogger_" + DateTime.Now.ToString("MM_dd_yyyy") + ".txt"); SqlLiteDbContext.DailyLoggerCommit.Add(new DailyLoggerCommit { Caption = caption, Commit = commit, CommitTime = DateTime.Now, LoggingFilePath = TodayLoggerFile, }); SqlLiteDbContext.SaveChanges(); bool append = true; if (!File.Exists(TodayLoggerFile)) { using (var wt = File.Create(TodayLoggerFile)) { } int timeout = 5000; while (!File.Exists(TodayLoggerFile)) { Thread.Sleep(100); timeout -= 100; if (timeout < 0) { return; } } using (StreamWriter wt = new StreamWriter(TodayLoggerFile)) { wt.WriteLine($"--HH-{DateTime.Now.ToString("HH")}"); wt.WriteLine($"--HH:mm {DateTime.Now.ToString("HH:mm")}"); wt.WriteLine($"------- {DateTime.Now.ToString("HH:mm:ss")} ------"); wt.WriteLine(); wt.WriteLine(commit); wt.WriteLine(); wt.WriteLine($"--HH:mm {DateTime.Now.ToString("HH:mm")}"); wt.WriteLine($"--HH-{DateTime.Now.ToString("HH")}"); wt.WriteLine("--------------------------------------------------------------------------------"); } return; } using (StreamWriter wt = new StreamWriter(TodayLoggerFile, true)) { wt.WriteLine($"--HH-{DateTime.Now.ToString("HH")}"); wt.WriteLine($"--HH:mm {DateTime.Now.ToString("HH:mm")}"); wt.WriteLine($"------- {DateTime.Now.ToString("HH:mm:ss")} ------"); wt.WriteLine(); wt.WriteLine(commit); wt.WriteLine(); wt.WriteLine($"--HH:mm {DateTime.Now.ToString("HH:mm")}"); wt.WriteLine($"--HH-{DateTime.Now.ToString("HH")}"); wt.WriteLine("--------------------------------------------------------------------------------"); } } catch (Exception ex) { } }
public async Task RegisterProperty(PropertyDetail req) { _context.Property.Add(_mapper.Map <Property>(req)); _context.SaveChanges(); }
public async Task CreateOwner(OwnerDetail req) { _context.Owner.Add(_mapper.Map <Owner>(req)); _context.SaveChanges(); }