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)));
        }
Ejemplo n.º 2
0
 public void Put(int id, [FromBody] ValueModel value)
 {
     _valueRepository.Save(id, value);
 }