예제 #1
0
 public IActionResult StartRollCallById([FromBody] Location loc)
 {
     try
     {
         var user = _userService.GetUserByUserId(User.Id());
         //var user = _userService.GetUserByUserId(1);
         if (user.Type != Shared.Models.Type.Teacher)
         {
             return(StatusCode(403, new { msg = "权限不足" }));
         }
         else
         {
             _userService.InsertClassAttendanceById(loc.ClassInfoId, loc.SeminarId);
             loc.ClassInfo = _classService.GetClassByClassId(loc.ClassInfoId);
             loc.Seminar   = _seminarService.GetSeminarBySeminarId(loc.SeminarId);
             var id = _classService.CallInRollById(loc);
             return(Created($"/class/{loc.ClassInfo.Id}/rollcall/{id}",
                            new Dictionary <string, string> {
                 ["url"] = $"/class/{loc.ClassInfo.Id}/rollcall/{id}"
             }));
         }
     }
     catch (SeminarNotFoundException)
     {
         return(StatusCode(404, new { msg = "未找到讨论课" }));
     }
     catch (ClassNotFoundException)
     {
         return(StatusCode(404, new { msg = "未找到班级" }));
     }
     catch (ArgumentException)
     {
         return(StatusCode(400, new { msg = "ID格式错误" }));
     }
 }
예제 #2
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 }));
        }