public async Task <EntityResponse <ProductApproval> > Handle(GetProductApprovalQuery request, CancellationToken cancellationToken) { var response = new EntityResponse <ProductApproval> () { ReponseName = nameof(GetProductApprovalQuery), Content = new List <ProductApproval> () { } }; var entity = await _approvalRepository.GetOneAsync(p => p.Id == request.Id); entity = _mapper.Map <ProductApproval> (entity);; if (entity == null) { response.Status = ResponseType.Warning; response.Message = $"{nameof(ProductApproval)} not found."; response.Content = null; } else { response.Status = ResponseType.Success; response.Message = $"{nameof(ProductApproval)} get successfully."; response.Content.Add(entity); } return(response); }
public async Task <ActionResult <EntityResponse <ProductApproval> > > GetProductApprovalEntity(string id) { try { var query = new GetProductApprovalQuery(id); var result = await _mediator.Send(query); return(Ok(result)); } catch (Exception ex) { var err = new EntityResponse <ProductApproval> (); err.ReponseName = nameof(GetProductApprovalEntity); err.Status = ResponseType.Error; err.Message = ex.Message; err.Content = null; return(Ok(err)); } }