public ActionResult Create(TeachersBookkeeping teacher) { teacher.TeacherId = context.Teachers.Where(x => x.Id == teacher.Teachers.Id).Select(x => x.Id).First(); teacher.Teachers = context.Teachers.Find(teacher.TeacherId); try { context.teachersBookkeepings.Add(teacher); context.SaveChanges(); return(RedirectToAction("Index/" + teacher.Teachers.UniversityId)); } catch { return(View()); } }
public ActionResult Edit(int id, [Bind(Include = "Id,TeacherId,Teachers,Hours,Experience_months,Salary,Taxes,Bonus")] TeachersBookkeeping teacher) { try { if (ModelState.IsValid) { context.Entry(teacher).State = EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index/" + teacher.Teachers.UniversityId)); } return(View(teacher)); } catch (Exception ex) { return(View(teacher)); } }