예제 #1
0
        public async Task <IActionResult> GetAsync(int id)
        {
            if (id <= 0)
            {
                return(BadRequest("Wrong employee id"));
            }

            var employee = await _employeService.GetEmployeeByIdAsync(id);

            if (employee == null)
            {
                return(NotFound($"There is no employee with {id} id"));
            }

            return(Ok(employee));
        }
예제 #2
0
        public async Task <IActionResult> GetAllEmployees(int id)
        {
            var model = new List <EmployeesDTO>();

            if (id == 0)
            {
                model = await _service.GetAllEmployeesAsync();

                return(View(model));
            }
            else
            {
                var employee = await _service.GetEmployeeByIdAsync(id);

                model.Add(employee);
                return(View(model));
            }
        }
예제 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public async Task <IEnumerable <EmployeeDto> > GetAsync(int id)
 {
     return(await _employeesService.GetEmployeeByIdAsync(id));
 }
예제 #4
0
        public async Task GetByIdAsync()
        {
            var result = await _employeesService.GetEmployeeByIdAsync(1);

            Assert.IsTrue(result != null && result.Any() && result.FirstOrDefault().Id == 1);
        }