MrWalshyType2 / Noting

Note app with study features written in C# with ASP.NET 5.
0 stars 0 forks source link

Update Notes Details view #13

Closed MrWalshyType2 closed 3 years ago

MrWalshyType2 commented 3 years ago

image

MrWalshyType2 commented 3 years ago

Changed LastAttempt property to reference a field for control of get and set methods

[NotMapped]
private SpacedRepetitionAttempt lastAttempt;

[NotMapped]
public SpacedRepetitionAttempt LastAttempt 
{ 
    get 
    {
        List<SpacedRepetitionAttempt> attempts = null;
        SpacedRepetitionAttempt lastAttempt = null;
        var attemptQuery = from a in SpacedRepetitionAttempts
                           orderby a.AttemptDate descending
                           select a;

        if (attemptQuery.Any())
        {
            attempts = attemptQuery.ToList();
            lastAttempt = attempts[0];
            return lastAttempt;
        }
        return null;
    }
    set
    {
        this.lastAttempt = value;
    }
}