public void MapSameReferenceToDifferentTypes()
        {
            var config = new TypeAdapterConfig();

            config.Default.PreserveReference(true);

            var employee = new Employee {
                Id = 1, Name = "Name"
            };

            var department = new Department
            {
                Manager    = employee,
                Supervisor = employee
            };

            var result = department.Adapt <DepartmentDto>(config);

            result.Manager.Id.ShouldBe(employee.Id);
            result.Manager.Name.ShouldBe(employee.Name);
            result.Supervisor.Id.ShouldBe(employee.Id);
            result.Supervisor.Name.ShouldBe(employee.Name);
        }
Esempio n. 2
0
        public async Task <ActionResult <DepartmentDto> > AddDepartment([FromBody] Department department)
        {
            await _repository.AddDepartmentAsync(department);

            await _repository.CommitAsync();

            return(CreatedAtAction(nameof(GetDepartment), new { departmentId = department.DepartmentId }, department.Adapt <DepartmentDto>()));
        }