示例#1
0
        public async Task <CreateResponse <IClient> > CreateAsync()
        {
            var createResponse = new CreateResponse <IClient>();

            try
            {
                var client = new Client
                {
                    Name        = "<New Client>",
                    ClientType  = ClientTypeEnum.InsuranceCarrier,
                    ProcessType = AuditProcessTypeEnum.SharedAudit
                };

                // Create a billing contact
                var contactResponse = await _contactApplicationService.CreateAsync(client.Id, ContactTypeEnum.Billing);

                if (!contactResponse.IsSuccessful)
                {
                    return(createResponse.Join <CreateResponse <IClient> >(contactResponse));
                }

                client.Contacts.Add(contactResponse.Content);

                // Create a client contact
                contactResponse = await _contactApplicationService.CreateAsync(client.Id, ContactTypeEnum.Client);

                if (!contactResponse.IsSuccessful)
                {
                    return(createResponse.Join <CreateResponse <IClient> >(contactResponse));
                }

                client.Contacts.Add(contactResponse.Content);

                // Create an address
                var addressResponse = await _addressApplicationService.CreateAsync();

                if (!addressResponse.IsSuccessful)
                {
                    return(createResponse.Join <CreateResponse <IClient> >(addressResponse));
                }

                client.Address = addressResponse.Content;

                createResponse.Content = client;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                createResponse.AddError(ex);
                _logManager.LogError(ex, "Unable to create a new client");
            }

            return(createResponse);
        }
示例#2
0
        public async Task <ICreateResponse <IAudit> > CreateAsync(AuditRequest request)
        {
            var response = new CreateResponse <Audit>();

            try
            {
                var audit = new Audit();
                var policyCreateResponse = await _policyApplicationService.CreateAsync(request);

                response.Join <CreateResponse <Audit> >(policyCreateResponse);

                if (policyCreateResponse.IsSuccessful)
                {
                    audit.Policy = (Policy)policyCreateResponse.Content;
                }
            }
            catch (Exception ex)
            {
                _logManager.LogError(ex, "AuditApplicationService.CreateAsync");
                response.AddError(ex);
            }

            return(response);
        }