public OperationResult CreateEmployee(Model.Employee model) { using (IUnitOfWork unitofwork = new EntityFrameworkContext()) { IEmployeeRepository employeeRepository = new EmployeeRepository(unitofwork); if (!employeeRepository.ExistsUserName(model.UserName)) { employeeRepository.Insert(model); unitofwork.Commit(); return new OperationResult(OperationResultType.Success, "用户注册成功."); } return new OperationResult(OperationResultType.NoChanged, "用户名已存在."); } }