public List <AnswerViewModel> GetAnswersByAnswerID(int aid)
        {
            List <Answer>          ans    = ar.GetAnswersByAnswerID(aid);
            var                    config = new MapperConfiguration(cfg => { cfg.CreateMap <List <Answer>, List <AnswerViewModel> >(); cfg.IgnoreUnmapped(); });
            IMapper                mapper = config.CreateMapper();
            List <AnswerViewModel> avm    = mapper.Map <List <Answer>, List <AnswerViewModel> >(ans);

            return(avm);
        }
Пример #2
0
        public AnswerViewModel GetAnswerByAnswerID(int AnswerID)
        {
            Answer          a   = ar.GetAnswersByAnswerID(AnswerID).FirstOrDefault();
            AnswerViewModel avm = null;

            if (a != null)
            {
                var     config = new MapperConfiguration(cfg => { cfg.CreateMap <Answer, AnswerViewModel>(); cfg.IgnoreUnmapped(); });
                IMapper mapper = config.CreateMapper();
                avm = mapper.Map <Answer, AnswerViewModel>(a);
            }
            return(avm);
        }