2021-02-07 13:51:49 +03:00
|
|
|
|
using System;
|
2021-04-09 09:48:23 +03:00
|
|
|
|
using MapTo;
|
2021-02-07 13:51:49 +03:00
|
|
|
|
using TestConsoleApp.Data.Models;
|
|
|
|
|
using TestConsoleApp.ViewModels;
|
2021-02-17 11:32:23 +03:00
|
|
|
|
using TestConsoleApp.ViewModels2;
|
2020-12-21 13:20:29 +03:00
|
|
|
|
|
2021-01-27 10:53:29 +03:00
|
|
|
|
namespace TestConsoleApp
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
private static void Main(string[] args)
|
2021-02-13 14:27:32 +03:00
|
|
|
|
{
|
|
|
|
|
//UserTest();
|
2021-04-09 09:48:23 +03:00
|
|
|
|
CyclicReferenceTest();
|
|
|
|
|
|
|
|
|
|
// EmployeeManagerTest();
|
|
|
|
|
Console.WriteLine("done");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void EmployeeManagerTest()
|
|
|
|
|
{
|
2021-02-13 14:27:32 +03:00
|
|
|
|
var manager1 = new Manager
|
|
|
|
|
{
|
|
|
|
|
Id = 1,
|
|
|
|
|
EmployeeCode = "M001",
|
|
|
|
|
Level = 100
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var manager2 = new Manager
|
|
|
|
|
{
|
|
|
|
|
Id = 2,
|
|
|
|
|
EmployeeCode = "M002",
|
|
|
|
|
Level = 100,
|
|
|
|
|
Manager = manager1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var employee1 = new Employee
|
|
|
|
|
{
|
|
|
|
|
Id = 101,
|
|
|
|
|
EmployeeCode = "E101",
|
|
|
|
|
Manager = manager1
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var employee2 = new Employee
|
|
|
|
|
{
|
|
|
|
|
Id = 102,
|
|
|
|
|
EmployeeCode = "E102",
|
|
|
|
|
Manager = manager2
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
manager1.Employees = new[] { employee1, manager2 };
|
|
|
|
|
manager2.Employees = new[] { employee2 };
|
|
|
|
|
|
2021-02-17 11:32:23 +03:00
|
|
|
|
manager1.ToManagerViewModel();
|
|
|
|
|
employee1.ToEmployeeViewModel();
|
2021-02-13 14:27:32 +03:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-09 09:48:23 +03:00
|
|
|
|
private static ManagerViewModel CyclicReferenceTest()
|
|
|
|
|
{
|
|
|
|
|
var manager1 = new Manager
|
|
|
|
|
{
|
|
|
|
|
Id = 1,
|
|
|
|
|
EmployeeCode = "M001",
|
|
|
|
|
Level = 100
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
manager1.Manager = manager1;
|
|
|
|
|
return manager1.ToManagerViewModel();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-13 14:27:32 +03:00
|
|
|
|
private static void UserTest()
|
2021-01-27 10:53:29 +03:00
|
|
|
|
{
|
2021-02-07 13:51:49 +03:00
|
|
|
|
var user = new User
|
|
|
|
|
{
|
|
|
|
|
Id = 1234,
|
|
|
|
|
RegisteredAt = DateTimeOffset.Now,
|
|
|
|
|
Profile = new Profile
|
|
|
|
|
{
|
|
|
|
|
FirstName = "John",
|
|
|
|
|
LastName = "Doe"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var vm = user.ToUserViewModel();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Key: {0}", vm.Key);
|
|
|
|
|
Console.WriteLine("RegisteredAt: {0}", vm.RegisteredAt);
|
|
|
|
|
Console.WriteLine("FirstName: {0}", vm.Profile.FirstName);
|
|
|
|
|
Console.WriteLine("LastName: {0}", vm.Profile.LastName);
|
2021-01-27 10:53:29 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|