public ReferencesServices() { if (referencesRepository == null) { referencesRepository = new ReferencesRepository(); } }
public async Task <ActionResult> Create(Reference reference) { try { ReferencesRepository referenceRepository = new ReferencesRepository(); var result = await referenceRepository.CreateReference(reference); return(RedirectToAction("View", "Home", new { projectId = reference.Project })); } catch (RedirectRequiredException x) { return(Redirect(x.RedirectUri.ToString())); } }
private async Task <ProjectDetailViewModel> GetProjectAndReferencesFromSharePoint(string projectId) { ProjectDetailViewModel model = new ProjectDetailViewModel(); ProjectsRepository projectRepository = new ProjectsRepository(); ReferencesRepository referenceRepository = new ReferencesRepository(); int id = -1; if (Int32.TryParse(projectId, out id)) { model.Project = await projectRepository.GetProject(id, String.Empty); model.References = (await referenceRepository.GetReferencesForProject(id)).ToList(); } return(model); }
private async Task <ActionResult> GetForEditDelete(int id) { ReferencesRepository referenceRepository = new ReferencesRepository(); Reference reference = null; try { reference = await referenceRepository.GetReference(id, String.Empty); } catch (RedirectRequiredException x) { return(Redirect(x.RedirectUri.ToString())); } return(View(reference)); }
public async Task <ActionResult> Delete(Reference reference) { try { ReferencesRepository repository = new ReferencesRepository(); if (await repository.DeleteReference(reference.Id, reference.__eTag)) { return(RedirectToAction("View", "Home", new { projectId = reference.Project })); } else { return(View(reference)); } } catch (RedirectRequiredException x) { return(Redirect(x.RedirectUri.ToString())); } }
public async Task <ActionResult> View(string projectId) { ProjectDetailViewModel model = new ProjectDetailViewModel(); ProjectsRepository projectRepository = new ProjectsRepository(); ReferencesRepository referenceRepository = new ReferencesRepository(); int id = -1; try { if (Int32.TryParse(projectId, out id)) { model.Project = await projectRepository.GetProject(id, String.Empty); model.References = (await referenceRepository.GetReferencesForProject(id)).ToList(); } } catch (RedirectRequiredException x) { return(Redirect(x.RedirectUri.ToString())); } return(View(model)); }