public Task <GetProductDetailByIdResponse> GetDetailAsync(GetProductDetailById dto) { return(Task.Run(() => { var worksEntity = _pruoductRepository.TableNoTracking.Where(t => t.Id.Equals(dto.id)).SingleOrDefault(); if (worksEntity != null) { GetProductDetailByIdResponse resp = Mapper.Map <GetProductDetailByIdResponse>(worksEntity); var productMeta = _pruoductMetaRepository.TableNoTracking.Where(t => t.PruductId.Equals(dto.id)).SingleOrDefault(); resp.is_hot = productMeta.IsHot; return resp; } else { throw new NotFoundException(string.Format("不存在id为:{0}的产品!", dto.id.ToString())); } })); }
public async Task <IHttpActionResult> Get([FromUri] GetProductDetailById dto) { var resp = _productService.GetDetailAsync(dto); return(Ok(resp)); }