For my application, I have created a stored procedure(taken from here):
Create proc spResetPassword
@UserName nvarchar(100)
as
Begin
Declare @UserId int
Declare @Email nvarchar(100)
Select @UserId = Id, @Email = Email
from tblUsers
where UserName = @UserName
if(@UserId IS NOT NULL)
Begin
--If username exists
Declare @GUID UniqueIdentifier
Set @GUID = NEWID()
Insert into tblResetPasswordRequests
(Id, UserId, ResetRequestDateTime)
Values(@GUID, @UserId, GETDATE())
Select 1 as ReturnCode, @GUID as UniqueId, @Email as Email
End
I have created a model and added the required properties:
[Table("tblResetPasswordRequests")]
public class RequestResetPasswordModel
{
[Key]
public Guid Id { get; set; }
[ForeignKey("ADMIN_ID")]
public AdminLogin UserId{ get; set; }
public DateTime ResetRequestDateTime { get; set; }
}
In the controller, I have called the stored procedure inside a method:
var uniqueIdForUser = db.Database.SqlQuery<RequestResetPasswordModel>("spResetPassword {0}", user.ADMIN_USERNAME).FirstOrDefault();
The record is getting inserted into the db table, but when I debug the method,the Id is not being passed, it only shows 00000000-0000-0000-0000-000000000000 every time.What should I do?please help