Question

I have a model as below :

public class BaseModel 
{
    public DateTime? CrDate { get; set; }

    [ForeignKey("CrUser")]
    public ApplicationUser UserCr { get; set; }
    public string CrUser { get; set; }

    public DateTime? MdDate { get; set; }

    [ForeignKey("MdUser")]
    public ApplicationUser UserMd { get; set; }
    public string MdUser { get; set; }


    public bool IsDeleted { get; set; }



    public void LogWhatever()
    {
        this.CrDate = System.DateTime.Now;
        this.CrUser = ?????
    }

}

How can i get the logged userID from model to store in CrUser ?

regards.

Was it helpful?

Solution

Asp.net Identity expose IUser(IdentityUser) Context, once user logged in.

Context.User.Identity.GetUserId()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top