Esempio n. 1
0
 public ActionResult Register(RegisterViewModel register)
 {
     if (ModelState.IsValid)
     {
         var user = new User
                        {
                            DayOfBirth = register.DayOfBirth,
                            EMail = register.EMail,
                            FirstName = register.FirstName,
                            GenderId = Guid.Parse(register.Gender),
                            MatrialStatusId = Guid.Parse(register.MatrialStatus),
                            LastName = register.LastName,
                            Password = register.Password,
                            UserId = Guid.NewGuid()
                        };
         try
         {
             _authenticator.CreateUser(user);
         }
         catch (UserCreateMailAlreadyUsingExeption)
         {
             register = _modelFactory.RegisterViewModel(register);
             return View(register);
         }
     }
     register.PossibleGenders = _modelFactory.RegisterViewModel().PossibleGenders;
     register.PossibleMatrialStatus = _modelFactory.RegisterViewModel().PossibleMatrialStatus;
     return View();
 }
Esempio n. 2
0
 public void CreateUser(User user)
 {
     if(this._repository.GetUsers().Any(x => x.EMail == user.EMail))
     {
         throw new UserCreateMailAlreadyUsingExeption();
     }
     this._repository.AddUser(user);
 }
Esempio n. 3
0
 public void AddUser(User user)
 {
     this._dataBaseContex.Users.Add(user);
     this._dataBaseContex.SaveChanges();
 }