Esempio n. 1
0
        // GET: Employees/Details/5
        public async Task <IActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var employee = await _repository.GetEmployeeDetailsAsync(id);


            // This code is left commented out intentionally.
            //
            // What I am showing here is the ability to call another project/service/microservice to facilitate getting and processing the Discount information.
            // Ideally breaking apart functionality/seperating concerns such as a microservice would allow the Discount Processing to be handled elsewhere outside
            // context of the Benefit Project.
            //
            // To futher illustrate this I have made seperate Projects in the Solution to show that all Discount Related boundaries have there own project/service/repoLayer
            // to call upon and calculate the discount.
            //
            // This is not a perfect example as I am keeping everything under one Solution and therfore it keeps dependecies to the projects. In real world practice this
            // would be a seperate project/service that is agnostic to this solution.
            //
            //var discountApiController = new DiscountController(_discountRepository);
            //var result = await discountApiController.GetEmployeeBenefitCost(employee.EmployeeId, employee.FirstName, employee.LastName, employee.Dependents.ToList());


            // Here I am simply calling the repository for the Microservice directly as explained above for berevity in the project.
            var employeeDetailResult = await _discountRepository.GetDiscountResult(employee.EmployeeId, employee.FirstName, employee.LastName, employee.Dependents);



            if (employeeDetailResult == null)
            {
                return(NotFound());
            }

            return(View(employeeDetailResult));
        }