public IActionResult Create([FromBody] CreateInputModel model) { //データの入力チェック if (!ModelState.IsValid) { return(JsonBadRequest("Invalid inputs.")); } if (string.IsNullOrWhiteSpace(model.Name)) { //名前に空文字は許可しない return(JsonBadRequest($"A name of Data is NOT allowed to set empty string.")); } // データの登録 Data newData = new Data() { // 名前の前後の空白文字を除去して設定する。 Name = model.Name.Trim(), Memo = model.Memo, }; //タグの登録 if (model.Tags != null && model.Tags.Count() > 0) { tagLogic.Create(newData, model.Tags); } dataRepository.Add(newData); // DBへのコミット unitOfWork.Commit(); return(JsonCreated(new IndexOutputModel(newData))); }
public void Post([FromBody] CreateTagUICommand command) { Execute(() => { _tagLogic.Create(command); }); }
public async Task <IActionResult> UploadPreprocessImage([FromRoute] long id, [FromRoute] long dataId, [FromBody] AddOutputDataInputModel model, [FromServices] ITagLogic tagLogic, [FromServices] IDataRepository dataRepository) { if (!ModelState.IsValid) { return(JsonBadRequest("Invalid inputs.")); } //データの存在チェック var preprocessHistory = await preprocessHistoryRepository.GetPreprocessIncludeDataAndPreprocessAsync(id, dataId); if (preprocessHistory == null) { return(JsonNotFound($"Preprocessing History about Preprocess {id} to Data {dataId} is not found.")); } var status = ContainerStatus.Convert(preprocessHistory.Status); if (status.IsOpened() == false) { //追加できるのは開放中のコンテナだけ(ローカルの結果を追加することがあるので、Runningとは限らない) return(JsonBadRequest($"Preprocessing History {preprocessHistory.Id} is not opened.")); } //データを追加する Data newData = new Data() { //データ名が未指定であれば、デフォルトの値を入れる Name = string.IsNullOrEmpty(model.Name) ? $"{preprocessHistory.InputData.Name}_{preprocessHistory.Preprocess.Name}" : model.Name, Memo = model.Memo, ParentDataId = preprocessHistory.InputDataId }; dataRepository.Add(newData); foreach (var file in model.Files) { dataRepository.AddFile(newData, file.FileName, file.StoredPath); } //タグの登録 if (model.Tags != null && model.Tags.Count() > 0) { tagLogic.Create(newData, model.Tags); } else { //タグが未指定であれば、前処理名を付ける List <string> tags = new List <string>() { preprocessHistory.Preprocess.Name }; tagLogic.Create(newData, tags); } preprocessHistoryRepository.AddOutputData(preprocessHistory.Id, newData); unitOfWork.Commit(); return(JsonOK(new HistoriesOutputModel(preprocessHistory))); }