Example #1
0
        public async Task <IActionResult> CreateEmployee([FromBody] DtoCreateEmployeeRequest request)
        {
            if (ModelState.ValidationState != ModelValidationState.Valid)
            {
                return(BadRequest());
            }

            return(await employees.CreateEmployee(new Employee
            {
                VenueId = request.VenueId,
                CompanyId = request.CompanyId,
                Username = request.Username,
                PasswordHash = crypto.Generate(request.Password),
                EmployeeName = request.EmployeeName,
                RoleId = request.RoleId
            })
                   .Ensure(e => e.HasValue, "Employee was created")
                   .OnBoth(e => e.IsFailure ? StatusCode(500) : StatusCode(201))
                   .ConfigureAwait(false));
        }
Example #2
0
 public string HashPassword(Employee user, string password)
 {
     return(_cryptoHelper.Generate(password));
 }