public ActionResult Register(RegisterModel model)
 {
     try
     {
         string errorMessage = null;
         if (!model.IsValid(out errorMessage))
         {
             return(GetJsonResult(false, errorMessage));
         }
         User            user    = model.CreateUser(BcRole.RestApiUser);
         BcEntityContext context = BcEntityContext.Create();
         errorMessage = null;
         if (!context.RegisterUser(user, out errorMessage))
         {
             return(GetJsonResult(false, errorMessage));
         }
         FormsAuthentication.SetAuthCookie(user.UserName, true);
         return(GetJsonResult(true));
     }
     catch (Exception ex)
     {
         ExceptionHandler.HandleException(ex);
         return(RedirectToError(ex.Message));
     }
 }