示例#1
0
        public ActionResult UpdateChildren(int id)
        {
            var vm = new ParentChildChecklistVM();
            vm.ParentId = id;
            var searchRequest = new SearchRequest
            {
                RoleName = "Student"
            };

            var searchResponse = _lmsUserManager.UserSearch(searchRequest);

            if (!searchResponse.Success)
            {
                ViewBag.ErrorMsg = searchResponse.Message;
                return View("Error");
            }

            var studentResponse = _lmsUserManager.GetStudentsByParentId(id);

            if (studentResponse.Success)
            {
                vm.PopulateList(searchResponse.Data, studentResponse.Data);
                return View("SelectUserChildren", vm);
            }
            else
            {
                ViewBag.ErrorMsg = studentResponse.Message;
                return View("Error");
            }
        }
示例#2
0
        public ActionResult UpdateChildren(ParentChildChecklistVM model)
        {
            var childIdList = new List<int>();
            foreach (var item in model.AllUsersSelectList)
            {
                if (item.IsChecked)
                {
                    childIdList.Add(item.UserId);
                }
            }

            var response = _lmsUserManager.UpdateParentChildRelationship(model.ParentId, childIdList);
            if (response.Success)
            {
                return RedirectToAction("UserDetails", new {id = model.ParentId});
            }
            else
            {
                ViewBag.ErrorMsg = response.Message;
                return View("Error");
            }
        }