Esempio n. 1
0
 public IActionResult GetSeminarById([FromRoute] int seminarId)
 {
     try
     {
         Seminar      seminar = _seminarService.GetSeminarBySeminarId(seminarId);
         List <Topic> topics  = new List <Topic>(_topicService.ListTopicBySeminarId(seminarId));
         return(Json(new
         {
             id = seminar.Id,
             name = seminar.Name,
             description = seminar.Description,
             groupingMethod = seminar.IsFixed,
             startTime = seminar.StartTime,
             endTime = seminar.EndTime,
             topics = topics.Select(t => new { id = t.Id, name = t.Name })
         }));
     }
     catch (SeminarNotFoundException)
     {
         return(StatusCode(404, new { msg = "未找到讨论课" }));
     }
     catch (ArgumentException)
     {
         return(StatusCode(400, new { msg = "错误的ID格式" }));
     }
 }
Esempio n. 2
0
 /// 老师获取该班级签到、分组状态.
 public Location GetCallStatusById(long seminarId, long classId)
 {
     try
     {
         _seminarService.GetSeminarBySeminarId(seminarId);
         //_classDao.Get(classId);
         return(_classDao.GetLocation(seminarId, classId));
     }
     catch (SeminarNotFoundException e) { throw e; }
 }
Esempio n. 3
0
 [HttpGet("/seminar/{seminarId:long}")]//测试成功
 public IActionResult GetSeminarByIdRandom([FromRoute] long seminarId)
 {
     try
     {
         var sem = _service.GetSeminarBySeminarId(seminarId);
         var cou = _db.Course.Find(sem.CourseId);
         sem.Course.Name = cou.Name;
         return(Json(sem));
     }
     catch (SeminarNotFoundException)
     {
         return(StatusCode(404, new { msg = "讨论课不存在!" }));
     }
 }
Esempio n. 4
0
 public IActionResult GetGroupInfo([FromRoute] long classId, [FromRoute] long seminarId)
 {
     try
     {
         var user = _userService.GetUserByUserId(User.Id());
         //   var user = _userService.GetUserByUserId(1);
         if (user.Type == Shared.Models.Type.Teacher)
         {
             var seminar = _seminarService.GetSeminarBySeminarId(seminarId);
             IList <SeminarGroup> groupss = _seminarGroupService.ListSeminarGroupBySeminarId(seminarId);
             List <SeminarGroup>  groups  = new List <SeminarGroup>();
             foreach (SeminarGroup g in groupss)
             {
                 if (g.ClassId == classId)
                 {
                     g.SeminarGroupTopics = _topicService.ListSeminarGroupTopicByGroupId(g.Id);;
                     groups.Add(g);
                 }
             }
             return(Json(groups.Select(g =>
                                       new
             {
                 groupId = g.Id,
                 topicname = g.SeminarGroupTopics.Select(t => new {
                     serial = t.Topic.Serial,
                     id = t.Topic.Id,
                     name = t.Topic.Name
                 }),
                 members = _seminarGroupService.ListSeminarGroupMemberByGroupId(g.Id).Select(m => new
                 {
                     id = m.Id,
                     name = m.Name,
                     number = m.Number
                 })
             })));
         }
         else
         {
             return(StatusCode(404, new { msg = "权限不足" }));
         }
     }
     catch (SeminarNotFoundException)
     {
         return(StatusCode(404, new { msg = "未找到讨论课" }));
     }
 }
Esempio n. 5
0
        public IActionResult Get(long id)
        {
            var seminar = seminarService.GetSeminarBySeminarId(id);
            var course  = courseService.GetCourseByCourseId(seminar.Course.Id);

            seminar.Course = course;
            return(Json(seminar));
        }
Esempio n. 6
0
        public IActionResult startClass(long classid, [FromQuery] long seminarid, [FromQuery] decimal latitude, [FromQuery] decimal longitude)
        {
            Location location = new Location()
            {
                ClassInfo = classService.GetClassByClassId(classid),
                Latitude  = latitude,
                Longitude = longitude,
                Seminar   = seminarService.GetSeminarBySeminarId(seminarid),
                Status    = 1
            };

            classService.CallInRollById(location);
            return(Json(new { status = 200 }));
        }
 public IActionResult GetSeminarById([FromRoute] long seminarId)
 {
     try
     {
         return(Json(_seminarService.GetSeminarBySeminarId(seminarId)));
     }
     catch (SeminarNotFoundException)
     {
         return(StatusCode(404, new { msg = "讨论课不存在" }));
     }
     catch (ArgumentException)
     {
         return(StatusCode(400, new { msg = "讨论课ID输入格式有误" }));
     }
 }
 public IActionResult GetSeminarById([FromRoute] long seminarId)
 {
     try
     {
         var sem = _seminarService.GetSeminarBySeminarId(seminarId);
         return(Json(new
         {
             id = sem.Id,
             name = sem.Name,
             description = sem.Description,
             startTime = sem.StartTime.ToString("yyyy-MM-dd"),
             endTime = sem.EndTime.ToString("yyyy-MM-dd")
         }));
     }
     catch (SeminarNotFoundException)
     {
         return(StatusCode(404, new { msg = "讨论课不存在" }));
     }
     catch (ArgumentException)
     {
         return(StatusCode(400, new { msg = "讨论课ID输入格式有误" }));
     }
 }
Esempio n. 9
0
 public IActionResult GetGradeByCourseId([FromRoute] long courseId)
 {
     try
     {
         var seminarGroups = _seminarGroupService.ListSeminarGroupIdByStudentId(User.Id());
         return(Json(seminarGroups.Select(s => new
         {
             seminarName = _seminarService.GetSeminarBySeminarId(s.SeminarId).Name,
             groupName = s.Id + "组",//这里还是没有组名的问题
             leaderName = _userService.GetUserByUserId(s.LeaderId).Name,
             presentationGrade = s.PresentationGrade,
             reportGrade = s.ReportGrade,
             grade = s.FinalGrade
         })));
     }
     catch (CourseNotFoundException)
     {
         return(StatusCode(404, new { msg = "未找到讨论课" }));
     }
     catch (ArgumentException)
     {
         return(StatusCode(400, new { msg = "课程ID格式错误" }));
     }
 }
        public IActionResult GetSeminar(long seminarId)
        {
            try
            {
                long id = seminarId;
                // Fetch data from database
                // 获得Seminar的基本信息
                Seminar seminarData = _iSeminarService.GetSeminarBySeminarId(seminarId);
                // 获得Seminar下的所有Topic信息
                IList <Topic> topicList = _iTopicService.ListTopicBySeminarId(seminarId);

                // 生成SeminarVO对象
                SeminarVO seminar = seminarData;
                // 如何计算剩余组数???
                List <TopicVO> topics = new List <TopicVO>();
                foreach (Topic i in topicList)
                {
                    topics.Add(i);
                }
                //将topics放入SeminarVO对象中
                seminar.Topics = topics;

                // Success
                return(Json(seminar));
            }
            //If seminar not found, 返回404
            catch (SeminarNotFoundException)
            {
                return(NotFound(new { msg = "未找到该讨论课!" }));
            }
            //seminarId 格式错误,返回400
            catch (ArgumentException)
            {
                return(BadRequest(new { msg = "错误的ID格式!" }));
            }
        }
Esempio n. 11
0
        public IActionResult Get(long id)
        {
            var seminar = seminarService.GetSeminarBySeminarId(id);

            return(Json(seminar));
        }