public async Task <IActionResult> Create([FromBody] CreateInputModel model) { //データの入力チェック if (!ModelState.IsValid) { return(JsonBadRequest("Invalid inputs.")); } if (string.IsNullOrWhiteSpace(model.Name)) { //名前に空文字は許可しない return(JsonBadRequest($"A name of Preprocessing is NOT allowed to set empty string.")); } if (model.GitModel != null && model.GitModel.IsValid() == false) { return(JsonBadRequest($"The input about Git is not valid.")); } Preprocess preprocessing = new Preprocess(); var errorResult = await SetPreprocessDetailsAsync(preprocessing, model); if (errorResult != null) { return(errorResult); } preprocessRepository.Add(preprocessing); unitOfWork.Commit(); return(JsonCreated(new IndexOutputModel(preprocessing))); }
public async Task <IActionResult> Create([FromBody] CreateInputModel model) { // データの入力チェック if (!ModelState.IsValid) { return(JsonBadRequest("Invalid inputs.")); } if (string.IsNullOrWhiteSpace(model.Name)) { // 名前に空文字は許可しない return(JsonBadRequest($"A name of Preprocessing is NOT allowed to set empty string.")); } if (model.GitModel != null && model.GitModel.IsValid() == false) { return(JsonBadRequest($"The input about Git is not valid.")); } // 各リソースの超過チェック Tenant tenant = tenantRepository.Get(CurrentUserInfo.SelectedTenant.Id); string errorMessage = clusterManagementLogic.CheckQuota(tenant, model.Cpu, model.Memory, model.Gpu); if (errorMessage != null) { return(JsonBadRequest(errorMessage)); } Preprocess preprocessing = new Preprocess(); var errorResult = await SetPreprocessDetailsAsync(preprocessing, model); if (errorResult != null) { return(errorResult); } preprocessRepository.Add(preprocessing); unitOfWork.Commit(); return(JsonCreated(new IndexOutputModel(preprocessing))); }