public async Task <ActionResult> Update([FromRoute] Guid Id, [FromBody] TestIDTO test) { Boolean sucess = await _testUpdater.Update(Id, _mapper.Map <Test>(test)); if (sucess) { return(NoContent()); } return(NotFound()); }
public async Task <ActionResult> Patch([FromRoute] Guid Id, [FromBody] JsonPatchDocument <TestIDTO> patchDoc) { Test test = await _testFinder.FindById(Id); if (test.IsInvalid()) { return(NotFound()); } TestIDTO testToPatch = _mapper.Map <TestIDTO>(test); patchDoc.ApplyTo(testToPatch, ModelState); if (!TryValidateModel(testToPatch)) { return(ValidationProblem(ModelState)); } await _testUpdater.Update(Id, _mapper.Map <Test>(testToPatch)); return(NoContent()); }
public async Task <ActionResult <TestODTO> > Create([FromBody] TestIDTO test) { Test testCreated = await _testCreator.Add(_mapper.Map <Test>(test)); return(CreatedAtAction(nameof(GetById), new { Id = testCreated.Id }, _mapper.Map <TestODTO>(testCreated))); }