//[ValidateAntiForgeryToken()] public async Task <IActionResult> GetPrivateKeys(long organisationId) { try { //TODO: user id linked to org? //await MemberIsValid(memberId); var results = new OrganisationKeysDto() { Items = await Executor.CastTo <OrganisationKeyDto>().Execute(new GetOrganisationKeysQuery(organisationId)) }; return(Ok(results)); } catch (ThisAppException ex) { Logger.LogError($"GetPrivateKeys, {ex.StatusCode}, {ex.Message}", ex); return(StatusCode(ex.StatusCode, ex.Message)); } catch (System.Exception ex) { Logger.LogError($"GetPrivateKeys, {StatusCodes.Status500InternalServerError}", ex); return(StatusCode(StatusCodes.Status500InternalServerError, Messages.Err500)); } }
private async Task GetOrginisations() { try { var Organisations = new List <OrganisationDto>(); var email = User.Identity.Name; Organisations = await Executor.CastTo <OrganisationDto>().Execute(new GetOrganisationsQuery(email), o => o.Name); if (Organisations == null || Organisations.Count == 0) { //create a new one OrgData = await Mediator.Send(new CreateOrganisationCommand(email, email)); StatusMessage = "Profile created. Please update as required"; return; } OrgData = Organisations.First(); //TODO: functionality to associate this user with multiple organisations. } catch (ThisAppException ex) { SiteLogger.LogError(this.ToString(), ex); StatusMessage = $"Listing Organisations failed: {ex.Message}"; } catch (System.Exception ex) { SiteLogger.LogError(this.ToString(), ex); StatusMessage = $"Listing Organisations failed: {Messages.Err500}"; } }
//[RequirePersonalAccessToken] //[ValidateAntiForgeryToken()] public async Task <IActionResult> GetOrganisationsForEmailAddress(string email) //GetOrganisationsForLoggedInUser() { try { //TODO: user id linked to org? //await MemberIsValid(memberId); //if (string.IsNullOrWhiteSpace(User.Identity.Name)) // throw new ThisAppExecption(StatusCodes.Status403Forbidden, "Invalid user name"); var results = await Executor.CastTo <OrganisationDto>().Execute(new GetOrganisationsQuery(email), o => o.Name); return(Ok(results)); } catch (ThisAppException ex) { Logger.LogError($"GetOrganisationsForLoggedInUser, {ex.StatusCode}, {ex.Message}", ex); return(StatusCode(ex.StatusCode, ex.Message)); } catch (System.Exception ex) { Logger.LogError($"GetOrganisationsForLoggedInUser, {StatusCodes.Status500InternalServerError}", ex); return(StatusCode(StatusCodes.Status500InternalServerError, Messages.Err500)); } }
public async Task <ActionResult <List <RefTypeDto> > > GetStage(long id) { try { Logger.LogInformation($"GetStages was queried by {User.Identity.Name} with Id={id}"); var values = await Executor.CastTo <RefTypeDto>().Execute(new GetStageQuery(id)); Logger.LogInformation(Request.Path); return(Ok(values)); } catch (Exception ex) { Logger.LogError($"GetStages Failed: {ex.Message}", ex); return(Ok(HttpStatusCode.InternalServerError)); } }