public ActionResult <IEnumerable <EmployeeModel> > Get()
        {
            EmployeeService        empService = new EmployeeService(this._context);
            IEnumerable <Employee> result     = empService.GetAll();

            return(Ok(result.Select(a => EmployeeMapper.toModel(a))));
        }
        public ActionResult <IEnumerable <EmployeeModel> > Get(Guid departmentId)
        {
            EmployeeService        empService = new EmployeeService(this._context);
            IEnumerable <Employee> result     = empService.GetByDepartment(departmentId);

            return(Ok(result.Select(a => EmployeeMapper.toModel(a))));
        }
Example #3
0
        public void testEmployeeMapper()
        {
            Company compEntity = new Company {
                token = System.Guid.NewGuid(), CompanyName = "Company1"
            };
            Department deptEntity = new Department {
                token = System.Guid.NewGuid(), DepartmentName = "Department1", Address = "Dep1-Address1"
            };

            Employee empEntity = new Employee {
                token = System.Guid.NewGuid(), FirstName = "FName1", LastName = "LName1", JobTitle = "Comp1-Dep1-Title1", MailingAddress = "Comp1-Dep1-Address1", department = deptEntity, departmentToken = deptEntity.token, company = compEntity, companyToken = compEntity.token
            };
            EmployeeModel empModel   = EmployeeMapper.toModel(empEntity);                 // convert from Model to Entity
            Employee      empEntity2 = EmployeeMapper.toEntity(new Employee(), empModel); // convert it back from Entity to Model

            Microsoft.VisualStudio.TestTools.UnitTesting.Assert.AreEqual(empEntity.ByProperties(), empEntity2);
        }