Пример #1
0
        //

        // GET: /SQ/

        public ActionResult Index(ChooseTypeModel model)
        {
            //Return path of Views part to count files
            string path   = HttpContext.Server.MapPath("");
            string RePath = path.Replace("SQ\\Index", "Views\\SQ");
            int    fCount = Directory.GetFiles(RePath, "*", SearchOption.TopDirectoryOnly).Length;

            System.Diagnostics.Debug.WriteLine(fCount);
            Random rdm     = new Random();
            int    rdmView = rdm.Next(fCount) + 1;

            //print to output for test
            System.Diagnostics.Debug.WriteLine(rdmView);
            System.Diagnostics.Debug.WriteLine(model.HoTen);
            System.Diagnostics.Debug.WriteLine(model.ID);
            //choose random action
            string rdmAction = "SQ_" + rdmView;

            //return RedirectToAction(rdmAction);
            SessionHelper.SetSession(new UserSession()
            {
                UserName = model.HoTen, ID = model.ID, DeSo = rdmView
            });
            //Session.Add("ID", model.ID);
            //Session.Add("DeSo", rdmView);

            return(RedirectToAction(rdmAction));
        }
Пример #2
0
        //
        // GET: /ChooseType/

        public ActionResult ChooseType()
        {
            var tp = "SQ";
            // Let's get all type that we need for a DropDownList
            var type = GetAllType();
            var name = GetAllName(tp);

            var model = new ChooseTypeModel();

            // Create a list of SelectListItems so these can be rendered on the page
            model.Type = GetSelectListItems(type);
            model.Name = GetSelectListItems(name);


            return(View("ChooseType", model));
        }
        //

        // GET: /Individual/

        public ActionResult Index(ChooseTypeModel model)
        {
            //Return path of Views part to count files

            System.Diagnostics.Debug.WriteLine(model.HoTen);
            System.Diagnostics.Debug.WriteLine(model.ID);

            //get Indicidual action
            int    number    = IndividualExamNumber(model.ID);
            string rdmAction = "Individual_" + number;

            //return RedirectToAction(rdmAction);
            SessionHelper.SetSession(new UserSession()
            {
                UserName = model.HoTen, ID = model.ID, DeSo = number
            });

            return(RedirectToAction(rdmAction));
        }
Пример #4
0
        public ActionResult ChooseType(ChooseTypeModel model)
        {
            var tp = model.ThanhPhan;
            //Get all type again
            var type = GetAllType();
            var name = GetAllName(tp);

            ;
            // Set these type on the model. We need to do this because
            // only the selected value from the DropDownList is posted back, not the whole
            // list of types.
            model.Type = GetSelectListItems(type);
            model.Name = GetSelectListItems(name);

            var id = GetID(model.HoTen, tp);

            model.ID = id;
            //var permission = new PermissionModel();
            var check_1 = checkPermission(id);

            if (check_1 == 1)
            {
                ViewData["check"] = 1;
                //permission.SetLogStatus(id);
            }
            else
            {
                ViewData["check"] = 0;
                return(View("ChooseType", model));
            }

            var check_2 = checkIndividualExam(id);

            if (check_2 == 1)
            {
                // do nothing
                System.Diagnostics.Debug.WriteLine("normal");
            }
            else
            {
                model.ThanhPhan = "DeRieng";
                System.Diagnostics.Debug.WriteLine(model.ThanhPhan);
            }

            // In case everything is fine - i.e. both "Name" and "Type" are entered/selected,
            // redirect user to the "Target" page, and pass the user object along via Session
            if (model.ThanhPhan == "DeRieng")
            {
                return(RedirectToAction("Index", "Individual", model));
            }
            else if (model.ThanhPhan == "SQ")
            {
                return(RedirectToAction("Index", "SQ", model));
            }
            else if (model.ThanhPhan == "QNCN")
            {
                return(RedirectToAction("Index", "QNCN", model));
            }
            else if (model.ThanhPhan == "HSQ")
            {
                return(RedirectToAction("Index", "HSQ", model)); // focus on this
            }
            else
            {
                return(View());
            }
        }