public GoodDTO GetGoodById(int id) { using (var entities = new GoodDAL()) { var good = entities.tblGoods.FirstOrDefault(c => c.id == id); return(_mapper.Map <GoodDTO>(good)); } }
public List <GoodDTO> GetGoodByCategory(CategoryDTO categoryDTO) { List <GoodDTO> products = new List <GoodDTO>(); using (var entities = new GoodDAL()) { products = _mapper.Map <List <GoodDTO> >(entities.tblGoods.Where(c => c.category_id == categoryDTO.id)).ToList(); } return(products); }
public List <GoodDTO> GetAllProduct() { List <GoodDTO> products = new List <GoodDTO>(); using (var entities = new GoodDAL()) { products = _mapper.Map <List <GoodDTO> >(entities.tblGoods).ToList(); } return(products); }