예제 #1
0
        public ActionResult register(tbl_ClientValidation uv, string tabButton, HttpPostedFileBase imgInp)
        {
            try
            {
                Client c = new Client();
                int    latestclientid = 0;

                if (tabButton.Equals("next"))
                {
                    c.UserName = uv.UserName;
                    //c.FatherName = uv.FatherName;
                    c.CreatedOn       = DateTime.Now;
                    c.Email           = uv.Email;
                    c.Password        = uv.Password;
                    c.ConfirmPassword = uv.ConfirmPassword;
                    c.Cnic            = uv.Cnic;
                    c.Contact_No      = uv.Contact_No;
                    c.status          = 1;

                    c.Gender = uv.Gender;
                    db.Clients.Add(c);
                    db.SaveChanges();
                    latestclientid            = c.UserId;
                    Session["Latestclientid"] = latestclientid;
                    //ViewBag.Message = "Data Submitted";


                    Session["btn"] = "1";
                }
                else if (tabButton.Equals("finish"))
                {
                    if (imgInp != null)
                    {
                        string filename  = Path.GetFileNameWithoutExtension(imgInp.FileName);
                        string extension = Path.GetExtension(imgInp.FileName);
                        filename = DateTime.Now.ToString("yymmssff") + extension;
                        //c.Image = "~/Content/img/users/" + filename;

                        filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/ClientReg/"), filename);
                        imgInp.SaveAs(filename);

                        int id   = Convert.ToInt32(Session["Latestclientid"]);
                        var item = db.Clients.Single(x => x.UserId == id);



                        item.Image = "~/FrontEnd/Images/ClientReg/" + filename;
                        db.Clients.Attach(item);
                        db.Entry(item).Property(X => X.Image).IsModified = true;
                        db.SaveChanges();
                        ModelState.Clear();
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }
            return(View());
        }
예제 #2
0
        public ActionResult ProfileSetting(tbl_StudentValidation sa)
        {
            if (Session["Student"] == null)
            {
                return(RedirectToAction("Login", "Account", new { area = "" }));
            }
            try
            {
                tbl_StudentValidation student = new tbl_StudentValidation();
                int userid = Convert.ToInt32((Session["Student"]));

                var l = db.loginTables.FirstOrDefault(t => t.UserId == userid);

                if (ModelState.IsValid)
                {
                    if (sa.UserImageFIle != null)
                    {
                        if (l != null)
                        {
                            Session["StudentName"] = sa.Name;
                            l.UserId          = userid;
                            l.Name            = sa.Name;
                            l.Password        = sa.Password;
                            l.Email           = sa.Email;
                            l.RoleID          = 4;
                            db.Entry(l).State = EntityState.Modified;

                            db.SaveChanges();
                        }
                        string filename  = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName);
                        string extension = Path.GetExtension(sa.UserImageFIle.FileName);
                        filename = DateTime.Now.ToString("yymmssff") + extension;



                        student.Image    = "~/FrontEnd/Images/StudentImage/" + filename;
                        student.Name     = sa.Name;
                        student.Email    = sa.Email;
                        student.Password = sa.Password;
                        student.Id       = userid;



                        if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                        {
                            if (sa.UserImageFIle.ContentLength <= 1000000)
                            {
                                db.Entry(student).State = EntityState.Modified;



                                string oldImgPath = Request.MapPath(Session["imgPath"].ToString());

                                if (db.SaveChanges() > 0)
                                {
                                    filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/StudentImage/"), filename);
                                    sa.UserImageFIle.SaveAs(filename);
                                    if (System.IO.File.Exists(oldImgPath))
                                    {
                                        System.IO.File.Delete(oldImgPath);
                                    }


                                    ViewBag.Message = "Data Updated";
                                    return(RedirectToAction("ProfileSetting"));
                                }
                            }
                            else
                            {
                                ViewBag.msg = "File Size must be Equal or less than 1mb";
                            }
                        }
                        else
                        {
                            ViewBag.msg = "Inavlid File Type";
                        }
                    }

                    //}
                    else
                    {
                        student.Image = Session["imgPath"].ToString();
                        if (l != null)
                        {
                            Session["name"]   = sa.Name;
                            l.UserId          = userid;
                            l.Name            = sa.Name;
                            l.Password        = sa.Password;
                            l.Email           = sa.Email;
                            l.RoleID          = 4;
                            db.Entry(l).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        student.Name            = sa.Name;
                        student.Email           = sa.Email;
                        student.Password        = sa.Password;
                        student.Id              = userid;
                        db.Entry(student).State = EntityState.Modified;

                        if (db.SaveChanges() > 0)
                        {
                            ViewBag.Message = "Data Updated";
                            return(RedirectToAction("ProfileSetting"));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Updated";
                return(View());
            }
            return(View());
        }
        public ActionResult addteacher(tbl_TeacherValidation teacher)
        {
            try
            {
                int           schoolid = Convert.ToInt32(Session["school"]);
                ClassDBHandle gc       = new ClassDBHandle();

                List <tbl_ClassValidation> list = gc.GetClass(schoolid);
                ViewBag.school = new SelectList(list, "Class_Id", "Name");
                teacher.Reg_No = RegNo(teacher);

                digital_School.Models.Teacher a = new digital_School.Models.Teacher();

                var userWithSameEmail = db.Teachers.Where(m => m.Email == teacher.Email).SingleOrDefault(); //checking if the emailid already exits for any user
                if (userWithSameEmail == null)
                {
                    string filename  = Path.GetFileNameWithoutExtension(teacher.UserImageFIle.FileName);
                    string extension = Path.GetExtension(teacher.UserImageFIle.FileName);
                    filename = DateTime.Now.ToString("yymmssff") + extension;

                    a.Image = "~/FrontEnd/Images/TeacherImage/" + filename;
                    //image ko folder me save krwanay ke leye
                    filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/TeacherImage/"), filename);
                    teacher.UserImageFIle.SaveAs(filename);
                    a.Class_Id  = teacher.Class_Id;
                    a.School_Id = Convert.ToInt32(Session["school"]);
                    a.Name      = teacher.Name;
                    a.Reg_No    = teacher.Reg_No;
                    a.Address   = teacher.Address;
                    a.Email     = teacher.Email;
                    a.Contact   = teacher.Contact;
                    a.Password  = teacher.Password;

                    a.JoiningDate = DateTime.Now;

                    db.Teachers.Add(a);

                    db.SaveChanges();
                }

                else
                {
                    ViewBag.Message = "User with this Email Already Exist";
                    return(View());
                }


                int        teacherlatestid = a.Id;
                loginTable l = new loginTable();
                l.UserId   = teacherlatestid;
                l.Name     = a.Name;
                l.Password = a.Password;
                l.RoleID   = 3;
                l.Email    = a.Email;
                db.loginTables.Add(l);
                db.SaveChanges();
                ModelState.Clear();
                ViewBag.Message = "Data Submitted";
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }

            return(View());
        }
예제 #4
0
        public ActionResult ProfileSetting(tbl_schoolValidation sa)

        {
            School school = new School();

            try
            {
                //loginTable l = new loginTable();
                int userid = Convert.ToInt32((Session["school"]));

                var l = db.loginTables.FirstOrDefault(t => t.UserId == userid);

                //if (ModelState.IsValid)
                //{

                if (sa.UserImageFIle != null)
                {
                    if (l != null)
                    {
                        Session["schoolName"] = sa.School_Name;
                        l.UserId          = userid;
                        l.Name            = sa.School_Name;
                        l.Password        = sa.Password;
                        l.Email           = sa.School_Email;
                        l.RoleID          = 2;
                        db.Entry(l).State = EntityState.Modified;

                        db.SaveChanges();
                    }
                    string filename  = Path.GetFileNameWithoutExtension(sa.UserImageFIle.FileName);
                    string extension = Path.GetExtension(sa.UserImageFIle.FileName);
                    filename = DateTime.Now.ToString("yymmssff") + extension;



                    school.School_Address   = sa.School_Address;
                    school.School_Image     = "~/FrontEnd/Images/SchoolImage/" + filename;
                    school.School_Name      = sa.School_Name;
                    school.School_Contactno = sa.School_Contactno;

                    school.School_Email = sa.School_Email;
                    school.Password     = sa.Password;
                    school.School_Id    = userid;
                    school.CreatedOn    = Convert.ToDateTime(Session["DateCreated"]);



                    if (extension.ToLower() == ".jpg" || extension.ToLower() == ".jpeg" || extension.ToLower() == ".png")
                    {
                        if (sa.UserImageFIle.ContentLength <= 1000000)
                        {
                            db.Entry(school).State = EntityState.Modified;



                            string oldImgPath = Request.MapPath(Session["imgPath"].ToString());

                            if (db.SaveChanges() > 0)
                            {
                                filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/SchoolImage/"), filename);
                                sa.UserImageFIle.SaveAs(filename);
                                if (System.IO.File.Exists(oldImgPath))
                                {
                                    System.IO.File.Delete(oldImgPath);
                                }


                                ViewBag.Message = "Data Updated";
                                return(RedirectToAction("ProfileSetting"));
                            }
                        }
                        else
                        {
                            ViewBag.msg = "File Size must be Equal or less than 1mb";
                        }
                    }
                    else
                    {
                        ViewBag.msg = "Inavlid File Type";
                    }
                }

                //}
                else
                {
                    school.School_Image = Session["imgPath"].ToString();
                    if (l != null)
                    {
                        Session["schoolName"] = sa.School_Name;
                        l.UserId   = userid;
                        l.Name     = sa.School_Name;
                        l.Password = sa.Password;
                        l.Email    = sa.School_Email;

                        l.RoleID          = 2;
                        db.Entry(l).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                    school.School_Name      = sa.School_Name;
                    school.School_Email     = sa.School_Email;
                    school.Password         = sa.Password;
                    school.CreatedOn        = Convert.ToDateTime(Session["DateCreated"]);
                    school.School_Contactno = sa.School_Contactno;
                    school.School_Address   = sa.School_Address;
                    school.School_Id        = userid;
                    db.Entry(school).State  = EntityState.Modified;

                    if (db.SaveChanges() > 0)
                    {
                        ViewBag.Message = "Data Updated";
                        return(RedirectToAction("ProfileSetting"));
                    }
                }
            }


            catch (Exception ex)
            {
                ViewBag.Message = "Not Updated";
                return(View());
            }
            return(View());
        }
예제 #5
0
        public JsonResult addonlinetest(QuestionOptionViewModel QuestionOption)
        {
            int teacherid = Convert.ToInt32(Session["Teacher"]);

            int tempclassid;
            int schoolid;
            int originalclassid;
            var getteacherid = db.Teachers.Find(teacherid);

            tempclassid = getteacherid.Class_Id;
            var classid = db.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid.Class_Id;


            CourseDBHandle gc = new CourseDBHandle();

            List <tbl_CourseAssigntoTeacherValidation> list = gc.GetTeacherAssignedCourse(teacherid, originalclassid);

            ViewBag.course = new SelectList(list, "courseId", "courseName");
            OnlineTest q = new OnlineTest();

            q.Role_Id = Convert.ToInt32(Session["RoleId"]);
            q.UserId  = Convert.ToInt32(Session["Teacher"]);
            var getteachid = db.Teachers.Find(teacherid);

            schoolid   = getteachid.School_Id;
            q.SchoolId = schoolid;
            //OnlineTest test = new OnlineTest();
            q.CourseId     = QuestionOption.CourseId;
            q.QuestionName = QuestionOption.QuestionName;
            q.IsActive     = true;
            q.ClassId      = originalclassid;
            q.CreatedDate  = DateTime.Now;
            q.Duration     = "1 hour";
            q.IsMultiple   = false;
            db.OnlineTests.Add(q);
            db.SaveChanges();

            int questionId = q.QuestionId;

            foreach (var item in QuestionOption.ListOfOptions)
            {
                OnlineTestQuestionOption objoption = new OnlineTestQuestionOption();
                objoption.OptionName = item;
                objoption.QuestionId = questionId;
                db.OnlineTestQuestionOptions.Add(objoption);
                db.SaveChanges();
            }
            OnlineTestAnswer objanswer = new OnlineTestAnswer();

            objanswer.AnswerText = QuestionOption.AnswerText;
            objanswer.RoleId     = Convert.ToInt32(Session["RoleId"]);
            objanswer.UserId     = Convert.ToInt32(Session["Teacher"]);
            objanswer.SchoolId   = schoolid;



            objanswer.QuestionId = questionId;
            db.OnlineTestAnswers.Add(objanswer);
            db.SaveChanges();

            return(Json(new { message = "Data Successfully Added", success = true }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult uploadLecture(tbl_LectureValidation lec)
        {
            int teacherid = Convert.ToInt32(Session["Teacher"]);

            int tempclassid;
            int schoolid;
            int originalclassid;

            var getteacherid = db.Teachers.Find(teacherid);

            tempclassid = getteacherid.Class_Id;
            schoolid    = getteacherid.School_Id;
            var classid = db.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid.Class_Id;

            lec.SchoolId = schoolid;
            lec.ClassId  = originalclassid;
            CourseDBHandle gc = new CourseDBHandle();

            List <tbl_CourseAssigntoTeacherValidation> list = gc.GetTeacherAssignedCourse(teacherid, originalclassid);

            ViewBag.course = new SelectList(list, "courseId", "courseName");


            if (lec.UserdocFIle == null)
            {
                ModelState.AddModelError("CustomError", "Please Select File");
                return(View());
            }
            if (!(lec.UserdocFIle.ContentType == "application/pdf" || lec.UserdocFIle.ContentType == "application/pdf"))
            {
                ModelState.AddModelError("CustomError", "Select Doc or Pdf extention file only ");
                return(View());
            }

            try
            {
                Lecture teaclecture = new Lecture();

                string fileName = Guid.NewGuid() + Path.GetExtension(lec.UserdocFIle.FileName);
                lec.UserdocFIle.SaveAs(Path.Combine(Server.MapPath("~/FrontEnd/File_upload/Lecture/"), fileName));

                teaclecture.LectureUrl          = fileName;
                teaclecture.Lecturename         = lec.Lecturename;
                teaclecture.CourseId            = lec.CourseId;
                teaclecture.ClassId             = lec.ClassId;
                teaclecture.CreatedDate         = DateTime.Now;
                teaclecture.Lecture_Description = lec.Lecture_Description;
                teaclecture.SchoolId            = lec.SchoolId;
                teaclecture.VideoLink           = lec.VideoLink;
                teaclecture.UserId = Convert.ToInt32(Session["Teacher"]);

                db.Lectures.Add(teaclecture);

                db.SaveChanges();

                ModelState.Clear();


                ViewBag.Message = "Data Submitted";
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }



            return(View());
        }
        public ActionResult addtestfile(tbl_TestFileValidation tfile)
        {
            int teacherid = Convert.ToInt32(Session["Teacher"]);

            int tempclassid;
            int schoolid;
            int originalclassid;

            var getteacherid = db.Teachers.Find(teacherid);

            tempclassid = getteacherid.Class_Id;
            schoolid    = getteacherid.School_Id;
            var classid = db.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid.Class_Id;
            CourseDBHandle gc = new CourseDBHandle();

            tfile.SchoolId = schoolid;
            tfile.ClassId  = originalclassid;
            List <tbl_CourseAssigntoTeacherValidation> list = gc.GetTeacherAssignedCourse(teacherid, originalclassid);

            ViewBag.course = new SelectList(list, "courseId", "courseName");


            if (tfile.UserdocFIle == null)
            {
                ModelState.AddModelError("CustomError", "Please Select File");
                return(View());
            }
            if (!(tfile.UserdocFIle.ContentType == "application/msword" || tfile.UserdocFIle.ContentType == "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || tfile.UserdocFIle.ContentType == "application/pdf"))
            {
                ViewBag.Message = "Select  doc or Docx Pdf extention file only ";
                return(View());
            }

            try
            {
                ManualTest mantestfile = new ManualTest();

                string fileName = Guid.NewGuid() + Path.GetExtension(tfile.UserdocFIle.FileName);
                tfile.UserdocFIle.SaveAs(Path.Combine(Server.MapPath("~/FrontEnd/File_Upload/ManualTest/"), fileName));


                mantestfile.TestUrl     = fileName;
                mantestfile.CourseId    = tfile.CourseId;
                mantestfile.ClassId     = tfile.ClassId;
                mantestfile.CreatedDate = DateTime.Now;
                mantestfile.Duration    = tfile.Duration;
                mantestfile.SchoolId    = tfile.SchoolId;
                mantestfile.UserId      = Convert.ToInt32(Session["Teacher"]);



                db.ManualTests.Add(mantestfile);
                db.SaveChanges();


                ModelState.Clear();

                ViewBag.Message = "Data Submitted";
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }



            return(View());
        }
        public ActionResult assignment(tbl_AssignmentValidation a)
        {
            int teacherid = Convert.ToInt32(Session["Teacher"]);

            int tempclassid;
            int schoolid;
            int originalclassid;

            var getteacherid = db.Teachers.Find(teacherid);

            tempclassid = getteacherid.Class_Id;
            schoolid    = getteacherid.School_Id;
            var classid = db.Tbl_Class.Where(x => x.Class_Id == tempclassid).SingleOrDefault();

            originalclassid = classid.Class_Id;

            a.SchoolId = schoolid;
            a.ClassId  = originalclassid;
            CourseDBHandle gc = new CourseDBHandle();

            List <tbl_CourseAssigntoTeacherValidation> list = gc.GetTeacherAssignedCourse(teacherid, originalclassid);

            ViewBag.course = new SelectList(list, "courseId", "courseName");


            if (a.UserdocFIle == null)
            {
                ModelState.AddModelError("CustomError", "Please Select File");
                return(View());
            }
            if (!(a.UserdocFIle.ContentType == "application/pdf" || a.UserdocFIle.ContentType == "application/pdf"))
            {
                ModelState.AddModelError("CustomError", "Select Doc or Pdf extention file only ");
                return(View());
            }

            try
            {
                SchoolAssignment scassignemnt = new SchoolAssignment();


                string fileName = Guid.NewGuid() + Path.GetExtension(a.UserdocFIle.FileName);
                a.UserdocFIle.SaveAs(Path.Combine(Server.MapPath("~/FrontEnd/File_Upload/Assignment/"), fileName));

                scassignemnt.AssignmentUrl  = fileName;
                scassignemnt.AssignmentName = a.AssignmentName;
                scassignemnt.CourseId       = a.CourseId;
                scassignemnt.ClassId        = a.ClassId;
                scassignemnt.CreatedDate    = DateTime.Now;
                scassignemnt.Duration       = a.Duration;
                scassignemnt.SchoolId       = a.SchoolId;
                scassignemnt.UserId         = Convert.ToInt32(Session["Teacher"]);

                db.SchoolAssignments.Add(scassignemnt);

                db.SaveChanges();

                ModelState.Clear();


                ViewBag.Message = "Data Submitted";
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }



            return(View());
        }
예제 #9
0
        public ActionResult addstudent(tbl_StudentValidation s)
        {
            try
            {
                int           schoolid = Convert.ToInt32(Session["school"]);
                ClassDBHandle gc       = new ClassDBHandle();

                List <tbl_ClassValidation> list = gc.GetClass(schoolid);
                ViewBag.schoolclass = new SelectList(list, "Class_Id", "Name");
                SectionDBHandle section = new SectionDBHandle();
                List <tbl_SectionValidation> sectionlist = section.GetSection(schoolid);
                ViewBag.schoolsection = new SelectList(sectionlist, "SectionID", "SectionName");


                digital_School.Models.Student a = new digital_School.Models.Student();
                var userWithSameEmail           = db.Students.Where(m => m.Email == s.Email).SingleOrDefault(); //checking if the emailid already exits for any user
                if (userWithSameEmail == null)
                {
                    s.RegNo = StudentRegNo(s, s.Name);

                    string filename  = Path.GetFileNameWithoutExtension(s.UserImageFIle.FileName);
                    string extension = Path.GetExtension(s.UserImageFIle.FileName);
                    filename = DateTime.Now.ToString("yymmssff") + extension;

                    a.ImagePath = "~/FrontEnd/Images/StudentImage/" + filename;
                    //image ko folder me save krwanay ke leye
                    filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/StudentImage/"), filename);
                    s.UserImageFIle.SaveAs(filename);
                    a.Class_Id   = s.Class_Id;
                    a.Section_Id = s.Section_Id;
                    a.School_Id  = Convert.ToInt32(Session["school"]);
                    a.Name       = s.Name;
                    a.RegNo      = s.RegNo;
                    a.Address    = s.Address;
                    a.Email      = s.Email;
                    a.ContactNo  = s.ContactNo;
                    a.Password   = s.Password;

                    a.RegisterationDate = DateTime.Now;

                    db.Students.Add(a);
                    db.SaveChanges();
                }

                else
                {
                    ViewBag.Message = "User with this Email Already Exist";
                    return(View());
                }

                int        studentlatestid = a.Id;
                loginTable l = new loginTable();
                l.UserId   = studentlatestid;
                l.Name     = a.Name;
                l.Password = a.Password;
                l.RoleID   = 4;
                l.Email    = a.Email;
                db.loginTables.Add(l);
                db.SaveChanges();
                ModelState.Clear();
                ViewBag.Message = "Data Submitted";
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }
            return(View());
        }