public ActionResult ChangeInfo(Model_StudentInfoEdit model) { if (ModelState.IsValid) { var _StudentInfo = db.Tbl_StudentInfo.Where(x => x.Tbl_Student.FirstOrDefault().Student_ID == model.ID && !x.SI_IsDelete).SingleOrDefault(); if (_StudentInfo != null) { _StudentInfo.SI_Name = model.Name; _StudentInfo.SI_Family = model.Family; _StudentInfo.SI_Mobile = model.Mobile; _StudentInfo.SI_Email = model.Email; _StudentInfo.SI_Phone = model.Phone; _StudentInfo.SI_GenderCodeID = Convert.ToInt32(model.Gender); _StudentInfo.SI_BirthYearCodeID = Convert.ToInt32(model.BirthYear); _StudentInfo.SI_NationalCodeID = Convert.ToInt32(model.National); _StudentInfo.SI_BloodCodeID = Convert.ToInt32(model.Blood); _StudentInfo.SI_InsuranceCodeID = Convert.ToInt32(model.Insurance); //Grad _StudentInfo.SI_HomeTypeCodeID = Convert.ToInt32(model.HomeType); _StudentInfo.SI_MarriageCodeID = Convert.ToInt32(model.Marriage); //University //College _StudentInfo.SI_BranchID = Convert.ToInt32(model.Branch);// _StudentInfo.SI_BirthdayLocation = model.BirthLocation; _StudentInfo.SI_BeforeUniversity = model.BeforeUniversity; db.Entry(_StudentInfo).State = EntityState.Modified; if (Convert.ToBoolean(db.SaveChanges() > 0)) { TempData["TosterState"] = "success"; TempData["TosterType"] = TosterType.Maseage; TempData["TosterMassage"] = "ویرایش شد"; } else { TempData["TosterState"] = "error"; TempData["TosterType"] = TosterType.Maseage; TempData["TosterMassage"] = "ویرایش نشد"; } return(RedirectToAction("Details", new { id = model.ID })); } return(HttpNotFound()); } return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); }
public ActionResult ChangeInfo(int?id) { if (id != null) { var _StudentInfo = db.Tbl_StudentInfo.Where(x => x.Tbl_Student.FirstOrDefault().Student_ID == id && !x.SI_IsDelete).SingleOrDefault(); if (_StudentInfo != null) { Model_StudentInfoEdit model = new Model_StudentInfoEdit() { ID = _StudentInfo.SI_ID, Name = _StudentInfo.SI_Name, Family = _StudentInfo.SI_Family, Email = _StudentInfo.SI_Email, Mobile = _StudentInfo.SI_Mobile, Phone = _StudentInfo.SI_Phone, Gender = _StudentInfo.SI_GenderCodeID, BirthYear = _StudentInfo.SI_BirthYearCodeID, National = _StudentInfo.SI_NationalCodeID, Blood = _StudentInfo.SI_BloodCodeID, Insurance = _StudentInfo.SI_InsuranceCodeID, Grad = _StudentInfo.Tbl_Branch.Tbl_Grad.Grade_ID,// HomeType = _StudentInfo.SI_HomeTypeCodeID, Marriage = _StudentInfo.SI_MarriageCodeID, University = _StudentInfo.Tbl_Branch.Tbl_Grad.Tbl_College.Tbl_University.University_ID, // College = _StudentInfo.Tbl_Branch.Tbl_Grad.Tbl_College.College_ID, // Branch = _StudentInfo.Tbl_Branch.Branch_ID, // BirthLocation = _StudentInfo.SI_BirthdayLocation, BeforeUniversity = _StudentInfo.SI_BeforeUniversity, }; return(PartialView(model)); } else { TempData["TosterState"] = "error"; TempData["TosterType"] = TosterType.Maseage; TempData["TosterMassage"] = "اطلاعات هویتی دانشجوی مورد نظر در سامانه ثبت نشده است."; return(RedirectToAction("Details", new { id })); } } return(HttpNotFound()); }