예제 #1
0
 public ActionResult Index()
 {
     
     var model = new ProjectModel();
     ViewBag.href = "/Project/Index/?course=";
     if (Request.Params[COURSE] != null)
     {
         ViewBag.href += Request.Params[COURSE] + "&year=";
         if (Request.Params[YEAR] != null)
         {
             ViewBag.href += Request.Params[YEAR] + "&homework=";
             if (Request.Params[HOMEWORK] != null)
             {
                 ViewBag.href = "/Project/Info/?" + COURSE + "=" + Request.Params[COURSE] + "&" + YEAR + "=" + Request.Params[YEAR] + "&" + HOMEWORK + "=" + Request.Params[HOMEWORK]+"&"+STUDENT+"=";
                 ViewBag.data = model.getAllProjectStudent(Request.Params[COURSE], Request.Params[YEAR], Request.Params[HOMEWORK]);
                 
             }
             else
             {
                 
                 ViewBag.data = model.getAllHomeWork(Request.Params[COURSE], Request.Params[YEAR]);
             }
         }
         else
         {
             
             ViewBag.data = model.getAllYears(Request.Params[COURSE]);
         }
     }
     else
     {
         ViewBag.data = model.getAllCources();
     }
     return View();
 }
예제 #2
0
 public ActionResult Project()
 {
     if (loginStatus() == false)
     {
         return Redirect("Login");
     }
     var model = new ProjectModel();
     ViewBag.Course = model.getAllCources();
     ViewBag.Years = model.getDistinctYears();
     ViewBag.Homeworks = model.getDistinctHomeWork();
     return View();
 }
예제 #3
0
        public ActionResult GetProject()
        {
            if (loginStatus() == false)
            {
                return Redirect("Login");
            }
            var root = new Dictionary<string, object>();
            var id = Request["id"];
            
            if (id == null)
            {
                return Json(root);
            }
            var dataArray = id.Split('_');
            var model = new ProjectModel();
            var list = new List<Dictionary<string, object>>();
            if (dataArray.Length == 1) //get course
            {
                
                var course = model.getAllCources();
                foreach (var c in course)
                {

                    Dictionary<string, object> node = new Dictionary<string, object>();
                    node.Add("text", c);
                    node.Add("id", string.Format("course_{0}",c));
                    node.Add("children",true);
                    list.Add(node);
                }
                root.Add("text", "PROJECT");
                root.Add("children", list);
                

            }
            else if (dataArray.Length == 2)//get year by course
            {
               var years =  model.getAllYears(dataArray[1]);
               foreach (var y in years)
               {
                   Dictionary<string, object> node = new Dictionary<string, object>();
                    node.Add("text", y);
                    node.Add("id", string.Format("course_{0}_{1}",dataArray[1],y));
                    node.Add("children",true);
                    list.Add(node);
               }
               return Json(list);
            }
            else if (dataArray.Length == 3)//get homework by course and year
            {
                var homeworks = model.getAllHomeWork(dataArray[1], dataArray[2]);
                foreach (var h in homeworks)
                {
                    Dictionary<string, object> node = new Dictionary<string, object>();
                    node.Add("text", h);
                    node.Add("id", string.Format("course_{0}_{1}_{2}", dataArray[1],dataArray[2], h));
                    node.Add("children", true);
                    list.Add(node);
                    
                }
                return Json(list);

            }
            else if(dataArray.Length==4)//get 
            {
                var students = model.getAllProjectStudent(dataArray[1], dataArray[2], dataArray[3]);
                foreach (var s in students)
                {
                    Dictionary<string, object> node = new Dictionary<string, object>();
                    node.Add("text", s);
                    node.Add("id", string.Format("course_{0}_{1}_{2}_{3}", dataArray[1], dataArray[2],dataArray[3], s));
                    //node.Add("children", true);
                    list.Add(node);

                }
                return Json(list);


            }



            return Json(root);
            
        }