public async Task Execute(UpdateObjectMapping command) { var mapping = await writeContext.SurveyObjectMapping.FindAsync(command.QuestionId, command.MappingType); if (mapping == null) { throw new EntityNotFoundException(typeof(SurveyObjectMapping), new { command.QuestionId, command.MappingType }); } mapping.IdQuestion = command.QuestionId; mapping.CdMappingtype = command.MappingType; mapping.NmMapvalue = command.MappingValue; await writeContext.SaveChangesAsync(); }
public async Task <IActionResult> PutMappingAsync([FromBody] UpdateObjectMapping command) { await rules .NoDuplicateMapping() .Apply(command, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await service.Execute(command); return(Ok()); }