Example #1
0
 public ActionResult announcementcrud(SearchViewModel collection)
 {
     try
     {
         DB41Entities db = new DB41Entities();
         List <AnnouncementViewModel> list = new List <AnnouncementViewModel>();
         var    dblist = db.CourseAnnounments.ToList();
         string a      = collection.Type1;
         var    Id     = db.Courses
                         .Where(x => x.Title == a)
                         .Select(x => x.CourseID)
                         .FirstOrDefault();
         foreach (var i in dblist)
         {
             if (i.CourseID == Id)
             {
                 AnnouncementViewModel mp = new AnnouncementViewModel();
                 mp.Title  = i.Title;
                 mp.Detail = i.Details;
                 mp.Course = a;
                 mp.ID     = Convert.ToString(i.AnnouncementId);
                 list.Add(mp);
             }
         }
         return(View(list));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public ActionResult CourseDetails(int id)
        {
            DB41Entities    db   = new DB41Entities();
            CourseViewModel m    = new CourseViewModel();
            var             list = db.Courses.ToList();

            foreach (var i in list)
            {
                if (i.CourseID == id)
                {
                    m.Title           = i.Title;
                    m.Start_date      = i.Starttime;
                    m.Fee             = i.Fee;
                    m.Course_duration = i.Duration;
                    m.Department      = i.Department;
                    var Id = db.Instructors
                             .Where(x => x.InstructorID == i.InstructorID)
                             .Select(x => x.Name)
                             .FirstOrDefault();
                    m.Instructor = Id;
                }
            }



            return(View(m));
        }
Example #3
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;
            }
        }
Example #4
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 }));
        }
Example #5
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;
            }
        }
        public ActionResult announcementcrud(SearchViewModel collection)
        {
            DB41Entities db = new DB41Entities();
            List <AnnouncementViewModel> list = new List <AnnouncementViewModel>();
            var dblist = db.CourseAnnounments.ToList();

            foreach (var i in dblist)
            {
                AnnouncementViewModel mp = new AnnouncementViewModel();
                mp.Title  = i.Title;
                mp.Detail = i.Detail;
                mp.Course = Convert.ToString(i.CourseID);
                list.Add(mp);
            }
            return(View(list));
        }
Example #7
0
 public ActionResult Login(StudentViewModel objUser, SearchViewModel se)
 {
     if (ModelState.IsValid)
     {
         using (DB41Entities db = new DB41Entities())
         {
             var obj = db.Students.Where(a => a.Email.Equals(objUser.Email) && a.Password.Equals(objUser.Password) && a.Department.Equals(se.Type)).FirstOrDefault();
             if (obj != null)
             {
                 Session["UserID"]   = obj.StudentID.ToString();
                 Session["UserName"] = obj.Name.ToString();
                 return(RedirectToAction("Index"));
             }
         }
     }
     return(View(objUser));
 }
Example #8
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());
            }
        }
Example #9
0
        public ActionResult ViewAssessment()
        {
            DB41Entities      db   = new DB41Entities();
            List <Assessment> list = new List <Assessment>();
            var dblist             = db.Questions.ToList();

            foreach (var i in dblist)
            {
                Assessment mp = new Assessment();
                mp.Detail       = i.Name;
                mp.Marks        = i.Marks;
                mp.Id           = i.QuestionID;
                mp.Department   = i.Department;
                mp.InstructorId = i.InstructorID;
                list.Add(mp);
            }

            return(View(list));
        }
        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;
            }
        }
Example #11
0
        public ActionResult StudentCrud(SearchViewModel collection)
        {
            DB41Entities            db   = new DB41Entities();
            List <StudentViewModel> list = new List <StudentViewModel>();
            var dblist = db.Students.ToList();

            foreach (var i in dblist)
            {
                StudentViewModel mp = new StudentViewModel();
                mp.Name       = i.Name;
                mp.CNIC       = i.CNIC;
                mp.Email      = i.Email;
                mp.Address    = i.Address;
                mp.Department = i.Department;


                list.Add(mp);
            }
            return(View(list));
        }
