public ActionResult DeleteConfirmed(int id, audit_trail audit)
        {
            var check = db.training_course_instance.Where(s => s.Instructor_ID == id).FirstOrDefault();

            if (check == null)
            {
                instructor instructor = db.instructors.Find(id);

                var userId = System.Web.HttpContext.Current.Session["UserID"] as String;
                int IntID  = Convert.ToInt32(userId);

                audit.Employee_ID       = IntID;
                audit.Trail_DateTime    = DateTime.Now.Date;
                audit.Deleted_Record    = "Instructor ID" + instructor.Instructor_ID.ToString() + " " + instructor.Instructor_Name + " " + instructor.Instructor_Surname + " " + instructor.Instructor_Cellphone + " " + instructor.Instructor_Email + " Type ID: " + instructor.Instructor_Type_ID.ToString();
                audit.Trail_Description = "Deleted a Instructor";

                db.audit_trail.Add(audit);

                db.instructors.Remove(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else
            {
                instructor instructor = db.instructors.Find(id);
                ViewBag.Error = "Can't delete a instructor that has given a training course, keep it as a record for historic purposes.";
                return(View(instructor));
            }
        }
Exemplo n.º 2
0
        public int Remove(int id)
        {
            instructor i = ctx.instructor.FirstOrDefault(ins => ins.id == id);

            ctx.instructor.Remove(i);
            return(ctx.SaveChanges());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Edit(string id, [Bind("instructor_code,confirm_date,contactor,contactor_detail,id,instructor_desc,ref_doc,x_log,x_note,x_status")] instructor instructor)
        {
            if (new Guid(id) != instructor.id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(instructor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!instructorExists(instructor.instructor_code))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(instructor));
        }
Exemplo n.º 4
0
        public IHttpActionResult Putinstructor(int id, instructor instructor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != instructor.id)
            {
                return(BadRequest());
            }

            db.Entry(instructor).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!instructorExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public ActionResult Login(student model)
        {
            if (ModelState.IsValid)
            {
                var Username = db.students.FirstOrDefault(x => x.username == model.username && x.password == model.password);
                if (Username != null)
                {

                    faculty faculty = db.faculties.SingleOrDefault(f => f.facultyID == Username.facultyID);
                    department department = db.departments.SingleOrDefault(d => d.departmentID == Username.departmentID);
                    instructor instructor = db.instructors.SingleOrDefault(d => d.instructorID == Username.instructorID);


                    Session["StudentName"] = Username.stufullname;
                    Session["StudentNumber"] = Username.number;
                    Session["StudentDep"] = department.depname;
                    Session["StudentFac"] = faculty.facultyname;
                    Session["studepid"] = Username.departmentID;
                    Session["studentid"] = Username.studentID;
                    Session["stufoto"] = Username.image;
                    Session["stuinst"] = instructor.instfullname;
                    Session["curriculum"] = department.curriculum;
                    Session["Username"] = Username;
                    ViewBag.curriculum = department.curriculum;
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    ViewBag.Message = "Username or password wrong!!!";
                }
            }

            return View(model);
        }
        public ActionResult Create([Bind(Include = "Instructor_ID,Instructor_Name,Instructor_Surname,Instructor_Email,Instructor_Cellphone,Employee_ID,Instructor_Type_ID,Title_ID,Gender_ID")] instructor instructor)
        {
            bool val = Validate(instructor.Instructor_Email);

            if (ModelState.IsValid && val == false)
            {
                db.instructors.Add(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            else if (val == true)
            {
                ViewBag.StatusMessage = "There is already an instructor with email: " + instructor.Instructor_Email + "  in the database.";

                ViewBag.Employee_ID        = new SelectList(db.employees, "Employee_ID", "Employee_Name", instructor.Employee_ID);
                ViewBag.Gender_ID          = new SelectList(db.genders, "Gender_ID", "Gender1", instructor.Gender_ID);
                ViewBag.Title_ID           = new SelectList(db.titles, "Title_ID", "Title1", instructor.Title_ID);
                ViewBag.Instructor_Type_ID = new SelectList(db.instructor_type, "Instructor_Type_ID", "Instructor_Type_Name", instructor.Instructor_Type_ID);
                return(View());
            }

            ViewBag.Employee_ID        = new SelectList(db.employees, "Employee_ID", "Employee_Name", instructor.Employee_ID);
            ViewBag.Gender_ID          = new SelectList(db.genders, "Gender_ID", "Gender1", instructor.Gender_ID);
            ViewBag.Title_ID           = new SelectList(db.titles, "Title_ID", "Title1", instructor.Title_ID);
            ViewBag.Instructor_Type_ID = new SelectList(db.instructor_type, "Instructor_Type_ID", "Instructor_Type_Name", instructor.Instructor_Type_ID);
            return(View(instructor));
        }
Exemplo n.º 7
0
        public void instructorLogin()
        {
            instructor        instructor     = new instructor(id);
            teachingStaffMenu instructorMenu = new teachingStaffMenu(instructor);

            Assert.IsTrue(instructor is instructor && instructorMenu is teachingStaffMenu);
        }
        public ActionResult DeleteConfirmed(int id)
        {
            instructor instructor = db.instructors.Find(id);

            db.instructors.Remove(instructor);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemplo n.º 9
0
        public void instructorLogoff()
        {
            instructor        instructor     = new instructor(id);
            teachingStaffMenu instructorMenu = new teachingStaffMenu(instructor);

            instructorMenu.Close();
            Assert.IsNotNull(instructorMenu);
        }
Exemplo n.º 10
0
 public static instructor getInstructorByID(int id)
 {
     using (MCenterDBContext db = new MCenterDBContext())
     {
         instructor instructor = db.instructors.Where(x => x.instructor_id == id).SingleOrDefault();
         return(instructor);
     }
 }
Exemplo n.º 11
0
        public static void DeleteInstructor(int id)
        {
            MCenterDBContext db         = new MCenterDBContext();
            instructor       deletedIns = getInstructorByID(id);

            //delete from qualification instructor
            //delete from phone instructor

            DeletePhoneInstructor(id);
        }
Exemplo n.º 12
0
        public static void UpdateInstructor(instructorQualificationPhoneViewModel instructorvm)
        {
            MCenterDBContext db = new MCenterDBContext();
            instructor       updataedInstructor = getInstructorByID(instructorvm.instructor_id);

            updataedInstructor.instructor_name = instructorvm.instructor_name;
            updataedInstructor.NameOf_ItsUnit  = instructorvm.NameOf_ItsUnit;
            updataedInstructor.TrainningTopic  = instructorvm.TrainningTopic;
            db.SaveChanges();
        }
 public ActionResult Edit([Bind(Include = "inst_id,inst_name,inst_charge,inst_speciality,inst_car,inst_gender")] instructor instructor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(instructor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(instructor));
 }
Exemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "instructorID,instfullname,instmail,instroom,instofficehours,instusername,instpassword")] instructor instructor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(instructor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(instructor));
 }
Exemplo n.º 15
0
 public static void DeleteInstructor(int id)
 {
     using (MCenterDBContext db = new MCenterDBContext())
     {
         instructor deletedIns = getInstructorByID(id);
         //  db.instructors.Remove(deletedIns);
         db.Entry(deletedIns).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
Exemplo n.º 16
0
 public ActionResult Edit([Bind(Include = "instructorId,firstName,lastName,internship,pathPic")] instructor instructor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(instructor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(instructor));
 }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "instructorID,firstName,lastName,officePhoneNumber,email")] instructor instructor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(instructor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(instructor));
 }
Exemplo n.º 18
0
        public ActionResult Create([Bind(Include = "instructorID,instfullname,instmail,instroom,instofficehours,instusername,instpassword")] instructor instructor)
        {
            if (ModelState.IsValid)
            {
                db.instructors.Add(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(instructor));
        }
Exemplo n.º 19
0
        public ActionResult Create([Bind(Include = "instructorID,firstName,lastName,officePhoneNumber,email")] instructor instructor)
        {
            if (ModelState.IsValid)
            {
                db.Instructor.Add(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(instructor));
        }
Exemplo n.º 20
0
        public async Task <IActionResult> Create([Bind("instructor_code,confirm_date,contactor,contactor_detail,id,instructor_desc,ref_doc,x_log,x_note,x_status")] instructor instructor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(instructor);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(instructor));
        }
Exemplo n.º 21
0
        public ActionResult Create([Bind(Include = "instructorId,firstName,lastName,internship,pathPic")] instructor instructor)
        {
            if (ModelState.IsValid)
            {
                db.instructors.Add(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(instructor));
        }
Exemplo n.º 22
0
        public IHttpActionResult Getinstructor(int id)
        {
            instructor instructor = db.instructor.Find(id);

            if (instructor == null)
            {
                return(NotFound());
            }

            return(Ok(instructor));
        }
        public ActionResult Create([Bind(Include = "inst_id,inst_name,inst_charge,inst_speciality,inst_car,inst_gender")] instructor instructor)
        {
            if (ModelState.IsValid)
            {
                db.instructors.Add(instructor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(instructor));
        }
Exemplo n.º 24
0
        public IHttpActionResult Postinstructor(instructor instructor)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.instructor.Add(instructor);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = instructor.id }, instructor));
        }
Exemplo n.º 25
0
        public IHttpActionResult Deleteinstructor(int id)
        {
            instructor instructor = db.instructor.Find(id);

            if (instructor == null)
            {
                return(NotFound());
            }
            db.instructor.Remove(instructor);
            db.SaveChanges();
            return(Ok(instructor));
        }
Exemplo n.º 26
0
 static void Main(string[] args)
 {
     instructor john = new instructor("john", "English");
     instructor mike = new instructor("john", "Math");
     student jane = new student ("jane", 0, john );
     student joe = new student("joe", 0, john);
     student Melissa = new student("Melissa", 0, mike);
     student Matt = new student("Matt", 0, mike);
     john.SetStudentGrade(jane, 95);
     john.SetStudentGrade(joe, 85);
     mike.SetStudentGrade(Melissa, 90);
     mike.SetStudentGrade(Matt, 92);
 }
        // GET: instructors/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            instructor instructor = db.instructors.Find(id);

            if (instructor == null)
            {
                return(HttpNotFound());
            }
            return(View(instructor));
        }
        public ActionResult Edit(int id)
        {
            instructor instructor = InstructorBll.getInstructorByID(id);

            instructorQualificationPhoneViewModel insvm = new instructorQualificationPhoneViewModel();

            insvm.instructor_id   = instructor.instructor_id;
            insvm.instructor_name = instructor.instructor_name;
            insvm.NameOf_ItsUnit  = instructor.NameOf_ItsUnit;
            insvm.TrainningTopic  = instructor.TrainningTopic;



            return(View(insvm));
        }
