public IActionResult Index() { var customers = _manager.Get <List <Customers> >("customers"); if (customers != null) { customers = customers.OrderBy(x => x.Id).ToList(); ViewBag.Customers = customers; } return(View()); }
public async Task <Response <List <BasketModel> > > ReadItemsByUserId(Request <int> request) { try { SetCacheTableByUser(request); var result = await _basketCacheContext.Get(); var fresult = result.Item1 ? result.Item2 : new List <BasketModel>(); return(Response(fresult)); } catch (System.Exception e) { throw; } }
public async Task <Response <List <ItemDto>, PageList> > GetItems(Request <Search> request) { try { var cacheResult = await _itemCache.Get(); var result = (cacheResult.Item1) ? cacheResult.Item2 : await _itemCache.RefillIfNot(await _itemRepository.GetAllAsNoTraking().ToListAsync()); var orderByRequest = request.Item.OrderByQuery.ToObject <ItemOrderByRequest>(returnDefault: true) ?? new ItemOrderByRequest(); var searchByRequest = request.Item.SearchTerm.ToObject <ItemSearchByRequest>(returnDefault: true) ?? new ItemSearchByRequest(); if (!string.IsNullOrEmpty(searchByRequest?.Name)) { result = result.Where(p => p.Name.StartsWith(request.Item.SearchTerm, System.StringComparison.InvariantCultureIgnoreCase)).ToList(); } if (searchByRequest.MinPrice.HasValue) { result = result.Where(p => p.Price >= searchByRequest.MinPrice.Value).ToList(); } if (searchByRequest.MaxPrice.HasValue) { result = result.Where(p => p.Price <= searchByRequest.MaxPrice.Value).ToList(); } if (searchByRequest.Brand.HasValue) { result = result.Where(p => p.BrandId == searchByRequest.Brand.Value).ToList(); } var count = result.Count(); result = orderByRequest.Name ? result.OrderBy(p => p.Name).ToList() : result.OrderByDescending(p => p.Name).ToList(); result = orderByRequest.Price ? result.OrderBy(p => p.Price).ToList() : result.OrderByDescending(p => p.Price).ToList(); result = orderByRequest.Review ? result.OrderBy(p => p.Price).ToList() : result.OrderByDescending(p => p.Price).ToList(); if (!request.Item.Take.IsZero()) { result = result.Skip(request.Item.Skip).Take(request.Item.Take).ToList(); } var dtos = Mapper.Map <List <ItemDto> >(result); dtos.ForEach(item => { item.SetImageWithPath(); }); return(PageResponse(dtos, count, request.Item)); } catch (System.Exception e) { throw e; } }
/// <summary> /// /// </summary> /// <param name="redisContext"></param> /// <param name="mobile"></param> /// <returns></returns> private SmsVerificationCode GetSmsVerificationCode(RedisContext redisContext, string mobile) { return(redisContext.Get <SmsVerificationCode>(REDIS_Key, mobile + DAY_Key)); }