예제 #1
0
        public async Task <ActionResult> newHistoriaPsicologica([FromBody] HistoriaClinicaPsicologicaDTO model)
        {
            var txt = "Creating new HistoriaPsicologica by user => " + getUser();

            using (var transaction = context.Database.BeginTransaction())
            {
                logger.LogInformation("Begin Transaction {0}", txt);
                try
                {
                    var psicologica = await fundabiem.newHistoriaClinicaPsicologica(model);

                    transaction.Commit();
                    logger.LogInformation("Commit Transaction {0}", txt);
                    return(new CreatedAtRouteResult("ObtenerHistoriaPsicologica", new { id = psicologica.idHistoriaclinicaPsicologica }, psicologica));
                }
                catch (Exception ex)
                {
                    transaction.Rollback();
                    logger.LogInformation("RollBack transaction {0}", txt);
                    logger.LogError(ex.ToString());
                    return(BadRequest("No se completo la tarea de nuevo hisoriaclinicaPsicologica"));
                }
            }
        }