嗨,伙计们,我如何registernewacct.cshtml
从我的homecontroller.cs
. 和回来和堡垒....
我的代码在homecontroller.cs
[AcceptVerbs(HttpVerbs.Get)]
private bool IsValidRegisterNewAcct(string acctname, string dispname, string email, string password)
{
var crypto = new SimpleCrypto.PBKDF2();
bool IsValid = false;
IsValidErrorMessage = "";
IsValidErrorMessageInt = 0;
string NewAcctNameHash = MD5(acctname);
string NewEmailHash = MD5(email);
try
{
using (var db = new MainDbContext())
{
var NewAcctName = db.user.FirstOrDefault(u => u.AcctNameSalt == NewAcctNameHash);
if (NewAcctName != null)
{
IsValid = false;
IsValidErrorMessage = "Account Name already Exist!";
}
else
{
var NewEmail = db.user.FirstOrDefault(u => u.EmailSalt == NewEmailHash);
if (NewEmail != null)
{
IsValid = false;
IsValidErrorMessage = "Email Address already Exist!";
}
else
{
//THIS AREA <-- I wan to call my jquery function in my registernewacct.cshtml which is the dialog confirmation will ask if save or not. now if the answer is yes then it will return value yes. if not then it will return not.
var InsertNewAcctName = db.user.CreateObject();
InsertNewAcctName.UserId = Convert.ToString(Guid.NewGuid());
InsertNewAcctName.AcctName = acctname;
InsertNewAcctName.AcctNameSalt = NewAcctNameHash;
InsertNewAcctName.DisplayName = dispname;
InsertNewAcctName.Email = email;
InsertNewAcctName.EmailSalt = MD5(email);
InsertNewAcctName.Password = crypto.Compute(password);
InsertNewAcctName.PasswordSalt = crypto.Salt;
InsertNewAcctName.UserLevel = 2;
db.osoa_user.AddObject(InsertNewAcctName);
db.SaveChanges();
IsValid = true;
}
}
}
}
这是我的代码registernewacct.cshtml
@section Scripts{
<script>
$(document).ready(function(){
//THIS IS FOR THE CANCEL ACCOUNT DIALOG
function OpenDialogConfirmation(){
$( "#SaveDialogPage" ).dialog( "open" );
}
$("#yessavedialog").click(function(e) {
$( "#SaveDialogPage" ).dialog( "close" );
//then the code here that will pass my value back to homecontroller.cs....
});
$("#cancelsavedialog").click(function(e) {
$( "#SaveDialogPage" ).dialog( "close" );
//then the code here that will pass my value back to homecontroller.cs....
});
});
</script>
}
你能给我一些建议吗?多谢