예제 #1
0
        public Admin GetAdmin(int id)
        {
            var admin = CacheRepository.GetItem <Admin>($"{AdminCache}-{id}");

            if (admin != null)
            {
                return(admin);
            }

            admin = AdminRepository.Get(id);
            if (admin == null)
            {
                throw new AdminNullException();
            }
            CacheRepository.Add(admin, $"{AdminCache}-{id}");
            return(admin);
        }
예제 #2
0
        public FileModel GetFile(int id)
        {
            var file = CacheRepository.GetItem <FileModel>($"{FileCache}-{id}");

            if (file != null)
            {
                return(file);
            }

            file = FileRepository.Get(id);
            if (file == null)
            {
                throw new FileNullException();
            }
            CacheRepository.Add(file, $"{FileCache}-{id}");
            return(file);
        }