コード例 #1
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;
        }
コード例 #2
0
 public ActionResult Register(RegisterModel registerModel)
 {
     registerModel.Login += "@SportStore.pl";
     if (_employeesHelper.RegisterEmployee(registerModel))
     {
         return RedirectToAction("Login");
     }
     else
     {
         ModelState.AddModelError("", "Podany kod rejestracyjny nie istnieje albo został wygaszony!");
         return View();
     }
 }