public IActionResult GetMySeminarGroup(long seminarId)
        {
            // Authentication
            // 老师无法使用此API,返回403
            if (User.Type() == Shared.Models.Type.Teacher)
            {
                return(StatusCode(403, new { msg = "老师无法获得自己的小组信息!" }));
            }

            try
            {
                // Fetch data from database
                SeminarGroup seminarGroup = _iSeminarGroupService.GetSeminarGroupById(seminarId, User.Id());

                // 转换成VO对象
                GroupVO myGroup = seminarGroup;

                //获取Members
                IList <UserInfo> memberList = _iSeminarGroupService.ListSeminarGroupMemberByGroupId(seminarGroup.Id);
                List <UserVO>    members    = new List <UserVO>();
                foreach (UserInfo u in memberList)
                {
                    members.Add(u);
                }
                myGroup.Members = members;

                //获取Topics和PresentationGrade
                IList <SeminarGroupTopic> seminarGroupTopicList = _iTopicService.ListSeminarGroupTopicByGroupId(seminarGroup.Id);
                List <TopicVO>            topics = new List <TopicVO>();
                List <int> pGrades = new List <int>();
                foreach (SeminarGroupTopic sgt in seminarGroupTopicList)
                {
                    topics.Add(sgt.Topic);
                    pGrades.Add((int)sgt.PresentationGrade);
                }
                myGroup.Topics = topics;
                myGroup.Grade.PresentationGrade = pGrades;

                //获取Name
                myGroup.GetName();

                // Success
                return(Json(myGroup));
            }
            //If seminar not found, 返回404
            catch (SeminarNotFoundException)
            {
                return(NotFound(new { msg = "未找到该讨论课!" }));
            }
            //If group not found, 返回404
            catch (GroupNotFoundException)
            {
                return(NotFound(new { msg = "讨论课尚未分组!" }));
            }
            //seminarId 格式错误,返回400
            catch (ArgumentException)
            {
                return(BadRequest(new { msg = "错误的ID格式!" }));
            }
        }
Exemplo n.º 2
0
 public IActionResult Put([FromBody] GroupVO group)
 {
     if (group == null)
     {
         return(BadRequest());
     }
     return(new ObjectResult(this._groupService.Update(group)));
 }
Exemplo n.º 3
0
        public GroupVO deserializeToGroup(string response)
        {
            IDictionary search = Json.Deserialize(response) as IDictionary;
            GroupVO     group  = new GroupVO();

            group.name  = search["group"].ToString();
            group.grade = search["grade"].ToString();
            return(group);
        }
        public IActionResult GetGroupsUnderTopic(long topicId)
        {
            try
            {
                // Fetch groups belongs to this topic via topicId from database...
                IList <SeminarGroup> seminarGroupList = _iSeminarGroupService.ListGroupByTopicId(topicId);

                // 转换成VO对象
                List <GroupVO> groups = new List <GroupVO>();         //只需要Id和Name
                foreach (SeminarGroup sg in seminarGroupList)
                {
                    GroupVO g = sg;

                    //获取Members
                    IList <UserInfo> memberList = _iSeminarGroupService.ListSeminarGroupMemberByGroupId(sg.Id);
                    List <UserVO>    members    = new List <UserVO>();
                    foreach (UserInfo u in memberList)
                    {
                        members.Add(u);
                    }
                    g.Members = members;

                    //获取Topics和PresentationGrade
                    IList <SeminarGroupTopic> seminarGroupTopicList = _iTopicService.ListSeminarGroupTopicByGroupId(sg.Id);
                    List <TopicVO>            topics = new List <TopicVO>();
                    List <int> pGrades = new List <int>();
                    foreach (SeminarGroupTopic sgt in seminarGroupTopicList)
                    {
                        topics.Add(sgt.Topic);
                        pGrades.Add((int)sgt.PresentationGrade);
                    }
                    g.Topics = topics;
                    g.Grade.PresentationGrade = pGrades;

                    //获取Name
                    g.GetName();

                    groups.Add(g);
                }

                // Success
                return(Json(groups));
            }
            //If topic not found, 返回404
            catch (TopicNotFoundException)
            {
                return(NotFound(new { msg = "未找到该话题!" }));
            }
            //topicId 格式错误,返回400
            catch (ArgumentException)
            {
                return(BadRequest(new { msg = "错误的ID格式!" }));
            }
        }
Exemplo n.º 5
0
        public IActionResult Post([FromBody] GroupVO group)
        {
            if (group == null)
            {
                return(BadRequest());
            }
            var newGroup = new ObjectResult(this._groupService.Create(group));

            if (newGroup.Value == null)
            {
                return(Conflict());
            }
            return(Ok(newGroup));
        }
