public async Task <ActionResult> Index(int active)
        {
            bool isAcive = active.ToBoolean();
            var  plans   = await _plansService.FetchAsync(isAcive);

            plans = plans.GetOrdered();

            var models = plans.MapViewModelList(_mapper);

            return(Ok(models));
        }
Example #2
0
        public async Task <Plan> FindActivePlanAsync()
        {
            bool active      = true;
            var  activePlans = await _plansService.FetchAsync(active);

            if (activePlans.IsNullOrEmpty())
            {
                //例外
                _logger.LogException(new NoActivePlanFound());

                return(null);
            }
            else if (activePlans.Count() > 1)
            {
                //例外
                _logger.LogException(new MutiActivePlanFound());

                return(activePlans.GetOrdered().FirstOrDefault());
            }
            else
            {
                return(activePlans.FirstOrDefault());
            }
        }