Example #1
0
        public ActionResult ImportProject(ProjectImportPostData data)
        {
            var repo = _GetRepo(data);

            if (repo == null)
            {
                return(new HttpNotFoundResult());
            }

            Repository sourceRepo = null;
            int        courseId   = data.SourceCourseId > 0 ? data.SourceCourseId : data.CourseId;

            if (data.SourceType == ImportableProjects.Types.PLAYGROUND)
            {
                string userName = String.IsNullOrWhiteSpace(data.SourceUserName) ? data.UserName : data.SourceUserName;
                sourceRepo = PlaygroundRepository.Get(courseId, userName, data.SourceRepositoryId);
            }
            else if (data.SourceType == ImportableProjects.Types.WORKSPACE)
            {
                sourceRepo = WorkRepository.Get(courseId, data.UserName, data.SourceRepositoryId);
            }
            else if (data.SourceType == ImportableProjects.Types.SUBMISSION)
            {
                sourceRepo = SubmissionRepository.Get(courseId, data.UserName, data.SourceRepositoryId);
                sourceRepo.Checkout();
            }
            if (sourceRepo == null)
            {
                return(new HttpNotFoundResult());
            }

            try
            {
                repo.Commit("Before Import Project");
                repo.CopyFromRepository(sourceRepo);
                repo.Commit("After Import Project");
                return(Json("success"));
            }
            catch (Exception ex)
            {
                Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
                return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
Example #2
0
 public ActionResult BrowseUserWork(int courseId, string userName, int assignmentId, string pathInfo)
 {
     return(_Browse(WorkRepository.Get(courseId, userName, assignmentId).FilePath, pathInfo));
 }