public ActionResult Edit(EducationGroup educationGroup, int[] studentId, int[] notStudentId) { if (educationGroup.Id > 0) { if (studentId != null) { for (int i = 0; i < studentId.Length; i++) { _student = _stuBLL.Get(studentId[i]); _student.EducationGrouoStatus = false; _stuBLL.Update(_student); } } if (notStudentId != null) { for (int i = 0; i < notStudentId.Length; i++) { educationGroup.TrainerID = (int)Session["LoginID"]; _eduGroupStu = new Education_Group_Student(); _eduGroupStu.StudentID = notStudentId[i]; _eduGroupStu.EducationGroupID = educationGroup.Id; _student = _stuBLL.Get(notStudentId[i]); _eduGroupStu.DateOfJoin = DateTime.Now; _student.EducationGrouoStatus = true; _stuBLL.Update(_student); _educationGroupStuBLL.Add(_eduGroupStu); } } educationGroup.TrainerID = (int)Session["LoginID"]; _educationGroupBLL.Update(educationGroup); TempData["ResultMessage"] = "Yaptığınız Değişiklikler Başarıyla Gerçekleşmiştir."; } else { educationGroup.DateOfCreation = DateTime.Now.Date; educationGroup.TrainerID = (int)Session["LoginID"]; _educationGroupBLL.Add(educationGroup); for (int i = 0; i < studentId.Length; i++) { _eduGroupStu = new Education_Group_Student(); _eduGroupStu.DateOfJoin = DateTime.Now.Date; _eduGroupStu.EducationGroupID = educationGroup.Id; _eduGroupStu.StudentID = studentId[i]; _student = _stuBLL.Get(studentId[i]); _student.EducationGrouoStatus = true; _stuBLL.Update(_student); _educationGroupStuBLL.Add(_eduGroupStu); } } TempData["ResultMessage"] = "Kaydetme İşleminiz Başarıyla Gerçekleşmiştir."; return(RedirectToAction("Index")); }
public ActionResult Edit(int id = 0) { Student student; if (id != 0) { student = _studentBLL.Get(id); } else { student = new Student(); } List <EducationBranch> allEducationBranch = _studentBLL.EducationList(); SelectList educationBranchSelectList = new SelectList(allEducationBranch, "Id", "Name"); List <Gender> allGender = _studentBLL.GenderList(); SelectList genderSelectList = new SelectList(allGender, "Id", "Name"); ViewBag.EducationBranchs = educationBranchSelectList; ViewBag.Genders = genderSelectList; return(View(student)); }