public async Task <ApiResult <GetByIdListProductType> > GetById(int id) { var productType = await _context.ProductTypes.FindAsync(id); if (productType == null) { return(new ApiErrorResult <GetByIdListProductType>("Loại nguyên vật liệu không tồn tại")); } var query = await(from s in _context.ProductTypes join g in _context.ProductTypeGroups on s.IdProductTypeGroup equals g.Id where s.Id == id select new GetByIdListProductType() { Id = s.Id, Code = s.Code, Name = s.Name, IdGroupType = s.IdProductTypeGroup, GroupType = g.Name }).FirstAsync(); var result = new GetByIdListProductType() { Id = query.Id, Code = query.Code, Name = query.Name, IdGroupType = query.IdGroupType, GroupType = query.GroupType }; return(new ApiSuccessResult <GetByIdListProductType>(result)); }
public async Task <GetByIdListProductType> GetById(int id) { var result = await _productTypeApiClient.GetById(id); var data = new GetByIdListProductType() { Code = result.ResultObj.Code, Name = result.ResultObj.Name, IdGroupType = result.ResultObj.IdGroupType, GroupType = result.ResultObj.GroupType }; return(data); }