示例#1
0
        public object Get()
        {
            Mapper.Reset();
            Mapper.CreateMap <CardDemo, CardDemoModel>();
            Mapper.CreateMap <CardType, CardTypeModel>().ForMember(n => n.CardDemoModels, opt => opt.MapFrom(src => src.CardDemos));
            var all    = _cardTypeService.GetCardTypes().ToList();
            var roots  = all.Where(n => n.Parent == null).ToList();
            var result = new List <CardTypeModel>();

            Recursion(roots, all, result);
            return(result);
        }
示例#2
0
        public ActionResult <List <CardTypeOutput> > GetCardTypes()
        {
            List <CardTypeOutput> result  = new List <CardTypeOutput>();
            GetCardTypesCommand   command = new GetCardTypesCommand
            {
                GetActiveRecords = true
            };
            Task <GetCardTypesCommandResult> resultValue = _cardTypeService.GetCardTypes(command);

            if (resultValue.Result.ResultObject.Success)
            {
                foreach (var item in resultValue.Result.ResultObject.Data)
                {
                    result.Add(new CardTypeOutput()
                    {
                        CardTypeId = item.CardTypeId, Name = item.Name, IsSuccess = true
                    });
                }

                return(Ok(result));
            }
            else
            {
                return(BadRequest(result));
            }
        }