示例#1
0
        public IActionResult Delete(int id)
        {
            if (id <= 0)
            {
                return(BadRequest());
            }

            Employee employee = _employeesDataService.GetById(id);

            return(View(new EmployeeViewModel()
            {
                Id = employee.Id,
                Name = employee.Name,
                Surename = employee.Surename,
                Patronymic = employee.Patronymic,
                Age = employee.Age,
                Gender = employee.Gender,
                Profession = _employeesDataService.GetProfessions().FirstOrDefault(p => p.Id == employee.ProfessionId),
            }));
        }
示例#2
0
        public IActionResult Details(int id)
        {
            Employee employee = _employeesDataService.GetById(id);

            if (employee is not null)
            {
                return(View(new EmployeeViewModel()
                {
                    Id = employee.Id,
                    Name = employee.Name,
                    Surename = employee.Surename,
                    Patronymic = employee.Patronymic,
                    Age = employee.Age,
                    Gender = employee.Gender,
                    Profession = _employeesDataService.GetProfessions().FirstOrDefault(p => p.Id == employee.ProfessionId),
                }));
            }
            else
            {
                return(NotFound());
            }
        }
 public IEnumerable <Profession> GetProfessions() => _employeesData.GetProfessions();