public async Task <ActionResult> newCiclo([FromBody] CreateCicloRehabilitacionDTO ciclo) { string txt = "create ciclo de rehabilitacion {0} " + getUser(); using (var transaction = context.Database.BeginTransaction()) { logger.LogInformation("BeginTransaction {0}", txt); try { var cicloReha = await fundabiem.newCicloRehabilitacion(ciclo); transaction.Commit(); logger.LogInformation("Commit transaction {0}", txt); return(new CreatedAtRouteResult("ObtenerCicloRehabilitacion", new { id = cicloReha.idcicloRehabilitacion }, cicloReha)); } catch (Exception ex) { transaction.Rollback(); logger.LogError("RollBack transaction {0}", txt); logger.LogError(ex.ToString()); return(BadRequest()); } } }