public async Task <IActionResult> EditQuotas([FromBody] IEnumerable <QuotaInputModel> models, [FromServices] ITenantRepository tenantRepository) { //データの入力チェック if (!ModelState.IsValid) { return(JsonBadRequest("Invalid inputs.")); } var result = new List <QuotaOutputModel>(); foreach (var inputModel in models) { //更新用に、キャッシュではなくDBから直接取得 Tenant tenant = await tenantRepository.GetTenantForUpdateAsync(inputModel.TenantId.Value); if (tenant == null) { return(JsonNotFound($"Tenant ID {inputModel.TenantId.Value} is not found.")); } tenant.LimitCpu = inputModel.Cpu == 0 ? (int?)null : inputModel.Cpu; tenant.LimitMemory = inputModel.Memory == 0 ? (int?)null : inputModel.Memory; tenant.LimitGpu = inputModel.Gpu == 0 ? (int?)null : inputModel.Gpu; //結果に格納 result.Add(new QuotaOutputModel(tenant)); await clusterManagementLogic.SetQuotaAsync(tenant); } unitOfWork.Commit(); tenantRepository.Refresh(); return(JsonOK(result)); }