More work on #27 Added a new notify button to the search UI (Needs styling). Also fixed a bug where if the user could only see their own requests, if they search for something that has been requested, it will show as requested.

This commit is contained in:
tidusjar 2016-04-25 13:45:22 +01:00
parent 186b18ccb9
commit 7051c31dd3
4 changed files with 83 additions and 40 deletions

View file

@ -40,6 +40,7 @@ namespace PlexRequests.Store
public List<string> RequestedUsers { get; set; }
public string ArtistName { get; set; }
public string ArtistId { get; set; }
public List<string> UsersToNotify { get; private set; }
[JsonIgnore]
public List<string> AllUsers
@ -61,18 +62,27 @@ namespace PlexRequests.Store
}
[JsonIgnore]
public bool CanApprove
{
get
{
return !Approved && !Available;
}
}
public bool CanApprove => !Approved && !Available;
public bool UserHasRequested(string username)
{
return AllUsers.Any(x => x.Equals(username, StringComparison.OrdinalIgnoreCase));
}
public void AddUserToNotification(string username)
{
if (UsersToNotify == null)
{
UsersToNotify = new List<string>();
}
if (UsersToNotify.FirstOrDefault(x => x == username) != null)
{
// User already exists in the notification list
return;
}
UsersToNotify.Add(username);
}
}
public enum RequestType