public async Task <IActionResult> Edit(string id) { var user = UserModel.GetAuthenticatedUser(User.Identity); var viewModel = await GetProjectViewModel(id); viewModel.IsAuthor = viewModel.AuthorId == user.Email; var termsPage = await _termsPageRepository.GetAsync(id); if (termsPage != null) { ViewBag.TermsPage = TermsPageViewModel.Create(termsPage); } else { ViewBag.TermsPage = TermsPageViewModel.Create(id); } // TODO: move to a bool CanUserEditProject( if (viewModel.IsAdmin) { return(View("EditProject", viewModel)); } if ((viewModel.Status == Status.Initiative || viewModel.Status == Status.Draft) && viewModel.AuthorId == user.Email) { return(View("EditProject", viewModel)); } return(View("AccessDenied")); }
public async Task <IActionResult> Terms(string id) { if (!string.IsNullOrEmpty(id)) { var termsPage = await _termsPageRepository.GetAsync(id); var model = TermsPageViewModel.Create(termsPage); return(View("CustomTerms", model)); } return(View()); }
public async Task <IActionResult> AddCustomTermsPage(TermsPageViewModel model) { try { await _termsPageRepository.SaveAsync(model.ProjectId, model.Content); } catch (Exception ex) { return(Json(new { Error = ex.Message })); } return(Json(new { Success = true })); }