public async Task <GetByIdListMaterialsType> GetById(int id) { var result = await _materialsTypeApiClient.GetById(id); var data = new GetByIdListMaterialsType() { Code = result.ResultObj.Code, Name = result.ResultObj.Name, GroupType = result.ResultObj.GroupType }; return(data); }
public async Task <ApiResult <GetByIdListMaterialsType> > GetById(int id) { var materialsType = await _context.MaterialsTypes.FindAsync(id); if (materialsType == null) { return(new ApiErrorResult <GetByIdListMaterialsType>("Loại nguyên vật liệu không tồn tại")); } var result = new GetByIdListMaterialsType() { Id = materialsType.Id, Code = materialsType.Code, Name = materialsType.Name, GroupType = materialsType.GroupType == GroupType.NguyenLieu ? "Nguyên Liệu" : materialsType.GroupType == GroupType.NhienLieu ? "Nhiên Liệu" : "Vật Liệu" }; return(new ApiSuccessResult <GetByIdListMaterialsType>(result)); }