public ActionResult Create(Athlete athlete) { if (ModelState.IsValid) { db.Athletes.Add(athlete); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(athlete)); }
public ActionResult Create(PaymentBtns paymentBtns) { if (ModelState.IsValid) { db.PaymentBtns.Add(paymentBtns); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(paymentBtns)); }
public ActionResult Create(Program program) { if (ModelState.IsValid) { db.Programs.Add(program); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(program)); }
public ActionResult Create(VolunteerRoles volunteerroles) { if (ModelState.IsValid) { db.VolunteerRoles.Add(volunteerroles); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(volunteerroles)); }
public ActionResult Create(VolunteerCommitments volunteercommitments) { if (ModelState.IsValid) { db.VolunteerCommitments.Add(volunteercommitments); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EventID = new SelectList(db.VolunteerEvents, "EventID", "EventName", volunteercommitments.EventID); PopulateEventDropDownList(volunteercommitments.EventID); ViewBag.RoleID = new SelectList(db.VolunteerRoles, "RoleID", "Role", volunteercommitments.RoleID); return(View(volunteercommitments)); }
public ActionResult Create(Enrollment enrollment) { if (ModelState.IsValid) { db.Enrollment.Add(enrollment); db.SaveChanges(); return(RedirectToAction("Confirmation", enrollment)); // old way to call receipt //return RedirectToAction("Receipt", enrollment); } ViewBag.AthleteID = new SelectList(db.Athletes, "AthleteID", "FullName", enrollment.AthleteID); ViewBag.ProgramID = new SelectList(db.Programs.Where(p => p.Active == true).OrderBy(p => p.Title), "ProgramID", "Title", enrollment.ProgramID); return(View(enrollment)); }
public ActionResult Edit(ReceiptData receiptdata) { if (ModelState.IsValid) { db.Entry(receiptdata).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(receiptdata)); }
protected void Page_Load(object sender, EventArgs e) { //Redirect unauthenticated user to the Default page. string authenticationStatus = Session["loggedIn"] as string; if (authenticationStatus == "no" || authenticationStatus == null) { Response.Redirect("Default.aspx"); } //Get the Home LinkButton on the Master page //make it visible and attach an event handler //so that when clicked, redirect the user to the Default page. LinkButton btnHome = (LinkButton)Master.FindControl("btnHome"); btnHome.Click += (s, a) => Response.Redirect("Default.aspx"); //I know this isn't properly connected to masterpage buttons at the moment :( BulletedList topMenu = (BulletedList)Master.FindControl("topMenu"); if (!IsPostBack) { topMenu.Items.Add(new ListItem("Home")); topMenu.Items.Add(new ListItem("Log Out")); } //topMenu.Click += topMenu_Click; //Get the Logout LinkButton on the Master page //make it visible and attach the event handler Logout to it LinkButton btnLogout = (LinkButton)Master.FindControl("btnLogout"); btnLogout.Click += (s, a) => Logout(s, a); using (RegistrationDB entityContext = new RegistrationDB()) { //Get the registered course list of the authenticated user. string studentNumber = Session["studentNumber"] as string; //trying to pair the student's number with the course code from the DB. //I think my sql server isn't correct so I have some incorrect variables here //attempted to display correct courses via the database using Entity Framework List <Course> CourseList = (from a in entityContext where a.Course.Code == Registration.Course_CourseID && a.StudentId == studentNumber select a).FirstOrDefault <Course>(); //If the user clicked the delete link of a coure, //delete the selected course from the user's registration //same problems as above in terms of accessing "Registration" string action = Request.Params["action"] as string; if (action == "delete") { string ID = Request.Params["id"]; var course = (from c in entityContext.Courses where c.CourseID == ID select c).FirstOrDefault <Course>(); if (course != null) { //I realize "Registration is the incorrect property for (int i = course.Registration.Count() - 1; i >= 0; i--) { var record = course.Registration.ElementAt <Course>(i); course.Registration.Remove(record); } } entityContext.Courses.Remove(course); entityContext.SaveChanges(); Response.Redirect("CurrentRegistrations.aspx"); } //making list to display up to date courses //Display the registered course list (use ShowCourseInfo method) ShowCourseInfo(CourseList); } }
protected void Page_Load(object sender, EventArgs e) { //Redirect unauthenticated user to the Default page. if (Session["studentName"] == null) { Response.Redirect("Default.aspx"); } else { using (RegistrationDB entityContext = new RegistrationDB()) { //showing the list of courses List <Course> courses = entityContext.Courses.ToList <Course>(); //existing list of all courses List <Course> filteredCourses = new List <Course>(); //new empty list foreach (Course course in courses) //loops through each course { foreach (Student st in course.Students) //loops through each course to see which students are related to it //refer to diagram for navigation properties, that links both tables together { if (st.Name == (string)Session["studentName"]) //select the courses where studentName == the student's name from first page { filteredCourses.Add(course); //add selected courses to the new list "filteredCourses" } } } ShowCourseInfo(filteredCourses); //calling the method to display courses //deleting course string action = Request.Params["action"]; string courseId = Request.Params["id"]; string stNumber = (string)Session["studentNumber"]; if (Request.Params["action"] == "delete") { var removeCourse = (from c in entityContext.Courses where c.CourseID == courseId select c).FirstOrDefault <Course>(); //selecting course by id if (removeCourse != null) { for (int i = courses.Count() - 1; i >= 0; i--) //removing from list { var ar = courses.ElementAt <Course>(i); courses.Remove(ar); } } entityContext.Courses.Remove(removeCourse); //removing from database entityContext.SaveChanges(); Response.Redirect("CurrentRegistrations.aspx"); } } } //Get the Home LinkButton on the Master page //make it visible and attach an event handler //so that when clicked, redirect the user to the Default page LinkButton btnHome = (LinkButton)Master.FindControl("btnHome"); //instanciating Home Button btnHome.Visible = true; //making it visible btnHome.Click += (s, a) => Response.Redirect("Default.aspx"); //adding action to Home Button //Get the Logout LinkButton on the Master page //make it visible and attach the event handler Logout to it LinkButton btnLogout = (LinkButton)Master.FindControl("btnLogout"); //instanciating Logout Button btnLogout.Visible = true; //making it visible btnLogout.Click += (s, a) => Logout(s, a); //ading an action to Logout button }