示例#1
0
        public async Task <EmployeeViewResult> login(string email, string password)
        {
            var employee = await _dbContext.Employees.FirstOrDefaultAsync(e => e.Email == email);

            if (employee == null)
            {
                return(null);
            }
            else
            {
                if (_protectionService.VerifyHashedPassword(password, employee.Password))
                {
                    return(new EmployeeViewResult
                    {
                        Id = employee.Id,
                        Name = employee.Name,
                        PhoneNumber = employee.PhoneNumber,
                        Email = employee.Email,
                        JobTitle = employee.JobTitle
                    });
                }
                else
                {
                    return(null);
                }
            }
        }