Ejemplo n.º 1
0
        public async Task <IActionResult> GenerateVersionAsync(
            [FromRoute] string organisationId,
            [FromRoute] string teamId,
            [FromRoute] string appId,
            [FromBody] BranchActionRequest data,
            [FromServices] IVersionService service)
        {
            if (string.IsNullOrWhiteSpace(organisationId) || string.IsNullOrWhiteSpace(teamId) || string.IsNullOrWhiteSpace(appId) || data == null)
            {
                return(BadRequest(new { reason = $"Invalid parameters!" }));
            }

            if (string.IsNullOrWhiteSpace(data.From))
            {
                return(BadRequest("Source branch must have valid value!"));
            }

            if (string.IsNullOrWhiteSpace(data.To))
            {
                var resultGet = await service.GetVersionFromSourceBranchAsync(organisationId, teamId, appId, data);

                if (resultGet == null)
                {
                    return(NotFound());
                }
                return(Ok(resultGet));
            }

            var resultUpdate = await service.UpdateVersionOnBranches(organisationId, teamId, appId, data);

            if (resultUpdate == null)
            {
                return(NotFound());
            }

            return(Ok(resultUpdate));
        }