Ejemplo n.º 1
0
 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
     });
 }
Ejemplo n.º 2
0
        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);
                }
            }
        }
Ejemplo n.º 3
0
        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)));
        }