Skip to content

Commit

Permalink
project done, not tested
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamFXX committed Feb 14, 2025
1 parent 5a852d7 commit 3dc6537
Show file tree
Hide file tree
Showing 8 changed files with 172 additions and 165 deletions.
10 changes: 6 additions & 4 deletions Flashcards.Dreamfxx/Flashcards.Dreamfxx/Data/DatabaseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public List<Stack> GetStacks()
Console.ReadKey();
return null;
}
return stacks;
return new();
}

public List<Flashcard> GetCards()
Expand All @@ -77,7 +77,7 @@ public List<Flashcard> GetCards()
if (cards.Count == 0)
{
AnsiConsole.MarkupLine("No cards found");
return null;
return new();
}
return cards;
}
Expand Down Expand Up @@ -199,14 +199,14 @@ public StackDto GetStackDtos(int stackId)
var stackDetails = new StackDto
{
StackName = null,
FlashcardsDto = new List<Flashcard>() // Change the type to FlashcardDto
FlashcardsDto = new() // Change the type to FlashcardDto
};

var query = $@"
SELECT
Stacks.Name,
Cards.Id,
Cards.Question,
Cards.Question,
Cards.Answer
FROM Stacks
JOIN Cards ON Stacks.Id = Cards.StackId
Expand Down Expand Up @@ -448,6 +448,8 @@ FOREIGN KEY (StackId) REFERENCES Stacks(Id) ON DELETE CASCADE
)
END
";

ExecuteNonQuery(query);
SeedData();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
public class SessionPivotDto
{
public int Id { get; set; }
public required string StackName { get; set; }
public string? StackName { get; set; }
public int? January { get; set; }
public int? February { get; set; }
public int? March { get; set; }
Expand Down
5 changes: 2 additions & 3 deletions Flashcards.Dreamfxx/Flashcards.Dreamfxx/Dtos/StackDto.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using Flashcards.Dreamfxx.Models;
namespace Flashcards.Dreamfxx.Dtos;
namespace Flashcards.Dreamfxx.Dtos;

public class StackDto
{
public string? StackName { get; set; }
public List<Flashcard>? FlashcardsDto { get; set; }
public List<FlashcardDto>? FlashcardsDto { get; set; }
}
4 changes: 2 additions & 2 deletions Flashcards.Dreamfxx/Flashcards.Dreamfxx/Models/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class Session

[ForeignKey("Stack")]
public int StackId { get; set; }
public List<Flashcard> Cards { get; set; }
public List<Flashcard>? Flashcards { get; set; }
public DateTime EndTime { get; set; }
public int CorrectAnswers { get; set; }
public int WrongAnswers { get; set; }
public Stack Stack { get; set; }
public Stack? Stack { get; set; }
}
Loading

0 comments on commit 3dc6537

Please sign in to comment.