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