コード例 #1
0
        public void RecordLog(Log log)
        {
            var typesAllowed = new TypeLogEnum []
            {
                TypeLogEnum.Error,
                TypeLogEnum.Warning,
                TypeLogEnum.Information
            };

            if (typesAllowed.Contains(log.Type))
            {
                try{
                    log.Date = DateTime.Now;
                    _logRepository.Insert(log);
                }catch (Exception e) {
                    Console.WriteLine(e.Message);
                    throw new Exception("An error ocurred, please contact the administrator.");
                }
            }
            else
            {
                throw new Exception("Just allowed 3 types of Log: Information, Error, Waring.");
            }
        }