public async Task <IActionResult> JoinProviderOrganization(
            [FromRoute] Guid organizationId,
            [FromBody] JoinAsCustomerInput input)
        {
            var result = await _accountService.Create(_customer, input);

            if (!string.IsNullOrWhiteSpace(input.WorkOrderDescription))
            {
                await _workOrderService.CreateWorkOrder <BuyerWorkOrderOutput>(_customer, new WorkOrderInput()
                {
                    AccountManagerId             = result.AccountManagerId.Value,
                    AccountManagerOrganizationId = result.AccountManagerOrganizationId.Value,
                    Description = input.WorkOrderDescription,
                    IsDraft     = false
                });
            }

            return(Ok(result));
        }
Exemple #2
0
        public async Task <CustomerAccountResult> Create(IOrganizationCustomer cu, JoinAsCustomerInput input)
        {
            _logger.LogInformation(GetLogMessage("Customer: {0}"), cu.OrganizationId);

            var org = await _organizationService.Repository.Queryable()
                      .Include(x => x.ProviderOrganization)
                      .Include(x => x.AccountManagers)
                      .Where(x => x.ProviderOrganization.Discoverable && x.Id == input.ProviderOrganizationId)
                      .FirstOrDefaultAsync();

            var model = new CustomerAccountInput()
            {
                AccountManagerId             = org.ProviderOrganization.DefaultAccountManagerId,
                AccountManagerOrganizationId = org.Id,
                CustomerId             = cu.CustomerId,
                CustomerOrganizationId = cu.OrganizationId,
                PaymentTermId          = null
            };



            return(await Create(model));
        }