예제 #1
0
        private async Task SaveOrganisationApiClient()
        {
            try
            {
                var dto = new OrganisationDto
                {
                    Id          = OrgData.Id,
                    Name        = OrgData.Name,
                    MasterEmail = OrgData.MasterEmail
                };

                var results = await Mediator.Send(new ExecuteCommand(ExecuteCommand.HttpAction.Put, $"api/oranisations/{dto.Id}", dto));

                OrgData       = JsonConvert.DeserializeObject <OrganisationDto>(results);
                StatusMessage = "Organisation Saved";
            }
            catch (ThisAppException ex)
            {
                SiteLogger.LogError(this.ToString(), ex);
                StatusMessage = $"Save Organisation failed: {ex.Message}";
            }
            catch (System.Exception ex)
            {
                SiteLogger.LogError(this.ToString(), ex);
                StatusMessage = $"Save Organisation failed: {Messages.Err500}";
            }
            //finally
            //{
            //      TODO: functionality to associate this user with multiple organisations.
            //    await GetOrginisations();
            //}
        }
예제 #2
0
        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}";
            }
        }
예제 #3
0
        private async Task SaveOrginisationDirect()
        {
            try
            {
                OrgData = await Mediator.Send(new UpdateOrganisationCommand(OrgData.Id, OrgData.Name, OrgData.MasterEmail));

                StatusMessage = "Organisation Saved";
            }
            catch (ThisAppException ex)
            {
                SiteLogger.LogError(this.ToString(), ex);
                StatusMessage = $"Save Organisation failed: {ex.Message}";
            }
            catch (System.Exception ex)
            {
                SiteLogger.LogError(this.ToString(), ex);
                StatusMessage = $"Save Organisation failed: {Messages.Err500}";
            }
            //finally
            //{
            //      TODO: functionality to associate this user with multiple organisations.
            //    await GetOrginisations();
            //}
        }