示例#1
0
        // Форма добавления нового сотрудника
        public IActionResult Create()
        {
            var model = new CreateOrUpdateEmployeeModel
            {
                Employee    = new EmployeeDto(),
                Departments = new SelectList(_departments.Departments, "Id", "Name"),
                Positions   = new SelectList(_departments.Positions, "Id", "Name")
            };

            return(PartialView(model));
        }
示例#2
0
        public async Task <IActionResult> UpdateAsync(CreateOrUpdateEmployeeModel model)
        {
            if (ModelState.IsValid)
            {
                await _employees.UpdateEmployeeAsync(model.Employee);
            }

            model.Departments = new SelectList(_departments.Departments, "Id", "Name");
            model.Positions   = new SelectList(_departments.Positions, "Id", "Name");

            return(PartialView("Update", model));
        }
示例#3
0
        // Форма изменения данных сотрудника
        public async Task <IActionResult> UpdateAsync(int id)
        {
            var employee = await _employees.GetEmployeeByIdAsync(id);

            var model = new CreateOrUpdateEmployeeModel
            {
                Employee    = employee,
                Departments = new SelectList(_departments.Departments, "Id", "Name"),
                Positions   = new SelectList(_departments.Positions, "Id", "Name")
            };

            return(PartialView(model));
        }