public EmployeeController(IOptionsMonitor <ApiSettings> settings, IQuery <EmployeeEntity, Guid> getEmployeeAndCurrentSalaryQuery, IQueryNoParam <List <EmployeeEntity> > getAllEmployeesAndSalariesQuery,
                           IAddCommandNoResult <EmployeeEntity> addEmployeeCommand, IUpdateCommandNoResult <EmployeeEntity> updateEmployeeCommand)
 {
     _settings = settings.CurrentValue;
     _getEmployeeAndCurrentSalaryQuery = getEmployeeAndCurrentSalaryQuery;
     _getAllEmployeesAndSalariesQuery  = getAllEmployeesAndSalariesQuery;
     _addEmployeeCommand    = addEmployeeCommand;
     _updateEmployeeCommand = updateEmployeeCommand;
 }
 public DependentsController(IOptionsMonitor <ApiSettings> settings, IQuery <List <Dependent>, Guid> getEmployeeDependentsQuery,
                             IAddCommandNoResult <Dependent> addDependentCommand, IUpdateCommandNoResult <Dependent> updateDependentCommand, IQuery <Dependent, Guid> getEmployeeDependentQuery)
 {
     _settings = settings.CurrentValue;
     _getEmployeeDependentsQuery = getEmployeeDependentsQuery;
     _getEmployeeDependentQuery  = getEmployeeDependentQuery;
     _addDependentCommand        = addDependentCommand;
     _updateDependentCommand     = updateDependentCommand;
 }
Ejemplo n.º 3
0
        public async Task UpdateEmployee(IUpdateCommandNoResult <EmployeeEntity> updateEmployeeCommand, IQuery <EmployeeEntity, Guid> getEmployeeAndSalaryQuery,
                                         UpdateEmplyoeeModel employeeModel)
        {
            var employeeToUpdate = await getEmployeeAndSalaryQuery.ExecuteQueryAsync(employeeModel.Id);

            employeeToUpdate.FirstName = employeeModel.FirstName;
            employeeToUpdate.LastName  = employeeModel.LastName;
            employeeToUpdate.UpdatedOn = DateTime.Now;

            //  todo: apply error checking before executing command
            await updateEmployeeCommand.ExecuteAsync(employeeToUpdate);
        }
Ejemplo n.º 4
0
        public async Task UpdateDependentAsync(IUpdateCommandNoResult <Dependent> updateDependentCommand, IQuery <Dependent, Guid> getDependentQuery,
                                               UpdateDependentModel dependentModel)
        {
            var dependentToUpdate = await getDependentQuery.ExecuteQueryAsync(dependentModel.Id);

            dependentToUpdate.FirstName = dependentModel.FirstName;
            dependentToUpdate.LastName  = dependentModel.LastName;
            dependentToUpdate.Ssn       = dependentModel.Ssn;
            dependentToUpdate.Dob       = dependentModel.Dob;
            dependentToUpdate.UpdatedOn = DateTime.Now;

            //  todo: apply error checking before executing command
            await updateDependentCommand.ExecuteAsync(dependentToUpdate);
        }