コード例 #1
0
ファイル: SessionsController.cs プロジェクト: cri5ti/ippppp
 public async IAsyncEnumerable <Session> GetAll()
 {
     await foreach (var session in _sessionRepository.GetAll())
     {
         yield return(session);
     }
 }
コード例 #2
0
        public IActionResult GetHistory()
        {
            ICollection <Session> sessionHistory = sessionRepository.GetAll();
            var userEmail = HttpContext.User.Identity.Name;

            userService.SelectCurrentUser(userEmail);

            ICollection <Order> orderHistoy = new List <Order>();

            foreach (var session in sessionHistory)
            {
                if (session.IsActive == false)
                {
                    foreach (var order in session.Orders)
                    {
                        if (order.IsActive == false && order.User.Email == userEmail)
                        {
                            orderHistoy.Add(order);
                        }
                    }
                }
            }

            return(View(orderHistoy));
        }
コード例 #3
0
        public async Task <ActionResult <ICollection <SessionResponse> > > Get(DateTimeOffset?fromDate = null,
                                                                               DateTimeOffset?toDate   = null)
        {
            fromDate = fromDate ?? DateTimeOffset.MinValue;
            toDate   = toDate ?? DateTimeOffset.MaxValue;

            var cachedValue = await _cache.GetAsync(string.Format("{0}, from:{1}, to:{2}", _getSessions, fromDate, toDate));

            var result = cachedValue.FromByteArray <List <SessionResponse> >();

            if (result == null)
            {
                result = _sessionsRepository.GetAll()
                         .Where(s => IsSessionWithinDateRange(fromDate, toDate, s))
                         .Select(m => m.MapSessionResponse())
                         .ToList();

                await CacheValue(_getSessions, result);
            }

            return(result);
        }