Skip to content

Commit 7b72705

Browse files
committed
Updated to 3P comments and TP comments
1 parent 4e4a694 commit 7b72705

File tree

75 files changed

+273
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+273
-284
lines changed

Chapter_05/Exercises/Controllers/BoardGamesController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public async Task<RestDTO<BoardGame[]>> Get(
3535
var query = _context.BoardGames.AsQueryable();
3636
if (!string.IsNullOrEmpty(filterQuery))
3737
query = query.Where(b => b.Name.StartsWith(filterQuery));
38+
var recordCount = await query.CountAsync();
3839
query = query
3940
.OrderBy($"{sortColumn} {sortOrder}")
4041
.Skip(pageIndex * pageSize)
@@ -45,7 +46,7 @@ public async Task<RestDTO<BoardGame[]>> Get(
4546
Data = await query.ToArrayAsync(),
4647
PageIndex = pageIndex,
4748
PageSize = pageSize,
48-
RecordCount = await _context.BoardGames.CountAsync(),
49+
RecordCount = recordCount,
4950
Links = new List<LinkDTO> {
5051
new LinkDTO(
5152
Url.Action(

Chapter_05/Exercises/Controllers/SeedController.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,12 @@ public async Task<IActionResult> Put(int? id = null)
125125
_context.Mechanics.Add(mechanic);
126126
existingMechanics.Add(mechanicName, mechanic);
127127
}
128-
try
128+
_context.BoardGames_Mechanics.Add(new BoardGames_Mechanics()
129129
{
130-
_context.BoardGames_Mechanics.Add(new BoardGames_Mechanics()
131-
{
132-
BoardGame = boardgame,
133-
Mechanic = mechanic,
134-
CreatedDate = now
135-
});
136-
}
137-
catch (Exception e)
138-
{
139-
int i = 1;
140-
}
130+
BoardGame = boardgame,
131+
Mechanic = mechanic,
132+
CreatedDate = now
133+
});
141134
}
142135
}
143136

Chapter_05/MyBGList/Controllers/BoardGamesController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public async Task<RestDTO<BoardGame[]>> Get(
132132
var query = _context.BoardGames.AsQueryable();
133133
if (!string.IsNullOrEmpty(filterQuery))
134134
query = query.Where(b => b.Name.Contains(filterQuery));
135+
var recordCount = await query.CountAsync();
135136
query = query
136137
.OrderBy($"{sortColumn} {sortOrder}")
137138
.Skip(pageIndex * pageSize)
@@ -142,7 +143,7 @@ public async Task<RestDTO<BoardGame[]>> Get(
142143
Data = await query.ToArrayAsync(),
143144
PageIndex = pageIndex,
144145
PageSize = pageSize,
145-
RecordCount = await _context.BoardGames.CountAsync(),
146+
RecordCount = recordCount,
146147
Links = new List<LinkDTO> {
147148
new LinkDTO(
148149
Url.Action(

Chapter_05/MyBGList/Controllers/SeedController.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,12 @@ public async Task<IActionResult> Put()
124124
_context.Mechanics.Add(mechanic);
125125
existingMechanics.Add(mechanicName, mechanic);
126126
}
127-
try
127+
_context.BoardGames_Mechanics.Add(new BoardGames_Mechanics()
128128
{
129-
_context.BoardGames_Mechanics.Add(new BoardGames_Mechanics()
130-
{
131-
BoardGame = boardgame,
132-
Mechanic = mechanic,
133-
CreatedDate = now
134-
});
135-
}
136-
catch (Exception e)
137-
{
138-
int i = 1;
139-
}
129+
BoardGame = boardgame,
130+
Mechanic = mechanic,
131+
CreatedDate = now
132+
});
140133
}
141134
}
142135

Chapter_06/Exercises/Controllers/DomainsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public async Task<ActionResult<RestDTO<Domain[]>>> Get(
5656
var query = _context.Domains.AsQueryable();
5757
if (!string.IsNullOrEmpty(input.FilterQuery))
5858
query = query.Where(b => b.Name.Contains(input.FilterQuery));
59+
var recordCount = await query.CountAsync();
5960
query = query
6061
.OrderBy($"{input.SortColumn} {input.SortOrder}")
6162
.Skip(input.PageIndex * input.PageSize)
@@ -66,7 +67,7 @@ public async Task<ActionResult<RestDTO<Domain[]>>> Get(
6667
Data = await query.ToArrayAsync(),
6768
PageIndex = input.PageIndex,
6869
PageSize = input.PageSize,
69-
RecordCount = await _context.Domains.CountAsync(),
70+
RecordCount = recordCount,
7071
Links = new List<LinkDTO> {
7172
new LinkDTO(
7273
Url.Action(

Chapter_06/MyBGList/Attributes/SortColumnValidatorAttribute.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.ComponentModel.DataAnnotations;
2-
using System.Reflection;
32

43
namespace MyBGList.Attributes
54
{

Chapter_06/MyBGList/Controllers/BoardGamesController.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public BoardGamesController(
3939
// var query = _context.BoardGames.AsQueryable();
4040
// if (!string.IsNullOrEmpty(filterQuery))
4141
// query = query.Where(b => b.Name.Contains(filterQuery));
42+
// var recordCount = await query.CountAsync();
4243
// query = query
4344
// .OrderBy($"{sortColumn} {sortOrder}")
4445
// .Skip(pageIndex * pageSize)
@@ -49,7 +50,7 @@ public BoardGamesController(
4950
// Data = await query.ToArrayAsync(),
5051
// PageIndex = pageIndex,
5152
// PageSize = pageSize,
52-
// RecordCount = await _context.BoardGames.CountAsync(),
53+
// RecordCount = recordCount,
5354
// Links = new List<LinkDTO> {
5455
// new LinkDTO(
5556
// Url.Action(
@@ -71,6 +72,7 @@ public async Task<RestDTO<BoardGame[]>> Get(
7172
var query = _context.BoardGames.AsQueryable();
7273
if (!string.IsNullOrEmpty(input.FilterQuery))
7374
query = query.Where(b => b.Name.Contains(input.FilterQuery));
75+
var recordCount = await query.CountAsync();
7476
query = query
7577
.OrderBy($"{input.SortColumn} {input.SortOrder}")
7678
.Skip(input.PageIndex * input.PageSize)
@@ -81,7 +83,7 @@ public async Task<RestDTO<BoardGame[]>> Get(
8183
Data = await query.ToArrayAsync(),
8284
PageIndex = input.PageIndex,
8385
PageSize = input.PageSize,
84-
RecordCount = await _context.BoardGames.CountAsync(),
86+
RecordCount = recordCount,
8587
Links = new List<LinkDTO> {
8688
new LinkDTO(
8789
Url.Action(

Chapter_06/MyBGList/Controllers/DomainsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public async Task<ActionResult<RestDTO<Domain[]>>> Get(
5858
var query = _context.Domains.AsQueryable();
5959
if (!string.IsNullOrEmpty(input.FilterQuery))
6060
query = query.Where(b => b.Name.Contains(input.FilterQuery));
61+
var recordCount = await query.CountAsync();
6162
query = query
6263
.OrderBy($"{input.SortColumn} {input.SortOrder}")
6364
.Skip(input.PageIndex * input.PageSize)
@@ -68,7 +69,7 @@ public async Task<ActionResult<RestDTO<Domain[]>>> Get(
6869
Data = await query.ToArrayAsync(),
6970
PageIndex = input.PageIndex,
7071
PageSize = input.PageSize,
71-
RecordCount = await _context.Domains.CountAsync(),
72+
RecordCount = recordCount,
7273
Links = new List<LinkDTO> {
7374
new LinkDTO(
7475
Url.Action(

Chapter_06/MyBGList/Controllers/MechanicsController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public async Task<RestDTO<Mechanic[]>> Get(
3333
var query = _context.Mechanics.AsQueryable();
3434
if (!string.IsNullOrEmpty(input.FilterQuery))
3535
query = query.Where(b => b.Name.Contains(input.FilterQuery));
36+
var recordCount = await query.CountAsync();
3637
query = query
3738
.OrderBy($"{input.SortColumn} {input.SortOrder}")
3839
.Skip(input.PageIndex * input.PageSize)
@@ -43,7 +44,7 @@ public async Task<RestDTO<Mechanic[]>> Get(
4344
Data = await query.ToArrayAsync(),
4445
PageIndex = input.PageIndex,
4546
PageSize = input.PageSize,
46-
RecordCount = await _context.Mechanics.CountAsync(),
47+
RecordCount = recordCount,
4748
Links = new List<LinkDTO> {
4849
new LinkDTO(
4950
Url.Action(

Chapter_06/MyBGList/Controllers/SeedController.cs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -124,19 +124,12 @@ public async Task<IActionResult> Put()
124124
_context.Mechanics.Add(mechanic);
125125
existingMechanics.Add(mechanicName, mechanic);
126126
}
127-
try
127+
_context.BoardGames_Mechanics.Add(new BoardGames_Mechanics()
128128
{
129-
_context.BoardGames_Mechanics.Add(new BoardGames_Mechanics()
130-
{
131-
BoardGame = boardgame,
132-
Mechanic = mechanic,
133-
CreatedDate = now
134-
});
135-
}
136-
catch (Exception e)
137-
{
138-
int i = 1;
139-
}
129+
BoardGame = boardgame,
130+
Mechanic = mechanic,
131+
CreatedDate = now
132+
});
140133
}
141134
}
142135

0 commit comments

Comments
 (0)