コード例 #1
0
        public async Task <IActionResult> Update([FromRoute] Guid organizationId,
                                                 [FromBody] ProviderOrganizationInput input)
        {
            var result = await _organizationService
                         .UpdateOrganization(_providerAgencyOwner.Value, input);

            if (result.Succeeded)
            {
                return(await Get(organizationId));
            }

            return(Ok(result));
        }
コード例 #2
0
        public async Task <OrganizationResult> UpdateOrganization(IProviderAgencyOwner agencyOwner, ProviderOrganizationInput input)
        {
            _logger.LogInformation(GetLogMessage("Organization:{0}; input:{@input}"), agencyOwner.OrganizationId, input);

            var providerOrganization = await Repository.Queryable()

                                       .Include(x => x.ProviderOrganization)
                                       .Include(x => x.Contractors)
                                       .Include(x => x.ProjectManagers)
                                       .Include(x => x.AccountManagers)

                                       .Where(x => x.Id == agencyOwner.OrganizationId)
                                       .Select(x => x.ProviderOrganization)
                                       .FirstAsync();

            var organization = await Repository.Queryable()
                               .Where(x => x.Id == agencyOwner.OrganizationId)
                               .FirstOrDefaultAsync();

            return(await UpdateProviderOrganization(providerOrganization, input, organization));
        }
コード例 #3
0
        private Task <OrganizationResult> UpdateProviderOrganization(ProviderOrganization providerOrganization, ProviderOrganizationInput input, Organization organization)
        {
            _logger.LogInformation(GetLogMessage("Organization:{0}; input:{@input}"), providerOrganization.Id, input);

            providerOrganization.DefaultAccountManagerId = input.DefaultAccountManagerId;
            providerOrganization.DefaultProjectManagerId = input.DefaultProjectManagerId;
            providerOrganization.DefaultContractorId     = input.DefaultContractorId;
            providerOrganization.Discoverable            = input.Discoverable;
            providerOrganization.InjectFrom(input);
            providerOrganization.Updated     = DateTimeOffset.UtcNow;
            providerOrganization.ObjectState = ObjectState.Modified;

            organization.ProviderOrganization = providerOrganization;
            var result = Repository.InsertOrUpdateGraph(organization, true);

            _logger.LogDebug(GetLogMessage("{0} Records updated"), result);

            return(Task.FromResult(new OrganizationResult()
            {
                OrganizationId = organization?.Id,
                Succeeded = result > 0
            }));
        }