Ejemplo n.º 1
0
        public ActionResult Add(EmployeeAddViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var empl = new EmployeeAddViewModel
                {
                    Name = model.Name,
                    SecondName = model.SecondName,
                    Sex = model.Sex,
                    Years = model.Years,
                    DepartmentId = model.DepartmentId,
                    DepartmentList = db.Departments,
                    ProgrammingLanguageId = model.ProgrammingLanguageId,
                    ProgrammingLanguageList = db.ProgrammingLanguages
                };

                return View(empl);
            }
            var employee = new Employee();
            employee.Name = model.Name;
            employee.SecondName = model.SecondName;
            employee.Sex = model.Sex;
            employee.Years = model.Years;
            employee.DepartmentId = model.DepartmentId;
            employee.ProgrammingLanguageId = model.ProgrammingLanguageId;
            db.Employees.Add(employee);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
 public void SetEmployees(Employee[] employees)
 {
     employeeListBox.DataContext = employees;
 }
 public void SetEmployee(Employee employee)
 {
     DataContext = employee;
 }
 public void ShowView(Employee employee)
 {
     _employeeDetailsView.SetEmployee(employee);
     _regionManager.AddToRegion("WorkspaceRegion", _employeeDetailsView);
     _regionManager.Regions["WorkspaceRegion"].Activate(_employeeDetailsView);
 }