Moved to System.Text.Json - Removed all Library dependencies - Implemented DeleteCommand
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TBDel.Models;
|
||||
using TBDel.Services;
|
||||
|
||||
|
@@ -2,7 +2,7 @@ using TBDel.Services;
|
||||
|
||||
namespace TBDel.Commands;
|
||||
|
||||
public class DeleteCommand
|
||||
public class DeleteCAllCommand
|
||||
{
|
||||
public static async Task DeleteAll()
|
||||
{
|
||||
|
@@ -0,0 +1,35 @@
|
||||
using TBDel.Models;
|
||||
using TBDel.Services;
|
||||
|
||||
namespace TBDel.Commands;
|
||||
|
||||
|
||||
public class DeleteCommand
|
||||
{
|
||||
// Will be done by unique file Id
|
||||
public static async Task DeleteEntry(string[] args)
|
||||
{
|
||||
var dbService = new DbService();
|
||||
if (args.Length > 1)
|
||||
{
|
||||
if (File.Exists(args[1]))
|
||||
{
|
||||
Console.WriteLine($"Deleteing file: {args[1]}");
|
||||
if (await dbService.RemoveFileEntryAsync(args[1]))
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
Console.WriteLine("File deleted successfully");
|
||||
Console.ResetColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.ForegroundColor = ConsoleColor.Red;
|
||||
Console.WriteLine("something went wrong");
|
||||
Console.ResetColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user