public ActionResult CourseBatchEditLazyBinding(FormCollection form, bool IsEditMode = false) { List <CourseBatchEditVM> data = new List <CourseBatchEditVM>(); //try //{ // UpdateModel(data); //} //catch (Exception ex) //{ // throw ex; //} if (TryUpdateModel(data)) { foreach (var item in data) { var course = repoCourse.All().FirstOrDefault(p => p.CourseID == item.CourseID); course.InjectFrom(item); } repoCourse.UnitOfWork.Commit(); TempData["CourseBatchEditResult"] = "批次更新成功!"; return(RedirectToAction("CourseBatchEdit")); } ViewBag.IsEditMode = IsEditMode; ViewBag.DepartmentID = new SelectList(repo.All(), "DepartmentID", "Name"); return(View(repoCourse.All())); }
public LogViewModel(Database database) { _database = database; _userRepository = new UserRepository(database); _departmentRepository = new DepartmentRepository(database); _users = _userRepository.All(); _departments = _departmentRepository.All(); _user = new User(); }
public ActionResult CourseBatchEdit(List <CourseBatchEditVM> data, bool IsEditMode = false) { if (ModelState.IsValid) { foreach (var item in data) { var course = repoCourse.All().FirstOrDefault(p => p.CourseID == item.CourseID); course.InjectFrom(item); } repoCourse.UnitOfWork.Commit(); TempData["CourseBatchEditResult"] = "批次更新成功!"; return(RedirectToAction("CourseBatchEdit")); } ViewBag.IsEditMode = IsEditMode; ViewBag.DepartmentID = new SelectList(repo.All(), "DepartmentID", "Name"); return(View(repoCourse.All())); }
internal List <SelectListItem> GetDepartmentSelectList(string departmentSelected) { DepartmentRepository repoDepartment = RepositoryHelper.GetDepartmentRepository(); var query = repoDepartment.All(); List <SelectListItem> slResult = new List <SelectListItem>(); foreach (var c in query) { slResult.Add(new SelectListItem() { Text = c.DepartmentName, Value = c.DepartmentID, Selected = c.DepartmentID.Equals(departmentSelected) }); } repoDepartment.UnitOfWork.Context.Dispose(); return(slResult); }
// GET: Courses/Create public ActionResult Create() { ViewBag.DepartmentID = new SelectList(repoDept.All(), "DepartmentID", "Name"); return(View()); }
// GET: Departments public ActionResult Index() { return(View(repoDepart.All())); }
public override void OnActionExecuting(ActionExecutingContext filterContext) { filterContext.Controller.ViewBag.DepartmentList = repo.All().Select(p => new { p.DepartmentID, p.Name }).ToList(); base.OnActionExecuting(filterContext); }