public async Task Execute(CreateObjectMapping command) { //create the survey object mapping object (purpose of the command) var mapping = new SurveyObjectMapping { IdQuestion = command.QuestionId, CdMappingtype = command.MappingType, NmMapvalue = command.MappingValue }; await writeContext.SurveyObjectMapping.AddAsync(mapping); await writeContext.SaveChangesAsync(); }
public async Task <IActionResult> PostMappingAsync([FromBody] CreateObjectMapping command) { await rules .NoDuplicateMapping() .Apply(command, ModelState); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await service.Execute(command); var uri = Url.Action("Get", new { questionId = command.QuestionId, mappingType = command.MappingType }); return(Created(uri, command)); }