public async Task <EmployeeResponseModel> CreateEmployee(EmployeeRequestModel employeeRequestModel) { var dbEmployee = await _employeesRepository.GetEmployeeByName(employeeRequestModel.Name); if (dbEmployee != null) { throw new Exception("Employee exists, try Login"); } //var salt = CreateSalt(); //var hashedPassword = CreateHashedPassword(employeeRequestModel.Password, salt); var employee = new Employees { Name = employeeRequestModel.Name, Password = employeeRequestModel.Password, Designation = employeeRequestModel.Designation, }; var response = await _employeesRepository.AddAsync(employee); var createdEmployee = new EmployeeResponseModel { Id = response.Id, Name = response.Name, Designation = response.Designation, }; return(createdEmployee); }
public Task <IActionResult> Add(Employees model) { return(Task.Factory.StartNew <IActionResult>(() => { if (!ModelState.IsValid) { return Json(ExcutedResult.FailedResult("数据验证失败")); } EmployeesRepository.AddAsync(model, false); return Json(ExcutedResult.SuccessResult()); })); }
public async Task <EntityActionOutcome> CreateEntityAsync(EmployeeInputData viewData) { var newEntity = _factory.Create(viewData); var validator = new EmployeeDataInputValidator(); var result = validator.Validate(viewData); if (result.IsValid == false) { return(EntityActionOutcome.MissingFullEntityData); } var upsertSuccessful = await _repository.AddAsync(newEntity); if (upsertSuccessful == null) { return(EntityActionOutcome.CreateFailed); } return(EntityActionOutcome.Success); }
public async Task HandleAsync(CreateEmployee command, ICorrelationContext context) { var employee = new Employee(command.Id, command.FirstName, command.SecondName, command.Surname, command.Birthday, command.EmployeeStatus, command.EmployeePosition); await _employeeRepository.AddAsync(employee); }
public async Task <Employees> CreateEmployees(Employees employees) { return(await _employeesRepository.AddAsync(employees)); }