public string GetSchoolId() { string userId = HttpContext.Current.User.Identity.GetUserId(); if (userId != null) { var schoolId = DropDownManager.GetSchoolId(userId); return(schoolId.ToString()); } else { var schoolId = 1; //dropDownManager.GetSchoolId(null); return(schoolId.ToString()); } }
protected void btnSave_Click(object sender, EventArgs e) { if (ValidateInputs()) { if (Page.IsValid) { string userId = HttpContext.Current.User.Identity.GetUserId(); var schoolId = DropDownManager.GetSchoolId(userId); var student = new Student() { FirstName = txtFirstName.Value, LastName = txtLastName.Value, MiddleName = txtMidName.Value, DateOfBirth = txtdate.Value, Sex = ddlSex.SelectedValue, LocalGovernmentID = int.Parse(ddlLGA.SelectedValue), Address = txtAddress.Value, DateCreated = DateTime.Now.ToShortDateString(), SchoolId = schoolId, CreatedBy = userId }; unitOfWork.studentData.Insert(student); unitOfWork.Save(); var guardianDetails = new StudentGuardianDetial() { StudentId = student.StudentId, FullName = txtFullname.Value, Address = txtGAddress.Value, MobileNo = txtGMobile.Value, RelationShip = int.Parse(ddlRelation.SelectedValue), Email = txtGEmail.Value }; unitOfWork.GuardianDetails.Insert(guardianDetails); unitOfWork.Save(); ClearInputs(); DropDownManager.ShowPopUp("Student Added Successfull"); } } }