示例#1
0
 public HttpResponseMessage EndCourse([FromBody] JObject Newcourse)
 {
     try
     {
         string signature = HttpUtil.GetAuthorization(Request);
         if (signature == null || !redis.IsSet(signature))
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         Course course = new Course();
         QuickCopy.Copy <Course>(Newcourse, ref course);
         bool login = redis.IsSet(signature);
         if (!login)
         {
             return(new Response(2001, "未登录账户").Convert());
         }
         string targetId  = redis.Get <string>(signature);
         Course oldCourse = CourseDao.GetCourseInfoById(course.id);
         if (oldCourse == null || oldCourse.teacher_id != targetId)
         {
             return(new Response(2002, "无权限修改该课程的信息").Convert());
         }
         CourseDao.ChangeCourseInfo(course);
         LogUtil.Log(Request, "修改课程", course.id.ToString(), targetId, UserDao.GetUserById(targetId).role);
         return(new Response(1001, "修改课程信息成功").Convert());
     }
     catch (Exception e)
     {
         ErrorLogUtil.WriteLogToFile(e, Request);
         return(new Response(4001).Convert());;
     }
 }