Пример #1
0
        public async Task Invoke(HttpContext context, RailroadContext dbcontext)
        {
            IEnumerable <Staff> staffs;
            IEnumerable <Post>  posts;
            IEnumerable <Train> trains;

            if (!cache.TryGetValue("Post", out posts))
            {
                cache.Set("Post", dbcontext.Posts.ToList(), new MemoryCacheEntryOptions());
            }
            if (!cache.TryGetValue("Train", out trains))
            {
                cache.Set("Train", dbcontext.Trains.ToList(), new MemoryCacheEntryOptions());
            }
            if (!cache.TryGetValue("Staff", out staffs))
            {
                cache.Set("Staff", dbcontext.Staffs.Include(p => p.Post).ToList(), new MemoryCacheEntryOptions());
            }
            await _next.Invoke(context);
        }
 public PostController(RailroadContext rc, IMemoryCache cache)
 {
     railroadContext = rc;
     this.cache      = cache;
 }
 public TypeController(RailroadContext rc)
 {
     railroadContext = rc;
 }
Пример #4
0
 public TrainController(RailroadContext rc)
 {
     railroadContext = rc;
 }