public IActionResult PostContractItem([FromBody] ContractDetailsForPostDto contractDetails)
        {
            var customer = _repository.GetCustomerByName(contractDetails.CustomerName);

            if (customer == null)
            {
                _logger.LogInformation($"Customer with name {contractDetails.CustomerName} not found.");
                ModelState.AddModelError("Customer Name", "Customer does not exist!");
                return(BadRequest(ModelState));
            }
            var planType = _repository.GetCoveragePlan(contractDetails.CustomerCountry, customer.DateOfBirth);
            var age      = DateTime.Now.Year - contractDetails.DOB.Year;

            if (planType == null)
            {
                _logger.LogInformation("Suitable Coverage Plan not found for provided paramters.");
                ModelState.AddModelError("Coverage Plan", "Coverage Plan not found!");
                return(BadRequest(ModelState));
            }
            object g      = null;
            Gender gender = (Gender)
                            (Enum.TryParse(typeof(Gender), contractDetails.CustomerGender, true, out g) ? g : Gender.Other);
            var rate = _repository.GetRate(gender, age, planType);

            if (rate == null)
            {
                _logger.LogInformation($"Rate not found for Plan Id {planType.PlanId}.");
                ModelState.AddModelError("Rate", "Rate not found!");
                return(BadRequest(ModelState));
            }
            var contractItem = new ContractItem
            {
                CustomerId = customer.CustomerId,
                SaleDate   = contractDetails.SaleDate,
                CoverageId = planType.PlanId,
                NetPrice   = rate.NetPrice
            };

            try
            {
                _repository.SaveContract(contractItem);
            }
            catch (DbUpdateConcurrencyException ex)
            {
                _logger.LogCritical("Database update concurrency exception thrown", ex);
                return(StatusCode(500, "Internal Server Error has occurred."));
            }


            return(CreatedAtAction("GetContract", new { id = contractItem.ContractId }, contractItem));
        }