Exemplo n.º 1
0
        public void GetAllTest()
        {
            logger.Log(aLog.LogType, aLog.Message, aLog.Username, aLog.Date);
            ICollection <LogInfoDto> logs = logger.GetAllLogs();

            Assert.AreEqual(1, logs.Count);
        }
        private IActionResult TryGet(DateTime from, DateTime to)
        {
            ICollection <LogInfoDto> logs;

            if (from != new DateTime() && to != new DateTime())
            {
                logs = logger.GetAllLogs(from, to);
            }
            else if (from != new DateTime())
            {
                logs = logger.GetAllLogs(from, DateTime.Now);
            }
            else if (to != new DateTime())
            {
                logs = logger.GetAllLogs(DateTime.MinValue, to);
            }
            else
            {
                logs = logger.GetAllLogs();
            }
            IEnumerable <LogModelOut> output = logs.Select(l => new LogModelOut {
                Id       = l.id,
                Date     = l.date,
                LogType  = l.logType,
                Message  = l.message,
                Username = l.username
            });

            return(Ok(output));
        }