I wrote a code to recover passwrod in my website.The user enter his email address and we send a new password to him.In additcion,we also change his password in DB to newest password.
Problem: If code for send mail fails,i cant change his password in DB,and if code to change password fails i cant send mail.
Take a look:
public bool RecoverPassword(string email)
{
try
{
SceLoginMail sceEmail = new SceLoginMail(email, "Recuperação de senha", 5);
ChangeUserPassword(sceEmail.NovaSenha, email);
sceEmail.SendEmail();
sceUsers.CommitOrRollBack(true);
return true;
}
catch (Exception ex)
{
sceUsers.CommitOrRollBack(false);
return false;
}
}
I try to rollback in DB if an exceptions occurs in SendEmail method.But,i cant "RollBack" the SendMail method if an exceptions throws in CommitOrRollback method.If so,system will send the mail and wont change it on DB.
Any ideias?