public int Add(int discsNumber) { HanoiLog log = new HanoiLog() { CreationTime = DateTime.Now, DiscsNumber = discsNumber }; _context.Logs.Add(log); _context.SaveChanges(); return(log.LogId); }
public void UpdateEnd(int id) { HanoiLog log = _context.Logs.Where(l => l.LogId == id).FirstOrDefault(); if (log == null) { throw new Exception("Log not found"); } log.EndTime = DateTime.Now; _context.Entry(log).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); }
public HanoiExecution Get(int id) { HanoiExecution ex = null; HanoiLog log = _context.Logs.Where(l => l.LogId == id).FirstOrDefault(); if (log != null) { ex = new HanoiExecution() { HanoiExecutionId = log.LogId, CreationTime = log.CreationTime, DiscsNumber = log.DiscsNumber, EndTime = log.EndTime }; } return(ex); }