Esempio n. 1
0
        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()));
        }
Esempio n. 2
0
        public LogViewModel(Database database)
        {
            _database = database;

            _userRepository       = new UserRepository(database);
            _departmentRepository = new DepartmentRepository(database);

            _users       = _userRepository.All();
            _departments = _departmentRepository.All();

            _user = new User();
        }
Esempio n. 3
0
 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()));
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 // GET: Courses/Create
 public ActionResult Create()
 {
     ViewBag.DepartmentID = new SelectList(repoDept.All(), "DepartmentID", "Name");
     return(View());
 }
Esempio n. 6
0
 // GET: Departments
 public ActionResult Index()
 {
     return(View(repoDepart.All()));
 }
Esempio n. 7
0
 public override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     filterContext.Controller.ViewBag.DepartmentList = repo.All().Select(p => new { p.DepartmentID, p.Name }).ToList();
     base.OnActionExecuting(filterContext);
 }