Пример #1
0
        public ActionResult EditStudent(int id)
        {
            USERLOGIN user = StudentActions.findStudentByID(id);

            ViewBag.listParishes = ParishActions.listParishes();
            ViewBag.StudentByID  = user;

            var listclasses            = ClassActions.listClasses();
            List <SelectListItem> item = new List <SelectListItem>();
            int?selectedclass_id       = null;

            foreach (var i in listclasses)
            {
                if (i.class_id == user.class_id)
                {
                    selectedclass_id = i.class_id;
                    item.Add(new SelectListItem {
                        Text = i.class_name, Value = Convert.ToString(i.class_id), Selected = true
                    });
                }
                else
                {
                    item.Add(new SelectListItem {
                        Text = i.class_name, Value = Convert.ToString(i.class_id)
                    });
                }
            }
            ViewBag.listClasses = item;
            if (selectedclass_id == null)
            {
                ViewBag.findSelectedClassByID = null;
            }
            else
            {
                ViewBag.findSelectedClassByID = ClassActions.findListClassByID(selectedclass_id.Value);
            }
            return(View(ParishActions.findParishByUserID(user.userid)));
        }