Exemplo n.º 1
0
        public Task <Group> GetGroupForTeam(int teamId)
        {
            var cacheKey     = $"{CacheKeyPrefix}-groupByTeam-{teamId}";
            var valueFactory = new Func <Task <Group> >(async() => await resultService.GetGroupForTeam(teamId));

            try
            {
                return(cache.AddOrGetFromCache(cacheKey, valueFactory,
                                               DateTimeOffset.Now.Add(TimeSpan.FromMinutes(30))));
            }
            catch (ServiceException)
            {
                // do not cache exception
                cache.Remove(cacheKey);
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Team(int teamId)
        {
            Group            group = null;
            ServiceException error = null;

            try
            {
                group = await resultService.GetGroupForTeam(teamId);
            }
            catch (ServiceException e)
            {
                error = e;
            }

            var viewModel = new GroupViewModel(group, error);

            if (Request.IsAjaxRequest())
            {
                return(PartialView(viewModel));
            }

            return(View(viewModel));
        }