示例#1
0
        public ActionResult RegisterSubject(string Id_Class, string Id_Subject, string Id_Teacher, int Year_Term)
        {
            if (Session["student_subject"] == null)
            {
                var gv            = TeacherAction.GetAll();
                var mh            = SubjectAction.GetAll();
                var lop           = ClassAction.GetAll();
                var nam           = YearTermAction.GetAll();
                var teacher_info  = gv.Find(a => a.id == Id_Teacher);
                var subject_infor = mh.Find(a => a.id == Id_Subject);
                var class_info    = lop.Find(a => a.id == Id_Class);
                var year_info     = nam.Find(a => a.year_term == Year_Term);
                List <Tuple <Subject, YearTerm, Class, Teacher> > lst = new List <Tuple <Subject, YearTerm, Class, Teacher> >();
                Tuple <Subject, YearTerm, Class, Teacher>         tup = new Tuple <Subject, YearTerm, Class, Teacher>(subject_infor, year_info, class_info, teacher_info);
                lst.Add(tup);
                Session["student_subject"] = lst;
            }
            else
            {
                List <Tuple <Subject, YearTerm, Class, Teacher> > lst = (List <Tuple <Subject, YearTerm, Class, Teacher> >)Session["student_subject"];
                var gv            = TeacherAction.GetAll();
                var mh            = SubjectAction.GetAll();
                var lop           = ClassAction.GetAll();
                var nam           = YearTermAction.GetAll();
                var teacher_info  = gv.Find(a => a.id == Id_Teacher);
                var subject_infor = mh.Find(a => a.id == Id_Subject);
                var class_info    = lop.Find(a => a.id == Id_Class);
                var year_info     = nam.Find(a => a.year_term == Year_Term);
                Tuple <Subject, YearTerm, Class, Teacher> tup = new Tuple <Subject, YearTerm, Class, Teacher>(subject_infor, year_info, class_info, teacher_info);
                lst.Add(tup);
                Session["student_subject"] = lst;
            }

            return(Redirect("~/Student/RegisterSubject"));
        }
示例#2
0
 public ActionResult RegisterSubject()
 {
     //ViewBag.MH = SubjectAction.ShowAll();
     if ((string)Session["role"] == "Student")
     {
         var tmp = SubjectAction.ShowAll();
         List <Tuple <RegisterSubject, Student> >          subject = StudentAction.GetAllSubject();
         List <Tuple <Subject, YearTerm, Class, Teacher> > lst     = (List <Tuple <Subject, YearTerm, Class, Teacher> >)Session["student_subject"];
         if (lst != null)
         {
             for (int i = 0; i < lst.Count; i++)
             {
                 tmp.RemoveAll(a => a.Item1.id == lst[i].Item1.id);
             }
         }
         if (subject != null)
         {
             for (int i = 0; i < subject.Count; i++)
             {
                 tmp.RemoveAll(a => a.Item1.id == subject[i].Item1.id_subject);
             }
         }
         ViewBag.DK = lst;
         ViewBag.Mh = tmp;
         return(View());
     }
     else
     {
         return(Redirect("~/Home/Index"));
     }
 }
示例#3
0
 public Room(Exchange roomName, SubjectAction subjectAction, string subjectId, string roomKey, IMessageBus messageBus, ILogger <Room> logger)
 {
     RoomName      = roomName;
     SubjectAction = subjectAction;
     SubjectId     = subjectId;
     _messageBus   = messageBus;
     _logger       = logger;
     RoomKey       = roomKey;
     AddSubscriptionToMessageBus();
 }