Exemplo n.º 29
0
 //public ActionResult Edit(int? id)
 //{
 //    if (id == null)
 //    {
 //        return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
 //    }
 //    Course course = db.course.Find(id);
 //    if (course == null)
 //    {
 //        return HttpNotFound();
 //    }
 //    return View(course);
 //}
 public ActionResult edit(string id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     else
     {
         instructor instructor = db.instructor.Find(id);
         if (instructor == null)
         {
             return(HttpNotFound());
         }
         return(View(instructor));
     }
 }
Exemplo n.º 30
0
 public static void UpdateInstructor(instructorVM instructorvm)
 {
     using (MCenterDBContext db = new MCenterDBContext())
     {
         instructor updataedInstructor = getInstructorByID(instructorvm.instructor_id);
         updataedInstructor.instructor_name    = instructorvm.instructor_name;
         updataedInstructor.NameOf_ItsUnit     = instructorvm.NameOf_ItsUnit;
         updataedInstructor.TrainningTopic     = instructorvm.TrainningTopic;
         updataedInstructor.Current_JobTitle   = instructorvm.Current_JobTitle;
         updataedInstructor.Mobile             = instructorvm.Mobile;
         updataedInstructor.phone              = instructorvm.phone;
         updataedInstructor.Email              = instructorvm.Email;
         updataedInstructor.QualificationsName = instructorvm.QualificationsName;
         db.Entry(updataedInstructor).State    = EntityState.Modified;
         db.SaveChanges();
     }
 }
        // GET: instructors/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            instructor instructor = db.instructors.Find(id);

            if (instructor == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Employee_ID        = new SelectList(db.employees, "Employee_ID", "Employee_Name", instructor.Employee_ID);
            ViewBag.Gender_ID          = new SelectList(db.genders, "Gender_ID", "Gender1", instructor.Gender_ID);
            ViewBag.Title_ID           = new SelectList(db.titles, "Title_ID", "Title1", instructor.Title_ID);
            ViewBag.Instructor_Type_ID = new SelectList(db.instructor_type, "Instructor_Type_ID", "Instructor_Type_Name", instructor.Instructor_Type_ID);
            return(View(instructor));
        }
Exemplo n.º 32
0
 public student(string studentName, int grade, instructor teacher)
 {
     this.studentName = studentName;
     this.grade = grade;
     this.teacher = teacher;
 }