Skip to content

Commit 123ee0d

Browse files
committed
Some code cleanup
1 parent a4aab7e commit 123ee0d

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

SimpleWebAppMVC/Controllers/TasksController.cs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,18 @@ public async Task<IActionResult> GetJSON(string sort)
180180
{
181181
IQueryable<Models.Task> tasks = from task in this.dbContext.Tasks select task;
182182

183-
switch (sort) {
184-
case "Title": tasks = tasks.OrderBy(s => s.Title); break;
185-
case "Title_desc": tasks = tasks.OrderByDescending(s => s.Title); break;
186-
case "Description": tasks = tasks.OrderBy(s => s.Description); break;
187-
case "Description_desc": tasks = tasks.OrderByDescending(s => s.Description); break;
188-
case "Date": tasks = tasks.OrderBy(s => s.Date); break;
189-
case "Date_desc": tasks = tasks.OrderByDescending(s => s.Date); break;
190-
case "Status": tasks = tasks.OrderBy(s => s.Status); break;
191-
case "Status_desc": tasks = tasks.OrderByDescending(s => s.Status); break;
192-
default: tasks = tasks.OrderBy(s => s.Title); break;
193-
}
183+
tasks = sort switch
184+
{
185+
"Title" => tasks.OrderBy(s => s.Title),
186+
"Title_desc" => tasks.OrderByDescending(s => s.Title),
187+
"Description" => tasks.OrderBy(s => s.Description),
188+
"Description_desc" => tasks.OrderByDescending(s => s.Description),
189+
"Date" => tasks.OrderBy(s => s.Date),
190+
"Date_desc" => tasks.OrderByDescending(s => s.Date),
191+
"Status" => tasks.OrderBy(s => s.Status),
192+
"Status_desc" => tasks.OrderByDescending(s => s.Status),
193+
_ => tasks.OrderBy(s => s.Title),
194+
};
194195

195196
return tasks;
196197
}

0 commit comments

Comments
 (0)