public static AccountModel RegisterAccount(RegisterAccountModel registerAccountModel)
 {
     var adm = AccountDataMapper.GetAccountDataMapper();
     if (adm.GetById(registerAccountModel.Username.ToLower()) == null)
     {
         AccountModel accountModel = new AccountModel();
         accountModel.Username = registerAccountModel.Username.ToLower();
         accountModel.Password = registerAccountModel.Password;
         accountModel.Email = registerAccountModel.Email;
         EncryptPassword(accountModel);
         accountModel.Roles = new List<string>() { "User" };
         adm.Add(accountModel);
         AddToConfirmList(accountModel);
         return accountModel;
     }
     return null;
 }
 public ActionResult Register(RegisterAccountModel accountModel)
 {
     AccountModel acc = LoginUtils.RegisterAccount(accountModel);
     if (acc != null)
     {
         String baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
         if (!baseUrl.Contains("localhost"))
         {
             String[] urlPart = baseUrl.Split(':');
             baseUrl = urlPart[0]+urlPart[1];
         }
         LoginUtils.SendConfirmationMail(acc, baseUrl);
         return RedirectToAction("Confirmation");
     }
     return RedirectToAction("Register");
 }