Exemplo n.º 6
0
 public GroupVO Update(GroupVO group)
 {
     try
     {
         GroupRepository ldapGroup   = new GroupRepository(_mySQLContext);
         var             groupEntity = _converter.Parse(group);
         groupEntity = ldapGroup.Update(groupEntity);
         return(_converter.Parse(groupEntity));
     }
     catch (Exception e)
     {
         Console.WriteLine("\r\nUnexpected exception occurred:\r\n\t" + e.GetType() + ":" + e.Message);
         return(null);
     }
 }
Exemplo n.º 7
0
        public IActionResult GetGroupSeminarGrade(long groupId)
        {
            try
            {
                SeminarGroup seminarGroup = _iSeminarGroupService.GetSeminarGroupByGroupId(groupId);
                // 转换成VO对象
                GroupVO myGroup = seminarGroup;

                //获取Members
                IList <UserInfo> memberList = _iSeminarGroupService.ListSeminarGroupMemberByGroupId(seminarGroup.Id);
                List <UserVO>    members    = new List <UserVO>();
                foreach (UserInfo u in memberList)
                {
                    members.Add(u);
                }
                myGroup.Members = members;

                //获取Topics和PresentationGrade
                IList <SeminarGroupTopic> seminarGroupTopicList = _iTopicService.ListSeminarGroupTopicByGroupId(seminarGroup.Id);
                List <TopicVO>            topics = new List <TopicVO>();
                List <int> pGrades = new List <int>();
                foreach (SeminarGroupTopic sgt in seminarGroupTopicList)
                {
                    topics.Add(sgt.Topic);
                    pGrades.Add((int)sgt.PresentationGrade);
                }
                myGroup.Topics = topics;
                myGroup.Grade.PresentationGrade = pGrades;

                //获取Name
                myGroup.GetName();

                // Success
                return(Json(myGroup));
            }
            catch (SeminarNotFoundException)
            {
                return(NotFound());
            }
            catch (GroupNotFoundException)
            {
                return(NotFound());
            }
            catch (ArgumentException)
            {
                return(BadRequest());
            }
        }
Exemplo n.º 8
0
        public IList <GroupVO> GetListAll()
        {
            IList <GroupVO> list = new List <GroupVO>();

            foreach (GroupEntity e in this.groupDao.GetListAll())
            {
                GroupVO vo = new GroupVO();
                vo.GroupId     = e.GroupId;
                vo.GroupName   = e.GroupName;
                vo.ParentId    = e.ParentId;
                vo.RegionId    = e.RegionId;
                vo.Sequence    = e.Sequence;
                vo.UseFlag     = e.UseFlag;
                vo.Description = e.Description;
                list.Add(vo);
            }
            return(list);
        }
