Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
6 changes: 0 additions & 6 deletions .idea/.idea.ConsoleApp2/.idea/projectSettingsUpdater.xml

This file was deleted.

127 changes: 0 additions & 127 deletions .idea/.idea.ConsoleApp2/.idea/workspace.xml

This file was deleted.

16 changes: 16 additions & 0 deletions ConsoleApp2.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{87E797D6-27CD-427F-89E0-21FBC4702711}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{87E797D6-27CD-427F-89E0-21FBC4702711}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{87E797D6-27CD-427F-89E0-21FBC4702711}.Debug|Any CPU.Build.0 = Debug|Any CPU
{87E797D6-27CD-427F-89E0-21FBC4702711}.Release|Any CPU.ActiveCfg = Release|Any CPU
{87E797D6-27CD-427F-89E0-21FBC4702711}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions ConsoleApp2/ConsoleApp2.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ConsoleMenu-simple" Version="2.4.3" />
</ItemGroup>

</Project>
11 changes: 11 additions & 0 deletions ConsoleApp2/ICollectionItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace ConsoleApp2;

public interface ICollectionItem
{
int _id
{
get;
set;
}
void validateWholeClass();
}
136 changes: 136 additions & 0 deletions ConsoleApp2/Menu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
namespace ConsoleApp2;

using System.Collections.Generic;
using System;
using System.Linq;
using System.Threading;
using ConsoleTools;

public class Menu
{
private REGISTRATION_CERTIFICATE_COLLECTION<REGISTRATION_CERTIFICATE> _collection;
public Menu()
{
_collection = new REGISTRATION_CERTIFICATE_COLLECTION<REGISTRATION_CERTIFICATE>();

_collection.deserealizeFromFile();
var dictionary = new Dictionary<int, Delegate>()
{
{ 1, Add},
{ 2, Remove},
{ 3, Find},
{ 4, Sort},
{ 5, Edit},
};

const string text = "1 - add\n" +
"2 - remove\n" +
"3 - search\n" +
"4 - sort\n" +
"5 - edit\n" +
"0 - exit";

foreach (var operation in InterfaceGetOperation(text, 0)) {
try
{
dictionary[operation].DynamicInvoke();
}
catch (Exception e)
{
Console.WriteLine("Incorect index\n" +
"try again");
}

}

}

static public IEnumerable<int> InterfaceGetOperation(string text, int exitKey) {
while (true)
{
Console.WriteLine(text);
int operation = Convert.ToInt32(Console.ReadLine());

if (operation == exitKey)
{
break;
}
yield return operation;
}
}

private void Sort()
{
Console.WriteLine("Please enter field by which you want sort: ");
var value = Console.ReadLine();

try
{
_collection.sort(value);
Console.Write(_collection);
}
catch (Exception e)
{
Console.WriteLine("There isn't such fields");
}
}

private void Find()
{
Console.WriteLine("Please enter value for search: ");
var value = Console.ReadLine();
var seachedByValue = _collection.searchByValue(value);
seachedByValue.ForEach(item => Console.WriteLine(item));
if(seachedByValue.Count==0)
Console.WriteLine("There is no such elements");
}

private void Add()
{
var certificate = REGISTRATION_CERTIFICATE.readFromConsole();
try
{
_collection.Add(certificate);
Console.Write(_collection);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}


}

private void Remove()
{
Console.WriteLine("Please enter id:");
try
{
var index = Convert.ToInt32(Console.ReadLine());
_collection.Remove(index);
Console.Write(_collection);
}
catch (Exception e)
{
Console.WriteLine("Invalid index \n" +
"Try again");
}

}

private void Edit()
{
Console.WriteLine("Please enter id of certificate which you want to edit:");
try
{
var index = Convert.ToInt32(Console.ReadLine());
_collection.Edit(index);
Console.Write(_collection);
}
catch (Exception e)
{
Console.WriteLine("Invalid values");
}

}
}
13 changes: 13 additions & 0 deletions ConsoleApp2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

namespace ConsoleApp2
{
public class Registration
{

// This is the main entry point for the application.
public static void Main(string[] args)
{
var menu = new Menu();
}
}
}
Loading