Example #12
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;
     }
 }
Example #14
0
        public ActionResult instructorcrud(SearchViewModel collection)
        {
            DB41Entities db = new DB41Entities();
            List <InstructorViewModel> list = new List <InstructorViewModel>();
            var dblist = db.Instructors.ToList();

            foreach (var i in dblist)
            {
                if (i.Department == collection.Type)
                {
                    InstructorViewModel mp = new InstructorViewModel();
                    mp.Fullname    = i.Name;
                    mp.Cnic        = i.CNIC;
                    mp.EmailiD     = i.Email;
                    mp.Homeaddress = i.Address;
                    mp.Department  = i.Department;
                    mp.Phonenumber = i.PhoneNumber;
                    mp.Salary      = i.Salary;
                    list.Add(mp);
                }
            }
            return(View(list));
        }
Example #15
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;
     }
 }
Example #16
0
        public ActionResult coursecrud(SearchViewModel collection)
        {
            DB41Entities           db   = new DB41Entities();
            List <CourseViewModel> list = new List <CourseViewModel>();
            var dblist = db.Courses.ToList();

            foreach (var i in dblist)
            {
                if (i.Department == collection.Type)
                {
                    CourseViewModel mp = new CourseViewModel();
                    mp.Title           = i.Title;
                    mp.Start_date      = i.Starttime;
                    mp.Course_duration = i.Duration;
                    mp.Fee             = i.Fee;
                    mp.Department      = i.Department;


                    list.Add(mp);
                }
            }
            return(View(list));
        }
        public ActionResult Login(StudentViewModel objUser, SearchViewModel se)
        {
            if (ModelState.IsValid)
            {
                using (DB41Entities db = new DB41Entities())
                {
                    var obj = db.Students.Where(a => a.Email.Equals(objUser.Email) && a.Password.Equals(objUser.Password) && a.Department.Equals(se.Type)).FirstOrDefault();
                    if (obj != null)
                    {
                        Session["UserID"]   = obj.StudentID.ToString();
                        Session["UserName"] = obj.Name.ToString();
                        return(RedirectToAction("ViewAllCourses"));
                    }
                    else
                    {
                        IdentityMessage m = new IdentityMessage();
                        m.Body = "Please Enter register yourself";
                    }
                }
            }

            return(View(objUser));
        }
Example #18
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;
            }
        }
Example #19
0
        //public ActionResult Showpaper()
        //{
        //    return View();
        //}

        public ActionResult Showpaper(int id)
        {
            DB41Entities db     = new DB41Entities();
            List <MCQ_S> list   = new List <MCQ_S>();
            var          dblist = db.QuestionPapers.ToList();

            foreach (var i in dblist)
            {
                if (i.QuestionID == id)
                {
                    MCQ_S mp = new MCQ_S();
                    mp.Title   = i.Title;
                    mp.Option1 = i.Option2;

                    mp.Option2 = i.Option2;
                    mp.Option3 = i.Option3;
                    mp.Option4 = i.Option4;

                    list.Add(mp);
                }
            }

            return(View(list));
        }
        public ActionResult ViewAllCourses(SearchViewModel collection)
        {
            try
            {
                DB41Entities           db   = new DB41Entities();
                List <CourseViewModel> list = new List <CourseViewModel>();
                var dblist = db.Courses.ToList();
                foreach (var i in dblist)
                {
                    if (i.Department == collection.Type)
                    {
                        CourseViewModel mp = new CourseViewModel();

                        mp.CourseId        = i.CourseID;
                        mp.Title           = i.Title;
                        mp.Start_date      = i.Starttime;
                        mp.Course_duration = i.Duration;
                        mp.Fee             = i.Fee;
                        mp.Department      = i.Department;
                        var Id = db.Instructors
                                 .Where(x => x.InstructorID == i.InstructorID)
                                 .Select(x => x.Name)
                                 .FirstOrDefault();
                        mp.Instructor = Id;


                        list.Add(mp);
                    }
                }
                return(View(list));
            }
            catch (Exception e)
            {
                throw e;
            }
        }