コード例 #1
0
        public bool Register(RegisterViewModel model)
        {
            var result = CanRegister(model);

            if (result)
            {
                var employee = new Employee
                {
                    SSN            = model.SSN,
                    FirstName      = model.FirstName,
                    LastName       = model.LastName,
                    HashedPassword = _passwordHasher.Hash(model.Password),
                    Address        = model.Address,
                    DateOfBirth    = model.DateOfBirth,
                    Email          = model.EmailAddress,
                    Username       = model.UserName,
                    EmployeeRoleId = model.RoleId
                };
                var createdEmp = _employeeService.Add(employee);

                foreach (var phoneNumber in model.PhoneNumbers)
                {
                    _phoneNumberService.AddPhoneNumber(createdEmp.Id, phoneNumber);
                }

                return(true);
            }
            return(false);
        }
コード例 #2
0
 public async Task <IActionResult> Add([FromBody] PhoneNumbers phoneNumber)
 {
     return(Ok(await _phoneNumbersService.AddPhoneNumber(phoneNumber)));
 }