public IQueryable<WebApplication1.HalonModels.Firefighter> GetFirefighters()
        {
            HalonContext _db = new HalonContext();
            IQueryable<WebApplication1.HalonModels.Firefighter> firefighters = _db.Firefighters;
            IQueryable<WebApplication1.HalonModels.Firefighter> ffquery = _db.Firefighters;
            string firefighter_UName = Page.User.Identity.Name;
            ffquery = ffquery.Where(f => f.Firefighter_Account_Username.Equals(firefighter_UName));
            firefighters = firefighters.Where(f => f.Dept_ID == ffquery.FirstOrDefault().Dept_ID);

            return firefighters;
        }
        public IQueryable<WebApplication1.HalonModels.Department> GetDepartments()
        {
            HalonContext _db = new HalonContext();

            IQueryable<WebApplication1.HalonModels.Firefighter> ffquery = _db.Firefighters;
            string firefighter_UName = Page.User.Identity.Name;
            ffquery = ffquery.Where(f => f.Firefighter_Account_Username.Equals(firefighter_UName));
            int dept_id = Convert.ToInt32(ffquery.First().Dept_ID);

            IQueryable<WebApplication1.HalonModels.Department> depts = _db.Departments.Where(p => p.Dept_ID == dept_id);
            return depts;
        }
        private bool EditCounty(string countyId, string name, string stateID)
        {
            var _db = new WebApplication1.HalonModels.HalonContext();
            int county_ID = Convert.ToInt32(countyId);
            var myCounty = (from c in _db.Counties where c.County_ID == county_ID select c).FirstOrDefault();
            myCounty.County_Name = name;
            myCounty.State_ID = Convert.ToInt32(stateID);

            // Add product to DB.
            _db.SaveChanges();

            // Success.
            return true;
        }
        private bool AddCounty(string name, string stateID)
        {
            var _db = new WebApplication1.HalonModels.HalonContext();
            HalonModels.County myCounty = new HalonModels.County();
            myCounty.County_Name = name;
            myCounty.State_ID = Convert.ToInt32(stateID);

            // Add product to DB.
            _db.Counties.Add(myCounty);
            _db.SaveChanges();

            // Success.
            return true;
        }
        public IQueryable<WebApplication1.HalonModels.Firefighter> GetFirefighterInfo([QueryString("Firefighter_ID")]int? firefighterId)
        {
            var _db = new WebApplication1.HalonModels.HalonContext();
            IQueryable<WebApplication1.HalonModels.Firefighter> query = _db.Firefighters;

            if (firefighterId.HasValue && firefighterId > 0)
            {
                query = query.Where(f => f.Firefighter_ID == firefighterId);
            }
            else
            {
                query = null;
            }
            return query;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int county = Convert.ToInt16(Request.QueryString["CountyId"]);
         if (!(county == 0))
         {
             countyAddTitle.InnerHtml = "<h1>Edit County</h1>";
             AddCountyButton.Text = "Edit County";
             var db = new HalonContext();
             var myCounty = (from c in db.Counties where c.County_ID == county select c).FirstOrDefault();
             StateDD.SelectedValue = myCounty.State_ID.ToString();
             AddCounty_Name.Text = myCounty.County_Name;
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int enrollmentId = Convert.ToInt16(Request.QueryString["EnrollmentId"]);
         AddEnrollmentButton.Text = "Add Enrollment";
         if (!(enrollmentId == 0))
         {
             enrollmentAddTitle.InnerHtml = "<h1>Edit Enrollment</h1>";
             AddEnrollmentButton.Text = "Edit Enrollment";
             var db = new HalonContext();
             var myEnrollment = (from c in db.Enrollments where c.Enrollment_ID == enrollmentId select c).FirstOrDefault();
             AddFirefighterID.Text = myEnrollment.Firefighter_ID.ToString();
             AddClassID.Text = myEnrollment.Class_ID.ToString();
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         int classId = Convert.ToInt16(Request.QueryString["ClassId"]);
         if (!(classId == 0))
         {
             classAddTitle.InnerHtml = "<h1>Edit Class</h1>";
             var db = new HalonContext();
             var myClass = (from c in db.Classes where c.Class_ID == classId select c).FirstOrDefault();
             DropDownAddCourse.SelectedValue = myClass.Course_ID.ToString();
             AddClassDate.Text = myClass.Class_Date;
             AddClassNote.Text = myClass.Class_ID.ToString();
             AddClassCancel.Checked = myClass.Class_Cancelled;
             AddClassNote.Text = myClass.Class_Note;
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int courseID = Convert.ToInt16(Request.QueryString["CourseID"]);
                if (!(courseID == 0))
                {
                    AddCourseHeader.Text = "Update Course:";
                    AddCourseButton.Text = "Update Course";
                    var db = new HalonContext();
                    var myCourse = (from c in db.Courses where c.Course_ID == courseID select c).FirstOrDefault();
                    AddCourseName.Text = myCourse.Course_Name.ToString();

                    if (myCourse.Course_Discontinued)
                        AddCourseDiscontinued.SelectedIndex = 1;
                    else
                        AddCourseDiscontinued.SelectedIndex = 0;

                    AddCourseCreditHours.Text = myCourse.Course_Credit_Hours.ToString();
                }
            }
        }
 protected void AddClassButton_Click(object sender, EventArgs e)
 {
     int classId = Convert.ToInt16(Request.QueryString["ClassId"]);
     EditClass edit = new EditClass();
     bool editSuccess;
     var db = new WebApplication1.HalonModels.HalonContext();
     IQueryable<WebApplication1.HalonModels.Firefighter> ffquery = db.Firefighters;
     string firefighter_UName = Page.User.Identity.Name;
     ffquery = ffquery.Where(f => f.Firefighter_Account_Username.Equals(firefighter_UName));
     string firefighter_ID = ffquery.First().Firefighter_ID.ToString();
     if (classId == 0)
     {
         editSuccess = edit.EditClasses(AddClassCancel.Checked, firefighter_ID, DropDownAddCourse.SelectedValue.ToString(), AddClassNote.Text, AddClassDate.Text);
     }
     else
     {
         editSuccess = edit.EditClasses(classId.ToString(), AddClassCancel.Checked, firefighter_ID, DropDownAddCourse.SelectedValue.ToString(), AddClassNote.Text, AddClassDate.Text);
     }
     if (editSuccess)
     {
         // Reload the page.
         Response.Redirect("/Instructor/Class/Class_Display.aspx");
     }
 }
        public void GetTeachers()
        {
            var _db = new WebApplication1.HalonModels.HalonContext();

            IQueryable<WebApplication1.HalonModels.Firefighter> ffquery = _db.Firefighters;
            string firefighter_UName = Page.User.Identity.Name;
            ffquery = ffquery.Where(f => f.Firefighter_Account_Username.Equals(firefighter_UName));

            IQueryable<WebApplication1.HalonModels.Firefighter> ffighters = _db.Firefighters;
            ffighters = ffighters.Where(f => f.Firefighter_Account_Username != null);

            List<HalonModels.Firefighter> returnList = new List<HalonModels.Firefighter>();
            foreach (HalonModels.Firefighter f in ffighters)
            {
                if (Roles.GetRolesForUser(f.Firefighter_Account_Username)[0] != "User")
                {
                    returnList.Add(f);
                }
            }

            IQueryable<HalonModels.Firefighter> query = _db.Firefighters;

            query = returnList.AsQueryable<HalonModels.Firefighter>();

            List<HalonModels.Firefighter> list = query.ToList();

            DropDownAddTeacher.DataSource = list;
            DropDownAddTeacher.DataValueField = "Firefighter_ID";

            DropDownAddTeacher.DataBind();

            for (int i = 0; i < list.Count; i++)
            {
                DropDownAddTeacher.Items[i].Text = list[i].Firefighter_Fname + " " + list[i].Firefighter_Lname;
            }
        }
 public IQueryable<HalonModels.State> GetStates()
 {
     var db = new WebApplication1.HalonModels.HalonContext();
     IQueryable<HalonModels.State> query = db.States;
     return query;
 }
 public IQueryable<HalonModels.Class> GetClasses()
 {
     var db = new WebApplication1.HalonModels.HalonContext();
     IQueryable<HalonModels.Class> query = db.Classes;
     return query;
 }