Ejemplo n.º 1
0
        public int Add(int discsNumber)
        {
            HanoiLog log = new HanoiLog()
            {
                CreationTime = DateTime.Now, DiscsNumber = discsNumber
            };

            _context.Logs.Add(log);
            _context.SaveChanges();
            return(log.LogId);
        }
Ejemplo n.º 2
0
        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();
        }
Ejemplo n.º 3
0
        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);
        }