예제 #1
0
 public ActionResult NewAccount(NewAccountModel newAccountModel)
 {
     if (ModelState.IsValid)
     {
         var service = new AccountService();
         try
         {
             service.AddNewUser(newAccountModel);
             FormsAuthentication.RedirectToLoginPage();
         }
         catch (UpdateException updateEx)
         {
             var sqlEx = updateEx.InnerException as SqlException;
             ModelState.AddModelError("NewUserError",
                                      sqlEx.Number == 2601
                                          ? "This UserName is already used by another user"
                                          : "Database error while creating new user");
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("NewUserError", "Unknown error while creating new user");
         }
     }
     return View(newAccountModel);
 }
예제 #2
0
 public void AddNewUser(NewAccountModel newAccount)
 {
     UserRepository.AddNewUser(new User
         {
             UserName = newAccount.UserName,
             Password = newAccount.Password,
             Point = 0
         });
 }
예제 #3
0
 public AccountViewModel()
 {
     LoginModel = new LoginModel();
     NewAccountModel = new NewAccountModel();
 }