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) })); }
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()); } }
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()); } }