static void Main(string[] args) { setDBFilePath(); var db = new Database.WaterDbContext(); var stations = db.StationTable.ToList(); stations.FirstOrDefault().LastRecordTime = DateTime.Now; db.StationTable.Remove(stations.LastOrDefault()); var station = new Models.Station() { ID = "123", CreateTime = DateTime.Now }; db.StationTable.Add(station); db.SaveChanges(); ShowStation(stations); Console.ReadKey(); }
public IActionResult Create(YC.Models.Station station) { station.ID = System.Guid.NewGuid().ToString(); station.CreateTime = System.DateTime.Now; _applicationDbContext.Stations.Add(station); _applicationDbContext.SaveChanges(); return(RedirectToAction("Index")); }