Example #1
0
        private async Task _QueryOverCreatedEntities(PolicyController policyController)
        {
            var(policyDtos, shipCargoPolicyItemDtos) =
                await policyController.GetResultFromMultipleQueries(policyTerms : "one", shipName : "golden");

            Console.WriteLine($"Policies by terms query was executed. Number of policy dtos queried: {policyDtos.Count()}");
            Console.WriteLine(
                $"Ship cargo policy items by ship name query was executed. Number of ship cargo policy item dtos queried: " +
                $"{shipCargoPolicyItemDtos.Count()}");
        }
Example #2
0
        private async Task _CreateEntitiesUsingCommands(
            ShipController shipController,
            PolicyHolderController policyHolderController,
            PolicyController policyController,
            NhibernateUnitOfWork nhibernateUnitOfWork
            )
        {
            var shipOneId = await shipController.CreateNewShipAsync("lady star", 10m);

            var shipTwoId = await shipController.CreateNewShipAsync("golden sea", 20m);

            var newPolicyHolderId = await policyHolderController.CreateNewPolicyHolderAsync("Policy holder name");

            var today            = DateTime.Today;
            var todayPlusOneYear = today.AddYears(1);

            var policyOneId = await policyController.CreateNewPolicyAsync(
                policyHolderId : newPolicyHolderId,
                startDate : today,
                endDate : todayPlusOneYear,
                terms : "policy one terms"
                );

            await policyController.AddShipToPolicyAsync(policyOneId, shipOneId, insuredTonnage : 8m, ratePerTonnage : 5m);

            await policyController.AddShipToPolicyAsync(policyOneId, shipTwoId, insuredTonnage : 18m, ratePerTonnage : 6m);

            var policyTwoId = await policyController.CreateNewPolicyAsync(
                policyHolderId : newPolicyHolderId,
                startDate : today,
                endDate : todayPlusOneYear,
                terms : "policy two terms"
                );

            nhibernateUnitOfWork.Flush();
        }