public async Task <ActionResult> Update(UpdateProduct request) { try { var result = await _mediator.Send(request); return(new OkObjectResult(result)); } catch (Exception ex) { return(LogExceptionHelper.CreateApiError(ex, _logger)); } }
public async Task <ActionResult> GetAll() { try { var result = await _mediator.Send(new FindAllQuery()); return(new OkObjectResult(result)); } catch (Exception ex) { return(LogExceptionHelper.CreateApiError(ex, _logger)); } }
public async Task <ActionResult> GetByCode([FromRoute] string code) { try { var result = await _mediator.Send(new FindByCodeQuery { Code = code }); return(new OkObjectResult(result)); } catch (Exception ex) { return(LogExceptionHelper.CreateApiError(ex, _logger)); } }
public async Task <ActionResult> GetAccessToken(LoginUser loginUser) { try { var accessToken = await _authService.GetAccessToken(loginUser.Username, loginUser.Password); if (accessToken == null) { return(Unauthorized()); } return(Ok(accessToken)); } catch (Exception ex) { return(LogExceptionHelper.CreateApiError(ex, _logger)); } }
public async Task <ActionResult> Create(CreateProduct request) { var authorizationHeader = HttpContext.Request.Headers["Authorization"]; var idToken = new IdentityToken(AuthenticationHeaderValue.Parse(authorizationHeader)); try { _logger.LogInformation($"in create function...UserId-{idToken.UserId} and Role-{idToken.Role}"); var result = await _mediator.Send(request); _logger.LogInformation("out from repo function..."); throw new Exception("this is test exception"); //return new OkObjectResult(result); } catch (Exception ex) { return(LogExceptionHelper.CreateApiError(ex, _logger)); } }