public async Task <IActionResult> Post([FromBody] CreateValueResource createValueResource) { var value = _mapper.Map <Value>(createValueResource); _valueRepository.Add(value); await _unitOfWork.CompleteAsync(); return(CreatedAtRoute(nameof(Get), new { id = value.Id }, _mapper.Map <ValueResource>(value))); }
public async Task <IActionResult> Post([FromBody] string value) { var x = new Value { Name = value }; await _repository.Add(x); return(Ok(new { x.Id })); }
public ValueDto Add(ValueDto value) { if (value == null) { throw new ArgumentNullException(); } var entity = _mapper.Map <ValueDto, Value>(value); value = _mapper.Map <Value, ValueDto>(_valueRepository.Add(entity)); return(value); }
private MessageCode SaveValue(Value value, UpdateMessage message) { var mainMetric = _metricRepository.GetMainByExternalId(message.ChatId); if (mainMetric == null) { return(MessageCode.ValueWithoutMetric); } value.UpdateMetric(mainMetric); value = _valueRepository.Add(value); _logger.LogDebug($"Saved value {value.Content} {value.ValueDate} with id {value.Id}"); return(MessageCode.Done); }
public async Task <IActionResult> Post([FromForm] ValueForAddedDto valueForAdded) { var value = mapper.Map <Value>(valueForAdded); var file = valueForAdded.File; repository.Add(value); if (await repository.SaveAll()) { await SavePhoto(value, file); return(Ok(value)); } return(BadRequest("Nie udało sie dodać do bazy")); }
public ActionResult <ValueDto> Add([FromBody] ValueCreateDto valueCreateDto) { if (valueCreateDto == null) { return(BadRequest()); } Value toAdd = Mapper.Map <Value>(valueCreateDto); _valueRepository.Add(toAdd); if (!_valueRepository.Save()) { throw new Exception("Creating an item failed on save."); } Value newItem = _valueRepository.GetSingle(toAdd.Id); return(CreatedAtRoute(nameof(GetSingle), new { id = newItem.Id }, Mapper.Map <ValueDto>(newItem))); }
public async Task <Value> Add([FromBody] ValueInput value) { return(await repo.Add(value)); }
public void Post([FromBody] ValueModel value) { _valueRepository.Add(value); }
public async Task InsertValue(Value entity) { await _valueRepository.Add(entity); }
public IActionResult Post([FromBody] IValue value) { _valueRepository.Add(value); return(Ok()); }