示例#1
0
        public ActionResult AddAnnouncement(AnnouncementViewModel c, SearchViewModel collection, string ddlCustomers)
        {
            try
            {
                DB41Entities db = new DB41Entities();

                CourseAnnounment m = new CourseAnnounment();
                m.Title   = c.Title;
                m.Details = c.Detail;
                string a  = collection.Type1;
                var    Id = db.Courses
                            .Where(x => x.Title == a)
                            .Select(x => x.CourseID)
                            .FirstOrDefault();
                m.CourseID = Id;
                db.CourseAnnounments.Add(m);
                db.SaveChanges();

                return(View());
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#2
0
        public ActionResult DeleteStudent(string Cnic)
        {
            DB41Entities     db = new DB41Entities();
            StudentViewModel s  = new StudentViewModel();;

            s.CNIC = Cnic;

            //var item = db.Students.Where(x => x.CNIC == Cnic).SingleOrDefault();
            db.Students.Remove(db.Students.Where(x => x.CNIC == Cnic).SingleOrDefault());
            db.SaveChanges();
            string message = "Student Record has been deleted!";

            return(RedirectToAction("StudentCrud", "Admin", new { Message = message }));
        }
示例#3
0
        public ActionResult AddCourse(CourseViewModel c, SearchViewModel collection, string ddlCustomers)
        {
            //InstructorContext dbContext = new InstructorContext();
            //var getinstructorlist = dbContext.TbInstructor.ToList();
            //IEnumerable<SelectListItem> items = new SelectList(getinstructorlist, "Name");
            //ViewBag.JobTitle = items;



            DB41Entities db = new DB41Entities();

            //var getinstructorlist = db.Instructors.ToList();
            //SelectList list = new SelectList(getinstructorlist, "Name");
            //ViewBag.instructorlist = list;
            try
            {
                Cours m = new Cours();
                m.Title      = c.Title;
                m.Starttime  = c.Start_date.Date;
                m.Duration   = c.Course_duration;
                m.Fee        = c.Fee;
                m.Department = collection.Type;

                string a = collection.Type1;


                var Id = db.Instructors
                         .Where(x => x.Name == a)
                         .Select(x => x.InstructorID)
                         .FirstOrDefault();
                m.InstructorID = Id;


                db.Courses.Add(m);
                db.SaveChanges();

                return(View());

                //string q = ("SELECT Id FROM Instructors WHERE Name ='" + collection.Type1 + "'");
                //SqlCommand edit = new SqlCommand(q);
                //object result = edit.ExecuteScalar();
                //result = (result == DBNull.Value) ? null : result;
                //int a = Convert.ToInt32(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#4
0
        public ActionResult Delete(string C, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                DB41Entities db   = new DB41Entities();
                var          item = db.Students.Where(x => x.CNIC == C).SingleOrDefault();
                db.Students.Remove(item);
                db.SaveChanges();
                string message = "Student Record has been deleted!";
                return(RedirectToAction("StudentCrud", "Admin", new { Message = message }));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult EnrolledStudents(CourseViewModel m)
        {
            try
            {
                DB41Entities     db = new DB41Entities();
                StudentViewModel s  = new StudentViewModel();
                EnrolledStudent  n  = new EnrolledStudent();
                var Id = db.Courses
                         .Where(x => x.Title == m.Title)
                         .Select(x => x.CourseID)
                         .FirstOrDefault();
                n.CourseID   = Id;
                n.StartDate  = m.Start_date;
                n.Duration   = m.Course_duration;
                n.Department = m.Department;
                n.Fee        = m.Fee;
                var Ide = db.Instructors
                          .Where(x => x.Name == m.Instructor)
                          .Select(x => x.InstructorID)
                          .FirstOrDefault();

                n.InstructorID = Ide;
                string userid = User.Identity.GetUserId();
                int    g      = Convert.ToInt32(userid);
                var    person = db.Students.Where(y => y.StudentID == g).First();
                n.StudentName = person.Name;
                n.CNIC        = person.CNIC;
                n.Address     = s.Address;
                n.Email       = s.Email;
                n.StudentID   = person.StudentID;
                db.EnrolledStudents.Add(n);
                db.SaveChanges();



                return(View("Index"));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
示例#6
0
        public ActionResult AddAssessment(SearchViewModel collection, Assessment question)
        {
            try
            {
                DB41Entities db = new DB41Entities();
                Question     s  = new Question();
                string       d  = collection.Type;
                s.Name  = question.Detail;
                s.Marks = question.Marks;

                //var Id = db.Courses
                //  .Where(x => x.Title== collection.Type)
                //  .Select(x => x.CourseID)
                //  .FirstOrDefault();
                string userid = User.Identity.GetUserId();
                int    g      = Convert.ToInt32(userid);
                var    person = db.Instructors.Where(y => y.InstructorID == g).First();
                var    per    = db.Courses.Where(y => y.InstructorID == g).First();
                // var person = db.Courses.Where(y => y.Title == collection.Type).SingleOrDefault();
                s.CourseID     = per.CourseID;
                s.Department   = person.Department;
                s.InstructorID = g;

                //var Idee= db.Courses
                //  .Where(x => x.CourseID == Id)
                //  .Select(x => x.InstructorID)
                //  .FirstOrDefault();

                ////string userid = User.Identity.GetUserId();
                ////int g = Convert.ToInt32(userid);
                //s.InstructorID = Idee;

                db.Questions.Add(s);
                db.SaveChanges();
                return(RedirectToAction("Index", "Instructor"));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public ActionResult Create(StudentViewModel collection, SearchViewModel search)
 {
     try
     {
         DB41Entities db = new DB41Entities();
         Student      s  = new Student();
         s.Name       = collection.Name;
         s.CNIC       = collection.CNIC;
         s.Address    = collection.Address;
         s.Department = search.Type;
         s.Email      = collection.Email;
         s.Password   = collection.Password;
         db.Students.Add(s);
         db.SaveChanges();
         return(RedirectToAction("Login", "Student"));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#8
0
 public ActionResult Addinstructor(InstructorViewModel collection, SearchViewModel search)
 {
     try
     {
         DB41Entities db = new DB41Entities();
         Instructor   s  = new Instructor();
         s.Name        = collection.Fullname;
         s.CNIC        = collection.Cnic;
         s.Address     = collection.Homeaddress;
         s.Department  = search.Type;
         s.Email       = collection.EmailiD;
         s.PhoneNumber = collection.Phonenumber;
         s.Password    = collection.Password;
         s.Salary      = collection.Salary;
         db.Instructors.Add(s);
         db.SaveChanges();
         return(RedirectToAction("Index", "Admin"));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
示例#9
0
        public ActionResult addquestions(int id, MCQ_S a)
        {
            try
            {
                DB41Entities  db = new DB41Entities();
                QuestionPaper s  = new QuestionPaper();

                s.QuestionID = id;
                s.Title      = a.Title;
                s.Option1    = a.Option1;
                s.Option2    = a.Option2;
                s.Option3    = a.Option3;
                s.Option4    = a.Option4;

                db.QuestionPapers.Add(s);
                db.SaveChanges();
                return(RedirectToAction("ViewAssessment", "Instructor"));
            }
            catch (Exception e)
            {
                throw e;
            }
        }