예제 #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();
 }
예제 #2
0
 public void CreateUser(User user)
 {
     if(this._repository.GetUsers().Any(x => x.EMail == user.EMail))
     {
         throw new UserCreateMailAlreadyUsingExeption();
     }
     this._repository.AddUser(user);
 }
예제 #3
0
 public void AddUser(User user)
 {
     this._dataBaseContex.Users.Add(user);
     this._dataBaseContex.SaveChanges();
 }