public Ref_Product_TypesDTO ViewDetail(string id) { var type = dal.ViewDetail(id); if (type != null) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <Product, Ref_Product_TypesDTO>(); }); IMapper iMapper = config.CreateMapper(); var productModel = iMapper.Map <Ref_Product_Types, Ref_Product_TypesDTO>(type); return(productModel); } return(null); }