mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add boolean return value
This commit is contained in:
@ -281,7 +281,8 @@ namespace osu.Game.Database
|
|||||||
/// Is a no-op for already deleted items.
|
/// Is a no-op for already deleted items.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="item">The item to delete.</param>
|
/// <param name="item">The item to delete.</param>
|
||||||
public void Delete(TModel item)
|
/// <returns>false if no operation was performed</returns>
|
||||||
|
public bool Delete(TModel item)
|
||||||
{
|
{
|
||||||
using (ContextFactory.GetForWrite())
|
using (ContextFactory.GetForWrite())
|
||||||
{
|
{
|
||||||
@ -289,10 +290,11 @@ namespace osu.Game.Database
|
|||||||
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).FirstOrDefault(s => s.ID == item.ID);
|
var foundModel = queryModel().Include(s => s.Files).ThenInclude(f => f.FileInfo).FirstOrDefault(s => s.ID == item.ID);
|
||||||
|
|
||||||
// Test for null since FirstOrDefault will return null if nothing is found
|
// Test for null since FirstOrDefault will return null if nothing is found
|
||||||
if (foundModel == null || foundModel.DeletePending) return;
|
if (foundModel == null || foundModel.DeletePending) return false;
|
||||||
|
|
||||||
if (ModelStore.Delete(foundModel))
|
if (ModelStore.Delete(foundModel))
|
||||||
Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray());
|
Files.Dereference(foundModel.Files.Select(f => f.FileInfo).ToArray());
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user