public static ProjectDto LoadProject(int userId, int projectId)
        {
            var projectModel = ServerProjectRepository.GetProject(userId, projectId);
            var projectDto   = ProjectModelConverters.FromModelToDto(projectModel);

            return(projectDto);
        }
        private static FileOperationResponse Server_HandleStatefulFileOperationRequest(FileOperationRequest request)
        {
            FileOperationResponse response = new FileOperationResponse();

            ProjectModel     projectModel = null;
            ProjectFileModel fileModel    = null;

            try
            {
                projectModel = ServerProjectRepository.GetProject(request.UserId, request.ProjectId);
                if (projectModel == null)
                {
                    response.SetError("Specified project could not be located.");
                    return(response);
                }

                fileModel = ServerProjectRepository.GetFile(request.UserId, request.ProjectId, request.FileId);
                if (fileModel == null)
                {
                    response.SetError("Specified file could not be located within the project.");
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.SyncContent.SetError(ex);
            }


            // Set contextual identifiers on response
            response.UserId    = request.UserId;
            response.ProjectId = request.ProjectId;
            response.FileId    = request.FileId;

            // Now, handle each requested operation...

            if (request.SyncContent != null)
            {
                response.SyncContent = new FileSyncContentResponse();

                fileModel.Content           = request.SyncContent.Content;
                response.SyncContent.Status = ResponseStatus.OK;
            }


            if (request.Parse != null)
            {
                response.Parse = new FileParseResponse();

                try
                {
                    response.Parse.Errors = NRefactoryUtils.ParseFile(fileModel);
                    response.Parse.Status = ResponseStatus.OK;
                }
                catch (Exception ex)
                {
                    response.Parse.SetError(ex);
                }
            }


            if (request.CompleteCode != null)
            {
                response.CompleteCode = new FileCodeCompletionResponse();

                try
                {
                    var analysisRequest = new ProjectAnalysisRequest()
                    {
                        ProjectModel             = projectModel,
                        CodeCompletionParameters = new ProjectAnalysisCodeCompletionParameters()
                        {
                            FileId = request.FileId,
                            Line   = request.CompleteCode.LineNumber,
                            Column = request.CompleteCode.ColumnNumber
                        }
                    };

                    var analysisResult = NRefactoryUtils.RunFullProjectAnalysis(analysisRequest);

                    response.CompleteCode.CompletionOptions = analysisResult.CompletionOptions.Select(x => new FileCodeCompletionResult()
                    {
                        CompletionText = x.CompletionText,
                        DisplayText    = x.DisplayText
                    }).ToArray();
                    response.CompleteCode.Status = ResponseStatus.OK;
                }
                catch (Exception ex)
                {
                    response.CompleteCode.SetError(ex);
                }
            }

            response.Status = ResponseStatus.OK;
            return(response);
        }