Exemplo n.º 9
0
        public IEnumerator GetUserGroups(UserVO user)
        {
            CoroutineWithData cd = new CoroutineWithData(this, GetUserSubjects(user.subjects));

            yield return(cd.coroutine);

            IList <SubjectVO> user_subjects = cd.result as List <SubjectVO>;
            IList <GroupVO>   user_groups   = new List <GroupVO>();

            foreach (var subject in user_subjects)
            {
                string url = "group/" + subject.group_id + ".json";
                Debug.Log("Groups url: " + url);
                CoroutineWithData cd1 = new CoroutineWithData(this, myFirebase.GET(url));
                yield return(cd1.coroutine);

                GroupVO group = customDeserializer.deserializeToGroup(cd1.result.ToString());
                group.key = subject.group_id;
                user_groups.Add(group);
            }
            Debug.Log("Carla is in: " + user_groups[0].name);
            yield return(user_groups);
        }
        public IActionResult GetSeminarGroups(long seminarId, [FromQuery] bool gradeable, [FromQuery] int classId)
        {
            try
            {
                // 先只实现了不分班级小组和不分用户是否可打分小组的方法

                // Fetch data from database
                IList <SeminarGroup> seminarGroupList = _iSeminarGroupService.ListSeminarGroupBySeminarId(seminarId);

                // 转换成VO对象
                List <GroupVO> groups = new List <GroupVO>();
                foreach (var sg in seminarGroupList)
                {
                    GroupVO g = sg;

                    //获取Members
                    IList <UserInfo> memberList = _iSeminarGroupService.ListSeminarGroupMemberByGroupId(sg.Id);
                    List <UserVO>    members    = new List <UserVO>();
                    foreach (UserInfo u in memberList)
                    {
                        members.Add(u);
                    }
                    g.Members = members;

                    //获取Topics和PresentationGrade
                    IList <SeminarGroupTopic> seminarGroupTopicList = _iTopicService.ListSeminarGroupTopicByGroupId(sg.Id);
                    List <TopicVO>            topics = new List <TopicVO>();
                    List <int> pGrades = new List <int>();
                    foreach (SeminarGroupTopic sgt in seminarGroupTopicList)
                    {
                        if (sgt.Topic != null)
                        {
                            topics.Add(sgt.Topic);
                            if (sgt.PresentationGrade != null)
                            {
                                pGrades.Add((int)sgt.PresentationGrade);
                            }
                        }
                    }
                    g.Topics = topics;
                    g.Grade.PresentationGrade = pGrades;

                    //获取Name
                    g.GetName();

                    groups.Add(g);
                }

                // Success
                return(Json(groups));
            }
            //If seminar not found, 返回404
            catch (SeminarNotFoundException)
            {
                return(NotFound(new { msg = "未找到该讨论课!" }));
            }
            //seminarId 格式错误,返回400
            catch (ArgumentException)
            {
                return(BadRequest(new { msg = "错误的ID格式!" }));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 查看分组
        /// </summary>
        /// <param name="context">Context.</param>
        public void Getgroup(JabinfoContext context)
        {
            Weixin wx = new Weixin ();
            Utils Util = new Utils ();
            string url = "https://api.weixin.qq.com/cgi-bin/groups/get?access_token="+wx.GetAccessToken();

            string json = Jabinfo.Help.Http.GetHttps(url);
            var dict = Util.JsonTo<Dictionary<string, List<Dictionary<string, object>>>>(json);
            var gs = new Groups();
            var gilist = dict["groups"];
            foreach (var gidict in gilist)
            {
                var gi = new GroupVO();
                gi.name = gidict["name"].ToString();
                gi.id = Convert.ToInt32(gidict["id"]);
                gi.count = Convert.ToInt32(gidict["count"]);
                gs.Add(gi);
            }
            context.Variable ["groupList"] = gs;
        }
Exemplo n.º 12
0
        public IActionResult GetStudentGradeUnderAllSeminar(long courseId)
        {
            try
            {
                // Fetch data from database
                IList <SeminarGroup> seminarGroupList = _iGradeService.ListSeminarGradeByCourseId(User.Id(), courseId);

                // 转换为SeminarGradeDetailVO的List对象
                List <SeminarGradeDetailVO> seminarGrades = new List <SeminarGradeDetailVO>();
                foreach (SeminarGroup i in seminarGroupList)
                {
                    // 为了获得GroupName,要先建一个GroupVO实体
                    GroupVO g = i;

                    //获取Members
                    IList <UserInfo> memberList = _iSeminarGroupService.ListSeminarGroupMemberByGroupId(i.Id);
                    List <UserVO>    members    = new List <UserVO>();
                    foreach (UserInfo u in memberList)
                    {
                        members.Add(u);
                    }
                    g.Members = members;

                    //获取Topics和PresentationGrade
                    IList <SeminarGroupTopic> seminarGroupTopicList = _iTopicService.ListSeminarGroupTopicByGroupId(i.Id);
                    List <TopicVO>            topics = new List <TopicVO>();
                    List <int> pGrades = new List <int>();
                    foreach (SeminarGroupTopic sgt in seminarGroupTopicList)
                    {
                        topics.Add(sgt.Topic);
                        if (sgt.PresentationGrade != null)
                        {
                            pGrades.Add((int)sgt.PresentationGrade);
                        }
                        else
                        {
                            pGrades.Add(0);
                        }
                    }
                    g.Topics = topics;
                    g.Grade.PresentationGrade = pGrades;

                    //获取Name
                    g.GetName();

                    SeminarGradeDetailVO seminarGradeDetailVO = new SeminarGradeDetailVO {
                        SeminarName = i.Seminar.Name, GroupName = g.Name, LeaderName = i.Leader.Name, PresentationGrade = i.PresentationGrade == null?0:(int)i.PresentationGrade, ReportGrade = i.ReportGrade == null ? 0 : (int)i.ReportGrade, Grade = i.FinalGrade == null ? 0 : (int)i.FinalGrade
                    };
                    seminarGrades.Add(seminarGradeDetailVO);
                }

                // Success
                return(Json(seminarGrades));
            }
            // 未找到课程,返回404
            catch (CourseNotFoundException)
            {
                return(NotFound(new { msg = "未找到该课程!" }));
            }
            // 错误的ID格式,返回400
            catch (ArgumentException)
            {
                return(BadRequest(new { msg = "错误的ID格式!" }));
            }
        }