Ejemplo n.º 1
0
        public ActionResult SaveOrUpdate(ExamEntities Examentities)
        {
            ExamBL Exambl         = new ExamBL();
            int    recordAffected = Exambl.SaveOrUpdateExam(Examentities);

            return(Json(recordAffected, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        //for GetExamForDrp drp
        public void GetExamForDrp()
        {
            ExamBL examBL = new ExamBL();
            List <ExamEntities> pocoList = new List <ExamEntities>();

            pocoList = examBL.GetExamForDrp();

            List <ExamEntities> itmasterList = new List <ExamEntities>();

            foreach (ExamEntities up in pocoList)
            {
                ExamEntities unt = new ExamEntities();
                unt.ExamID   = up.ExamID;
                unt.ExamName = up.ExamName;

                itmasterList.Add(unt);
            }

            ViewBag.Exam = itmasterList.Select(x =>
                                               new SelectListItem()
            {
                Text  = x.ExamName,
                Value = x.ExamID.ToString()
            });
        }
Ejemplo n.º 3
0
        public List <ExamEntities> GetAllExam()
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("stpGetExamAll", con);

            cmd.CommandType = CommandType.StoredProcedure;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            List <ExamEntities> ExamList = new List <ExamEntities>();
            ExamEntities        exam     = new ExamEntities();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ExamList.Add(new ExamEntities
                {
                    ID       = Convert.ToInt32(dr["ID"].ToString()),
                    ExamName = Convert.ToString(dr["ExamName"]),
                });
            }
            con.Close();
            return(ExamList);
        }
Ejemplo n.º 4
0
        public ActionResult LoginStudent(Student model)
        {
            if (ModelState.IsValid)
            {
                string oldpassword = model.passwod;
                model.passwod = Encryptor.MD5Hash(oldpassword);

                using (var context = new ExamEntities())
                {
                    Student user = context.Students
                                   .Where(u => u.email == model.email && u.passwod == model.passwod)
                                   .FirstOrDefault();

                    if (user != null)
                    {
                        Session["rule"]     = user.rule;
                        Session["UserName"] = user.name;
                        Session["UserId"]   = user.ST_id;
                        return(RedirectToAction("StudentPage", "Students"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Invalid User Name or Password");
                        return(View(model));
                    }
                }
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 5
0
        public ExamEntities GetExamByID(int ExamID)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("stpGetExamByExamID", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@ID", ExamID);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            con.Close();
            ExamEntities Exam = new ExamEntities();

            Exam.ID       = Convert.ToInt32(ds.Tables[0].Rows[0]["ID"].ToString());
            Exam.ExamName = Convert.ToString(ds.Tables[0].Rows[0]["ExamName"]);
            return(Exam);
        }
Ejemplo n.º 6
0
        public int SaveOrUpdateExam(ExamEntities exam)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["SchoolDBConnectionString"].ConnectionString);

            con.Open();
            SqlCommand cmd = new SqlCommand("stpInsertUpdateExam", con);

            cmd.CommandType = CommandType.StoredProcedure;
            if (String.IsNullOrEmpty(exam.ID.ToString()) || (exam.ID == 0))
            {
                cmd.Parameters.AddWithValue("@ID", DBNull.Value);
            }
            else
            {
                cmd.Parameters.AddWithValue("@ID", exam.ID);
            }
            cmd.Parameters.AddWithValue("@ExamName", exam.ExamName);

            int recordAffected = cmd.ExecuteNonQuery();

            con.Close();
            return(recordAffected);
        }
Ejemplo n.º 7
0
        public ActionResult Instructions(string check)
        {
            if (Session["st_id"] == null)
            {
                return(RedirectToAction("Index"));
            }
            TempData["totalQues"] = 0;
            List <QuesCategory> lis = db.QuesCategories.ToList();
            var         prf         = db.Profiles.Where(x => x.Status == 1).FirstOrDefault();
            List <Exam> ls          = db.Exams.Where(x => x.ProfileId == prf.Id).ToList();

            if (check != null)
            {
                Queue <Question> queue = new Queue <Question>();

                foreach (var quesCat in ls)
                {
                    if (quesCat.CheckBox == true)
                    {
                        int k = Convert.ToInt32(quesCat.NoOfQues);
                        int i = 1;
                        //   List<Question> list = db.Questions.Where(x => x.QuesCategoryId == quesCat.Id).ToList();
                        foreach (var cat in lis)
                        {
                            if (cat.Name == quesCat.Category)
                            {
                                using (var ctx = new ExamEntities())
                                {
                                    var questionList = ctx.Questions.SqlQuery("Select * from Questions where QuesCategoryId=" + cat.Id + " ").Distinct().OrderBy(x => Guid.NewGuid()).ToList();


                                    foreach (Question a in questionList)
                                    {
                                        if (i <= k)
                                        {
                                            queue.Enqueue(a);
                                            i++;
                                            TempData["totalQues"] = Convert.ToInt32(TempData["totalQues"]) + 1;
                                        }
                                        else
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                TempData["questions"] = queue;
                TempData["score"]     = 0;
                TempData["Indi"]      = "";
                TempData["i"]         = 0;
                TempData["sc1"]       = null;
                TempData["sc2"]       = null;
                TempData["sc3"]       = null;
                TempData["attempt"]   = 0;
                TempData["ExamName"]  = prf.Name;
                // for(int i = 1; i < queue.Count; i++)
                // {
                //    TempData["sl"] = i;
                //}
                TempData.Keep();


                return(RedirectToAction("Ncat"));
            }
            else
            {
                ViewBag.error = "Kindly Check the box";
            }
            return(View());
        }
Ejemplo n.º 8
0
 public BaseService(ExamEntities dataContext)
 {
     this.dataContext = dataContext;
     dbSet            = dataContext.Set <T>();
 }
Ejemplo n.º 9
0
        public int SaveOrUpdateExam(ExamEntities Exam)
        {
            ExamDAL ExamDl = new ExamDAL();

            return(ExamDl.SaveOrUpdateExam(Exam));
        }
        protected override bool AuthorizeCore(HttpContextBase httpContext)
        {
            
            bool authorize = false;
            var userId = Convert.ToInt32(httpContext.Session["UserId"]);
            var username = Convert.ToString(httpContext.Session["UserName"]);
            var user_rule = (string)httpContext.Session["rule"];
            if (!string.IsNullOrEmpty(username) && userId != 0)
            {
            
                using (var context = new ExamEntities())
                {
                  //  string rule="" ;
                  //  if (user_rule == "student")
                  //  { var userRole = context.Students.Where(m => m.ST_id == userId).FirstOrDefault();
                  //      rule = userRole.rule;
                  //  }
                  //else if (user_rule == "professor")
                  //  {
                  //      var userRole = context.Professors.Where(m => m.P_id == userId).FirstOrDefault();
                  //      rule = userRole.rule;
                  //  }
                  // else if (user_rule == "admin")
                  //  { var userRole = context.Admins.Where(m => m.A_id == userId).FirstOrDefault();
                  //      rule = userRole.rule;
                  //  }




                    //       var userRole = (from u in context.ST_Rules
                    //                       join r in context.Rules on u.R_id equals r.id
                    //                       where u.ST_id == userId
                    //                       select new
                    //                       {
                    //                           r.title
                    //                       }).ToList();
                    
                    foreach (var role in allowedroles)
                    {

                        if (role == user_rule)
                        {
                            if(user_rule=="student")
                            {
                                var user = context.Students.Single(d => d.ST_id == userId);
                                if (user.approval == true)
                                { return true; }
                            }

                            else if(user_rule=="professor")
                            {
                                var user = context.Professors.Single(n => n.P_id == userId);
                                if (user.approval == true)
                                { return true; }
                            }
                            else if (user_rule=="admin")
                            {
                                return true;
                            }
                            else { return false; }
                             }
                       
                    }
                  



                }
            }





            return authorize;
        }
Ejemplo n.º 11
0
 public ExamDatabaseService(ExamEntities dataContext) : base(dataContext)
 {
 }