public bool CreateSale(SaleViewModel sale) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <SaleViewModel, SaleDTO>(); }); IMapper mapper = config.CreateMapper(); return(_dbConnect.CreateSale(mapper.Map <SaleViewModel, SaleDTO>(sale))); }