示例#1
0
        public async Task <IActionResult> DeleteAnEmployee([FromBody] FindEmployeeDTO model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Employee fetchedEmployee = await _employeeRepo.GetAnEmployee(model.EmployeeId);

            if (fetchedEmployee == null)
            {
                return(NotFound("Employee with requested id was not found"));
            }

            var deleteEmployee = await _employeeRepo.DeleteAnEmployee(fetchedEmployee);

            if (deleteEmployee)
            {
                return(Ok("Employee has been deleted successfully"));
            }

            return(BadRequest("There was an error deleting the employee record"));
        }