public async Task <IActionResult> Add([FromBody] ClipboardAddBindingModel collection) { try { var model = _mapper.Map <ClipboardAddSchema>(collection); var query = new ClipboardGetFirstSchema { AccountId = CurrentAccount.Id, Content = model.Content }; var duplicated = await _clipboardService.FirstAsync(query).ConfigureAwait(true); if (duplicated == null) { await _clipboardService.AddAsync(model).ConfigureAwait(true); return(Ok()); } return(BadRequest(_localizer[DataTransferer.DuplicatedValueFound().Message])); } catch (Exception ex) { Log.Error(ex, ex.Source); return(Problem()); } }
public void First() { var query = new ClipboardGetFirstSchema { Id = 1 }; var clipboard = _clipboardService.FirstAsync(query).GetAwaiter().GetResult(); Assert.IsTrue(query.StatusCode == 200); Assert.IsTrue(clipboard != null); }
public async Task <ClipboardResult> FirstAsync(ClipboardGetFirstSchema clipboard) { var result = await _storedProcedure.QueryFirstAsync <ClipboardGetFirstSchema, ClipboardResult>(clipboard); return(result); }