Пример #1
0
        public ActionResult AddRelative([Bind(Include = "id,user1_id,user2_id")] RelativeList relativeList)
        {
            if (ModelState.IsValid)
            {
                db.RelativeList.Add(relativeList);
                db.RelativeList.Add(new RelativeList {
                    user1_id = relativeList.user2_id, user2_id = relativeList.user1_id
                });
                db.SaveChanges();

                return(RedirectToAction("RelativeList", new { id = relativeList.user1_id }));
            }
            return(View(new List <User> {
                db.Member.Find(relativeList.user1_id), db.Member.Find(relativeList.user2_id)
            }));
        }
Пример #2
0
        public ActionResult Edit(string id, relative cl)
        {
            StudentList studentList = new StudentList();
            var         obj         = studentList.ListAll();

            ViewBag.studentCode = new SelectList(obj, "code", "code");
            try
            {
                // TODO: Add insert logic here
                RelativeList relativeList = new RelativeList();
                relativeList.UpdateRelative(id, cl); //Gọi đến hàm addClass trong class ClassList trong models
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Пример #3
0
        public ActionResult Create(relative cl)
        {
            StudentList    studentList = new StudentList();            //Khởi tạo biếm có giá trị là class được khai báo trong models/batch
            List <student> obj         = studentList.ListAll();        //Gọi hàm listall khai báo trong class trong models lấy ra danh sách batch

            ViewBag.studentCode = new SelectList(obj, "code", "code"); //Đưa viewBag vào view
            try
            {
                // TODO: Add insert logic here
                RelativeList relativeList = new RelativeList();
                relativeList.Insert(cl); //Gọi đến hàm addClass trong class ClassList trong models
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }