cs1 improvements
This commit is contained in:
@@ -51,7 +51,15 @@ namespace PoloClubApp
|
||||
/// <returns>List of wearable devices.</returns>
|
||||
public List<Device> GetAllWearables()
|
||||
{
|
||||
return devices.Where(d => d is IWearable).ToList();
|
||||
List<Device> wearables = new List<Device>();
|
||||
foreach (Device device in devices)
|
||||
{
|
||||
if (device is IWearable)
|
||||
{
|
||||
wearables.Add(device);
|
||||
}
|
||||
}
|
||||
return wearables;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -62,8 +70,8 @@ namespace PoloClubApp
|
||||
/// <exception cref="Exception">Thrown if device is not found.</exception>
|
||||
public void AssignDevice(int id, string playerName)
|
||||
{
|
||||
var device = GetDeviceById(id) ?? throw new Exception("Device not found");
|
||||
var waterResistance = (device as IWearable)?.GetWaterResistanceMeters();
|
||||
Device device = GetDeviceById(id) ?? throw new Exception("Device not found");
|
||||
int? waterResistance = (device as IWearable)?.GetWaterResistanceMeters();
|
||||
device.AssignDevice(playerName, waterResistance);
|
||||
}
|
||||
|
||||
@@ -74,7 +82,7 @@ namespace PoloClubApp
|
||||
/// <returns>True if successful, false if device not found.</returns>
|
||||
public bool ReturnDevice(int id)
|
||||
{
|
||||
var device = GetDeviceById(id);
|
||||
Device device = GetDeviceById(id);
|
||||
return device?.ReturnDevice() ?? false;
|
||||
}
|
||||
|
||||
@@ -95,8 +103,8 @@ namespace PoloClubApp
|
||||
/// <returns>Formatted report lines.</returns>
|
||||
public List<string> GenerateReportPerPlayer(string playerName)
|
||||
{
|
||||
var assignedDevices = GetAllAssignedDevicesByPlayer(playerName);
|
||||
var report = new List<string>
|
||||
List<Device> assignedDevices = GetAllAssignedDevicesByPlayer(playerName);
|
||||
List<string> report = new List<string>
|
||||
{
|
||||
$"List of devices assigned to {playerName}",
|
||||
"Phones",
|
||||
|
||||
Reference in New Issue
Block a user