void IEmployeeRepository.RegisterEmployee(employees model)
 {
     _context.Employees.Add(model);
     _context.SaveChanges();
 }
Esempio n. 2
0
        bool IEmployeesHelper.RegisterEmployee(RegisterModel model)
        {
            var registeredKey = _employeeRepository.GeneretedRegisterKeys
                .Where(x => x.RegisterPin == model.RegisterKey)
                .FirstOrDefault();

            if (registeredKey != null)
            {
                if (registeredKey.IsUsed != true)
                {
                    if (registeredKey.ExpirationDate >= DateTime.Now)
                    {
                        var modelToSave = new employees
                        {
                            Email = model.Login,
                            Password = PasswordHelper.Encrypt(model.Password),
                            Name = model.Name,
                            Surname = model.Surname,
                            Id_Rule = (int)Rules.Employee
                        };

                        _employeeRepository.RegisterEmployee(modelToSave);
                        _employeeRepository.SetUsedKey(registeredKey.Id);

                        return true;
                    }
                }
            }
            return false;
        }