コード例 #1
0
        public ActionResult GetAnnotateDocument(int assignmentID, int authorTeamID, string apiKey)
        {
            if (apiKey != ConfigurationManager.AppSettings["AnnotateApiKey"])
            {
                return(RedirectToAction("Index", "Home"));
            }

            Assignment assignment = db.Assignments.Find(assignmentID);

            //add in some robustness.  If we were passed in a critical review,
            //get the preceeding assignment.  Otherwise, just use the current assignment.
            if (assignment.Type == AssignmentTypes.CriticalReview)
            {
                assignment = assignment.PreceedingAssignment;
            }

            AssignmentTeam assignmentTeam = (from at in db.AssignmentTeams
                                             where at.AssignmentID == assignment.ID
                                             &&
                                             at.TeamID == authorTeamID
                                             select at
                                             ).FirstOrDefault();

            string path = FileSystem.GetDeliverable(
                assignment.Course as Course,
                assignment.ID,
                assignmentTeam,
                assignment.Deliverables[0].ToString()
                );
            string fileName = AnnotateApi.GetAnnotateDocumentName(assignment.ID, authorTeamID);

            return(new FileStreamResult(FileSystem.GetDocumentForRead(path), "application/octet-stream")
            {
                FileDownloadName = fileName
            });
        }