示例#1
0
        public ActionResult BrowseOrgData(int?departmentId, int?employeeId)
        {
            eManagerContext db        = new eManagerContext();
            var             viewModel = new BrowseOrgDataViewModel();

            viewModel.Departments = db.Departments.ToList();
            //.Include(e => e.Employees.Select(d => d.Department));

            if (departmentId != null)
            {
                viewModel.Employees = viewModel.Departments.Where(
                    d => d.Id == departmentId).Single().Employees;
            }

            if (employeeId != null)
            {
                var selectedEmployee = viewModel.Employees.Where(
                    e => e.Id == employeeId).Single();
                db.Entry(selectedEmployee).Collection(x => x.Dependents).Load();

                viewModel.Dependents = selectedEmployee.Dependents;
            }

            return(View(viewModel));
        }
示例#2
0
 public ActionResult Edit([Bind(Include = "Id,Title,Header,Description")] Service service)
 {
     if (ModelState.IsValid)
     {
         db.Entry(service).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(service));
 }