public BuildTarget ToEntity(BuildTargetCreateModel m) { return(new BuildTarget { Name = m.Name, Type = m.Type, DeploymentType = m.DeploymentType, TargetRelativePath = m.TargetRelativePath, ProjectId = m.ProjectId, CreatedAtUtc = DateTime.UtcNow, CreatedByUserId = m.CreatedByUserId }); }
public async Task <(bool, Guid)> CreateBuildTarget(BuildTargetCreateModel model) { using (var session = _store.OpenSession()) { try { var e = ToEntity(model); session.Store(e); await session.SaveChangesAsync(); return(true, e.Id); } catch (Exception exp) { Log.Error(exp, string.Empty); return(false, Guid.Empty); } } }
public async Task <IActionResult> CreateBuildTarget([FromForm] BuildTargetCreateModel model) { if (model.ProjectId == Guid.Empty) { return(BadRequest()); } if (ModelState.IsValid == false) { return(View(model)); } var session = await HttpContext.GetSession(); if (session == null) { return(BadRequest()); } model.CreatedByUserId = session.User.Id; var(result, buildTargetId) = await projectRepo.CreateBuildTarget(model); if (result == false) { this.AlertError("Could not persist this object."); return(View(model)); } if (model.DeploymentType == Core.Deploy.DeployTargetType.IIS) { return(RedirectToAction(nameof(CreateIISBuildTargetConfiguration), new { projectId = model.ProjectId, buildTargetId = buildTargetId })); } return(RedirectToAction(nameof(Index))); }