public async Task <IActionResult> CreateRepositoryCursor([FromForm] RepositoryCursorCreateModel m) { var session = await HttpContext.GetSession(); if (session == null) { return(BadRequest()); } //if (ModelState.IsValid == false) //{ // return View(model); //} m.CreatedByUserId = session.User.Id; var result = await projectRepo.CreateRepositoryCursor(m); if (result == false) { this.AlertError("Could not persist this object."); return(View(m)); } return(RedirectToAction(nameof(Index))); }
public RepositoryCursor ToEntity(RepositoryCursorCreateModel m) { return(new RepositoryCursor { ProjectId = m.ProjectId, CreatedAtUtc = DateTime.UtcNow, Info = m.Selected, Name = m.Name, CreatedByUserId = m.CreatedByUserId, }); }
public async Task <bool> CreateRepositoryCursor(RepositoryCursorCreateModel model) { using (var session = _store.OpenSession()) { try { var e = ToEntity(model); session.Store(e); await session.SaveChangesAsync(); return(true); } catch (Exception exp) { Log.Error(exp, string.Empty); return(false); } } }
public async Task <IActionResult> CreateRepositoryCursor([FromQuery] Guid projectId, [FromServices] IEnumerable <IRepositoryImportStrategy> strategies, [FromServices] AppConfiguration appConfig, [FromServices] IEnumerable <IRepositoryAuthenticationInfo> authInfos) { var project = await projectRepo.Get(projectId); if (project == null) { Log.Error($"Could not find project with id {projectId}"); return(BadRequest()); } var authInfo = authInfos.FirstOrDefault(x => x.Type == project.RepositoryType); if (authInfo == null) { Log.Error("Could not find suitable credentials"); return(BadRequest()); } var commits = await RepositoryManager.GetCommitList(project, project.RepositoryType, appConfig, authInfo, new ReadOnlyCollection <IRepositoryImportStrategy>(strategies.ToList()), new Core.Runner.CustomLogger(), 10); var m = new RepositoryCursorCreateModel { ProjectId = projectId, ProjectName = project.Name, Commits = commits }; return(View(m)); }