public ActionResult SLeaveRequests(LeaveViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); LeavesRequest request = new LeavesRequest(); request.Reason = collection.Reason; request.Date = DateTime.Now; request.StudentId = LoginClass.LoginId; db.LeavesRequests.Add(request); db.SaveChanges(); return(View()); }
public ActionResult PLeaveRequests(LeaveViewModel collection) { DBSmartSchoolWebPortalEntities111 db = new DBSmartSchoolWebPortalEntities111(); LeavesRequest request = new LeavesRequest(); var Parent = db.Parents.Where(x => x.Id == LoginClass.LoginId).First(); var Student = db.Students.Where(x => x.Id == Parent.StudentId).First(); request.Reason = collection.Reason; request.Date = DateTime.Now; request.StudentId = Student.Id; db.LeavesRequests.Add(request); db.SaveChanges(); return(View()); }