コード例 #1
0
        public async Task AddEmployee(IAddCommandNoResult <EmployeeEntity> addEmployeeCommand, AddEmployeeModel employeeModel)
        {
            //  todo: apply error checking before executing command
            var now      = DateTime.Now;
            var employee = new EmployeeEntity();

            employee.FirstName = employeeModel.FirstName;
            employee.LastName  = employeeModel.LastName;
            employee.Id        = Guid.NewGuid();
            employee.CreatedOn = now;
            employee.CreatedBy = string.Empty;
            employee.UpdatedOn = now;
            employee.UpdatedBy = string.Empty;
            employee.Salary    = new List <EmployeeSalary>
            {
                new EmployeeSalary()
                {
                    YearlyWages = 2000 * 26,
                    StartDate   = DateTime.Now,
                    EndDate     = null,
                    CreatedOn   = now,
                    CreatedBy   = string.Empty,
                    UpdatedOn   = now,
                    UpdatedBy   = string.Empty
                }
            };
            await addEmployeeCommand.ExecuteAsync(employee);
        }
コード例 #2
0
 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;
 }
コード例 #3
0
 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;
 }
コード例 #4
0
        public async Task AddDependentAsync(IAddCommandNoResult <Dependent> addEmployeeCommand, AddDependentModel dependentModel)
        {
            //  todo: apply error checking before executing command
            var now       = DateTime.Now;
            var dependent = new Dependent();

            dependent.Id         = Guid.NewGuid();
            dependent.EmployeeId = dependentModel.EmployeeId;
            dependent.FirstName  = dependentModel.FirstName;
            dependent.LastName   = dependentModel.LastName;
            dependent.Ssn        = dependentModel.Ssn;
            dependent.Dob        = dependentModel.Dob;
            dependent.CreatedOn  = now;
            dependent.CreatedBy  = string.Empty;
            dependent.UpdatedOn  = now;
            dependent.UpdatedBy  = string.Empty;
            await addEmployeeCommand.ExecuteAsync(dependent);
        }