public ChunkCollectionEnt Get(string courseId, string blockId, ref string errorInfo) { _log.Debug("Get material info for course " + courseId + " block " + blockId); string sql = string.Format("select update_time, download_url from chunk_collection where course_id='{0}' and block_id='{1}'" , courseId, blockId); DataSet ds = Query(sql); if (ds == null) { throw new Exception("Failed to query learn material data"); } if (ds.Tables[0].Rows.Count == 0) { errorInfo = "Course or block not exist"; return(null); } ChunkCollectionEnt ent = new ChunkCollectionEnt(); ent.CourseId = courseId; ent.BlockId = blockId; ent.UpdateTime = DateTime.Parse(ds.Tables[0].Rows[0][0].ToString() + "Z"); ent.DownloadUrl = ds.Tables[0].Rows[0][1].ToString(); return(ent); }
public IHttpActionResult Get(string courseId, string blockId) { _log.Info("Checking the material of course " + courseId + " and block " + blockId); try { string errorInfo = string.Empty; ChunkCollectionEnt ent = (new LearnMaterial()).Get(courseId, blockId, ref errorInfo); if (ent == null) { if (errorInfo == "Course or block not exist") { return(NotFound()); } return(BadRequest(errorInfo)); } return(Ok(ent)); } catch (Exception ex) { _log.Error(ex.ToString()); return(BadRequest(ex.ToString())); } }