Skip to content

Commit

Permalink
changed up prepopulate list feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Programming-With-Chris committed Aug 24, 2022
1 parent cabbbc3 commit a26a321
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions ShoppingList/Services/UserListService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,9 @@ public UserList GetLastUserListOfType(UserList newList)
Guard.IsNotNull(newList, nameof(newList));

var allUserLists = _db.GetAllQuery<UserList>();
UserList lastListOfThatType = new();
lastListOfThatType.Id = 0;

foreach(var ul in allUserLists)
{
if (ul.Type == newList.Type && ul.Id > lastListOfThatType.Id && ul.Id != newList.Id)
{
lastListOfThatType = ul;
}
}

var listsOfType = allUserLists.FindAll(x => (x.Type == newList.Type) && x.Id != newList.Id).ToList();
var lastListOfThatType = listsOfType.OrderByDescending(x => x.CreationDate).ToList()[0];

return lastListOfThatType;

Expand Down

0 comments on commit a26a321

Please sign in to comment.