예제 #1
0
        public ActionResult viewonlinetest(int courseId)
        {
            loginTable objuser = new loginTable();

            //Session["SName"] = userName;
            Session["CourseId"] = courseId;

            return(View("ShowQuestion"));
        }
예제 #2
0
        public ActionResult AddSchool(tbl_schoolValidation school)
        {
            try
            {
                digital_School.Models.School a = new digital_School.Models.School();

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

                    a.School_Image = "~/FrontEnd/Images/SchoolImage/" + filename;
                    //image ko folder me save krwanay ke leye
                    filename = Path.Combine(Server.MapPath("~/FrontEnd/Images/SchoolImage/"), filename);
                    school.UserImageFIle.SaveAs(filename);
                    a.School_Name      = school.School_Name;
                    a.School_Address   = school.School_Address;
                    a.School_Email     = school.School_Email;
                    a.School_Contactno = school.School_Contactno;
                    a.Password         = school.Password;

                    a.CreatedOn = DateTime.Now;

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

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


                int        schoollatestid = a.School_Id;
                loginTable l = new loginTable();
                l.UserId   = schoollatestid;
                l.Name     = a.School_Name;
                l.Password = a.Password;
                l.RoleID   = 2;
                l.Email    = a.School_Email;
                db.loginTables.Add(l);
                db.SaveChanges();
                ModelState.Clear();
                ViewBag.Message = "Data Submitted";

                return(View());
            }
            catch (Exception ex)
            {
                ViewBag.Message = "Not Submitted";
                return(View());
            }
        }
        public ActionResult viewonlinetest(int courseId)
        {
            if (Session["Cliente"] == null)
            {
                return(RedirectToAction("login", "Home", new { area = "" }));
            }
            loginTable objuser = new loginTable();

            //Session["SName"] = userName;
            Session["CourseId"] = courseId;

            return(View("ShowQuestion"));
        }
예제 #4
0
        public ActionResult Login(tbl_LoginTableValidation k)
        {
            loginTable u = new loginTable();


            if (k != null)
            {
                u.Email    = k.Email;
                u.Password = k.Password;

                var x = db.loginTables.Where(a => a.Email == u.Email && a.Password == u.Password).SingleOrDefault();
                if (x == null)
                {
                    ViewBag.ErrorMessage = "Login Failed";
                    return(View());
                }
                else
                {
                    if (x.RoleID == 1)
                    {
                        var data = db.SuperAdmins.Find(x.UserId);
                        Session["imgPath"] = data.ad_imageurl;
                        Session["Ad"]      = x.UserId;
                        Session["name"]    = x.Name;
                        Session["RoleId"]  = x.RoleID;
                        return(RedirectToAction("Index", "Home", new { Area = "SuperAdmin" }));
                    }
                    else if (x.RoleID == 2)
                    {
                        var data = db.Schools.Find(x.UserId);
                        Session["imgPath"]    = data.School_Image;
                        Session["school"]     = x.UserId;
                        Session["schoolName"] = x.Name;
                        Session["RoleId"]     = x.RoleID;
                        return(RedirectToAction("Index", "Home", new { Area = "Principle" }));
                    }
                    else if (x.RoleID == 3)
                    {
                        var data = db.Teachers.Find(x.UserId);
                        Session["imgPath"]     = data.Image;
                        Session["Teacher"]     = x.UserId;
                        Session["TeacherName"] = x.Name;
                        Session["RoleId"]      = x.RoleID;
                        return(RedirectToAction("Index", "Home", new { Area = "Teacher" }));
                    }
                    else if (x.RoleID == 4)
                    {
                        var data = db.Students.Find(x.UserId);
                        Session["imgPath"]     = data.ImagePath;
                        Session["Student"]     = x.UserId;
                        Session["StudentName"] = x.Name;
                        Session["RoleId"]      = x.RoleID;
                        return(RedirectToAction("Index", "Home", new { Area = "Student" }));
                    }

                    else if (x.RoleID == 5)
                    {
                        var data = db.Clients.Find(x.UserId);
                        Session["imgPath"]    = data.Image;
                        Session["Cliente"]    = x.UserId;
                        Session["ClientName"] = x.Name;
                        Session["RoleId"]     = x.RoleID;
                        return(RedirectToAction("dashboard", "Home", new { Area = "Cliente" }));
                    }
                }
            }
            else
            {
                return(View("Index"));
            }



            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());
        }
        public ActionResult addstudent(edu_course.Models.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");


                edu_course.Models.Student a = new edu_course.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 = "~/Content/img/users/" + filename;
                    //image ko folder me save krwanay ke leye
                    filename = Path.Combine(Server.MapPath("~/Content/img/users/"), 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());
        }