fix
This commit is contained in:
parent
14fbb042b5
commit
3683d8d96e
@ -44,8 +44,15 @@ namespace WorkTime
|
|||||||
}
|
}
|
||||||
public void AddWorker(Worker worker)
|
public void AddWorker(Worker worker)
|
||||||
{
|
{
|
||||||
_context.Workers.Add(worker);
|
try
|
||||||
_context.SaveChanges();
|
{
|
||||||
|
_context.Workers.Add(worker);
|
||||||
|
_context.SaveChanges();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.WriteLine(e.InnerException.Message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -23,6 +23,8 @@ namespace WorkTime
|
|||||||
operation = Console.ReadLine() ?? "";
|
operation = Console.ReadLine() ?? "";
|
||||||
switch (operation)
|
switch (operation)
|
||||||
{
|
{
|
||||||
|
case "0":
|
||||||
|
break;
|
||||||
case "1":
|
case "1":
|
||||||
controller.GetWorkers();
|
controller.GetWorkers();
|
||||||
break;
|
break;
|
||||||
@ -39,6 +41,7 @@ namespace WorkTime
|
|||||||
controller.GetPosts();
|
controller.GetPosts();
|
||||||
break;
|
break;
|
||||||
case "6":
|
case "6":
|
||||||
|
Console.WriteLine("Введите Имя и id должности(1,2)");
|
||||||
Worker worker = new()
|
Worker worker = new()
|
||||||
{
|
{
|
||||||
Name = Console.ReadLine(),
|
Name = Console.ReadLine(),
|
||||||
@ -47,7 +50,7 @@ namespace WorkTime
|
|||||||
controller.AddWorker(worker);
|
controller.AddWorker(worker);
|
||||||
break;
|
break;
|
||||||
case "7":
|
case "7":
|
||||||
|
Test(controller, context);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Console.WriteLine("Некорректно введенный номер операции");
|
Console.WriteLine("Некорректно введенный номер операции");
|
||||||
@ -60,11 +63,11 @@ namespace WorkTime
|
|||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
string name = "";
|
string name = "";
|
||||||
for (int i = 0; i < 7; i++)
|
for (int i = 0; i < 7; i++)
|
||||||
name += (char)r.Next(3, 255);
|
name += (char)r.Next(65, 89);
|
||||||
Worker worker = new()
|
Worker worker = new()
|
||||||
{
|
{
|
||||||
Name = name[..7],
|
Name = name[..7],
|
||||||
PostId = r.Next(1,context.Posts.Last().Id),
|
PostId = r.Next(1,2),
|
||||||
};
|
};
|
||||||
|
|
||||||
var result = new[]
|
var result = new[]
|
||||||
|
Loading…
Reference in New Issue
Block a user