示例#4
0
 public ActionResult CreateSubject(string Id, string Sub_name, int Numb_Credit, int Numb_Theory, int Numb_Practice,
                                   double Theory_Percent, int Numb_Student, string Specialized_Name, string Class_Name, string Teacher_Name, int Year_Term)
 {
     if (SubjectAction.Find(Id) != null)
     {
         SubjectAction.CreateRelate(Id, Class_Name, Teacher_Name, Year_Term);
     }
     if (SubjectAction.Find(Id) == null)
     {
         SubjectAction.Add_Subject(Id, Sub_name, Numb_Credit, Numb_Theory, Numb_Practice, Theory_Percent, Numb_Student, Class_Name, Teacher_Name, Year_Term);
     }
     return(Redirect("~/Subject/CreateSubject"));
 }
示例#5
0
 public ActionResult CreateTranscript()
 {
     if ((string)Session["role"] == "Admin")
     {
         ViewBag.SV   = StudentAction.GetAll();
         ViewBag.Mh   = SubjectAction.GetAll();
         ViewBag.Mark = RegSectorSubjectAction.ShowAll();
         return(View());
     }
     else
     {
         return(Redirect("~/Home/Index"));
     }
 }
示例#6
0
 public ActionResult CreateSubject()
 {
     if ((string)Session["role"] == "Admin")
     {
         ViewBag.ChuyenNganh = SpecializedAction.GetAll();
         ViewBag.Nganh       = MajorAction.GetAll();
         ViewBag.Lop         = ClassAction.GetAll();
         ViewBag.MH          = SubjectAction.ShowAll();
         ViewBag.GV          = TeacherAction.GetAll();
         ViewBag.YearTerm    = YearTermAction.GetAll();
         return(View());
     }
     else
     {
         return(Redirect("~/Home/Index"));
     }
 }
示例#7
0
 private string RoutingKey()
 {
     return(SubjectAction.ToString() + ":" + SubjectId);
 }
示例#8
0
 public JsonResult GetAllSubject(string Id)
 {
     return(Json(SubjectAction.Find(Id), JsonRequestBehavior.AllowGet));
 }
示例#9
0
        static void Main(string[] args)
        {
            ModelState model = new ModelState(
                new ModelValue[]
            {
                new ModelValue("Health", 0, 100),
                new ModelValue("Sleep", 0, 100),
                new ModelValue("Hungry", 0, 100)
            }
                );

            State Create(params double[] values) => new State(model, values);

            SubjectAction[] godActions = new SubjectAction[]
            {
                new SubjectAction("Wait", Create(new double[3]), Create(0, 0, 0)),
                new SubjectAction("Fight", Create(new double[3]), Create(-10, 0, 0)),
                new SubjectAction("Feed", Create(new double[3]), Create(0, 0, 10))
            };

            SubjectAction natureAction = new SubjectAction("Time", Create(new double[3]), Create(5, -5, -5));

            SubjectAction[] monkeyActions = new SubjectAction[]
            {
                new SubjectAction("Sleep", Create(0, 10, 0), Create(new double[3])),
                new SubjectAction("Work", Create(0, -5, 0), Create(new double[3])),
            };

            Subject god    = new Subject("God", model, godActions);
            Subject monkey = new Subject("Monkey", model, monkeyActions);

            string command;

            while (true)
            {
                if (monkey.State.Magnitude == 0)
                {
                    Console.WriteLine("Monkey is dead");
                    Console.Read();
                    break;
                }
                var monkeyAction = monkey.Wish();
                Console.WriteLine($"{monkey.Name} {monkeyAction.Action.Action.Name} {monkeyAction.Subject}");

                command = GetCommand(godActions);
                if (command == null)
                {
                    break;
                }
                if (!int.TryParse(command, out int godActionIndex) || !(godActionIndex >= 0 && godActionIndex < godActions.Length))
                {
                    continue;
                }

                var godAction = godActions[godActionIndex];

                natureAction.Apply(god, monkey);

                monkeyAction.Apply();

                godAction.Apply(god, monkey);

                monkey.Apply();
                Console.WriteLine($"{monkey.Name} {monkey.State.Magnitude}");
                Console.WriteLine($"{string.Join("\n", model.Values.Zip(monkey.State.Values, (m, v) => $"{m.Name} {v.Magnitude}"))}");
            }
        }