mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 16:28:50 -07:00
implement the rest of the report system methods
This commit is contained in:
parent
b0c9f47375
commit
f58e4d643c
@ -70,6 +70,26 @@ public class ModerationService
|
|||||||
|
|
||||||
// Reporting
|
// Reporting
|
||||||
|
|
||||||
|
public List<Report> GetAllReportsReceivedFromViking(Viking viking, int typeFilter = 0)
|
||||||
|
{
|
||||||
|
// get all reports the viking has received by 'CreatedAt' descending
|
||||||
|
List<Report> reports = new List<Report>();
|
||||||
|
if (typeFilter != 0) reports = viking.ReportsReceived.Where(e => e.ReportType == typeFilter).OrderByDescending(e => e.CreatedAt).ToList();
|
||||||
|
else reports = viking.ReportsReceived.OrderByDescending(e => e.CreatedAt).ToList();
|
||||||
|
|
||||||
|
return reports;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Report> GetAllReportsMadeFromViking(Viking viking, int typeFilter = 0)
|
||||||
|
{
|
||||||
|
// get all reports the viking has made by 'CreatedAt' descending
|
||||||
|
List<Report> reports = new List<Report>();
|
||||||
|
if (typeFilter != 0) reports = viking.ReportsMade.Where(e => e.ReportType == typeFilter).OrderByDescending(e => e.CreatedAt).ToList();
|
||||||
|
else reports = viking.ReportsMade.OrderByDescending(e => e.CreatedAt).ToList();
|
||||||
|
|
||||||
|
return reports;
|
||||||
|
}
|
||||||
|
|
||||||
public Report AddReportToViking(string apiToken, Viking viking, Viking vikingToReport, ReportType reportReason)
|
public Report AddReportToViking(string apiToken, Viking viking, Viking vikingToReport, ReportType reportReason)
|
||||||
{
|
{
|
||||||
// check if the report already exists with the viking creating the report
|
// check if the report already exists with the viking creating the report
|
||||||
@ -96,4 +116,15 @@ public class ModerationService
|
|||||||
|
|
||||||
return report;
|
return report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool RemoveReportFromViking(Viking viking, ReportType reportType)
|
||||||
|
{
|
||||||
|
// find the report of that type on that viking
|
||||||
|
Report? report = viking.ReportsReceived.FirstOrDefault(e => e.ReportType == (int)reportType);
|
||||||
|
if (report != null)
|
||||||
|
{
|
||||||
|
// remove it
|
||||||
|
return viking.ReportsReceived.Remove(report); // this should also remove it from the 'ReportsMade' list on the owner
|
||||||
|
} else return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user