Exemplo n.º 1
0
        public async Task <IActionResult> CreateBuild([FromForm, Required] CreateBuildRequest request)
        {
            using var cover = await SaveTempCover(request.Cover);

            var result = await _buildService.CreateOrAddVersion(new BuildService.CreateRequest(
                                                                    User.GetUserName(),
                                                                    request.Slug,
                                                                    request.Title,
                                                                    request.Description,
                                                                    request.Tags,
                                                                    (request.Hash, request.Version.Name, request.Version.Description, request.Version.Icons),
                                                                    null),
                                                                cover, User);

            return(result switch
            {
                BuildService.CreateResult.Success success => Created(Url.ActionLink(nameof(GetDetails), "Build", new
                {
                    owner = success.Build.OwnerSlug,
                    slug = success.Build.Slug,
                }), success.Build.ToThinViewModel(Url)),
                BuildService.CreateResult.DuplicateHash error => Conflict(error.ToProblem()),
                BuildService.CreateResult.DuplicateSlug error => Conflict(error.ToProblem()),
                { } error => BadRequest(error.ToProblem()),
            });
 public virtual CreateBuildResponse CreateBuild(string modelId, CreateBuildRequest request)
 {
     return(PolicyService.ExecuteRetryAndCapture400Errors(
                "RecommendationsService.CreateBuild",
                ApiKeys.RecommendationsRetryInSeconds,
                () =>
     {
         var result = RecommendationsRepository.CreateBuild(modelId, request);
         return result;
     },
                null));
 }
Exemplo n.º 3
0
        public virtual CreateBuildResponse CreateBuild(string modelId, CreateBuildRequest request)
        {
            try
            {
                var result = Task.Run(async() => await RecommendationsRepository.CreateBuildAsync(modelId, request)).Result;

                return(result);
            }
            catch (Exception ex)
            {
                Logger.Error("RecommendationsService.CreateBuild failed", this, ex);
            }

            return(null);
        }
 public void CreateBuildAsync(CreateBuildRequest request, AmazonServiceCallback <CreateBuildRequest, CreateBuildResponse> callback, AsyncOptions options = null)
 {
     throw new System.NotImplementedException();
 }
Exemplo n.º 5
0
        public async Task <CreateBuildResponse> CreateBuildAsync(string modelId, CreateBuildRequest request)
        {
            var response = await SendPostAsync($"{modelsUrl}{modelId}/builds", JsonConvert.SerializeObject(request));

            return(JsonConvert.DeserializeObject <CreateBuildResponse>(response));
        }
        public virtual async Task <CreateBuildResponse> CreateBuildAsync(string modelId, CreateBuildRequest request)
        {
            var response = await RepositoryClient.SendJsonPostAsync(ApiKeys.Recommendations, $"{ApiKeys.RecommendationsEndpoint}{modelsUrl}{modelId}/builds", JsonConvert.SerializeObject(request));

            return(JsonConvert.DeserializeObject <CreateBuildResponse>(response));
        }