public IActionResult EmployeeDetails(int id) { var employee = _employeesService.GetById(id); if (employee == null) { return(NotFound()); //return 404 Not Found } return(View(employee)); }
public IActionResult EmployeeDetails(int id) { var employeeViewModel = _employeesService.GetById(id); //Если такого не существует if (employeeViewModel == null) { return(NotFound()); // возвращаем результат 404 Not Found } return(View(employeeViewModel)); }
public ActionResult <Employee> Get(int id) { var employee = service.GetById(id); if (employee != null) { return(employee); } return(NotFound()); }
public IActionResult EmployeeDetails(int id) { var employeeVM = _employeesService.GetById(id); if (employeeVM == null) { return(RedirectToAction("NotFound404", "Home")); } return(View(employeeVM)); }
[Route("{id}")] // id взят в {}, чтобы он прибиндился к id в параметре метода Details // ~/users/1111 public IActionResult Details(int id) { // Нам нужен тот сотрудник,id которого совпадает с тем id, который мы передали var employee = _employeesService.GetById(id); //Если такого не существует if (employee == null) { return(NotFound()); //возвращаем результат 404 Not Found } return(View(employee)); }
public IActionResult EmployeeDetails(int id) { //Получаем сотрудника по Id var employee = _employeesService.GetById(id); //Если такого не существует if (employee == null) { return(NotFound()); // возвращаем результат 404 Not Found } //Иначе возвращаем сотрудника return(View(employee)); }
private Domain.Employee GetEmployeeByIdOrEmailPrefix(string id) { if (int.TryParse(id, out int employeeId)) { return(_employeeService.GetById(employeeId)); } return(_employeeService.GetByEmailPrefix(id)); }
public async Task <IHttpActionResult> GetEmployee(int id) { return(await TryCatchAsync(async() => { var employee = await _employeesService.GetById(id); return Ok(employee); })); }
public ActionResult <Employee> GetById(int id) { try { return(db.GetById(id)); } catch (Exception) { throw; } }
public async Task <IActionResult> Get(int id) { var employee = await _employeesService.GetById(id); if (employee == null) { return(NotFound()); } return(Ok(employee)); }
// GET: Employees/Details/5 public ActionResult Details(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } EmployeeViewModel employee = _employeesService.GetById(id.Value); if (employee == null) { return(HttpNotFound()); } if (employee.IsInArchive == true) { return(RedirectToAction("DetailsArchive", "Employees", new { id = employee.EmployeeId })); } return(View(employee)); }
public IActionResult Get(Guid Id) { var e = empService.GetById(Id); if (e == null) { return(NotFound()); } var employee = new EmployeeDto() { FirstName = e.FirstName, LastName = e.LastName, Email = e.Email, Telephone = e.Telephone, Street = e.Address?.Street, Number = e.Address?.Number, City = e.Address?.City, Zip = e.Address?.Zip }; return(Ok(employee)); }
public Employee GetById(int id) => _employeesService.GetById(id);
public Employee GetById(int id) { return(_employeesService.GetById(id)); }
public IActionResult Details(int id) { return(View(_employeesService.GetById(id))); }
[Authorize(Roles = "Admins, Users")] //для просмотра деталей о работнике нужна роль админа или юзера public IActionResult Details(int id) { return(View(_employees.GetById(id).ToView())); }
public IActionResult EmployeeDetails(int id) { var employeeModel = _mapper.Map <EmployeeViewModel>(_employeesService.GetById(id)); return(View(employeeModel)); }