private async Task<IndexViewModel> GetOrCreateModel(IndexViewModel model = null) { if (model == null) model = new IndexViewModel(); model.DropboxIsAuthenticated = _dropboxConnector.IsAuthenticated; model.ExactIsAuthenticated = _exactConnector.IsAuthenticated; model.DropboxFiles = _dropboxConnector.IsAuthenticated && _exactConnector.IsAuthenticated ? await _dropboxConnector.GetFiles() : Enumerable.Empty<TreeNode>(); return model; }
public async Task<ActionResult> Index(IndexViewModel model) { if (ModelState.IsValid) { var body = await _dropboxConnector.DownloadFile(model.SelectedFile); var id = _exactConnector.CreateDocument(model.Title, body); if (id == Guid.Empty) return RedirectToAction("Result", new { success = false }); using (_repository) { _repository.CreateReference(model.SelectedFile, id); } return RedirectToAction("Result", new { success = true }); } model = await GetOrCreateModel(model); return View(model); }