/// <summary> /// Guarda la informacion de un arete muerto /// </summary> /// <param name="muerte"></param> /// <param name="esCargaInicial"></param> /// <param name="animal"></param> /// <returns></returns> internal int GuardarMuerte(MuerteInfo muerte, FlagCargaInicial esCargaInicial, AnimalInfo animal) { try { Logger.Info(); int resultado; using (var transaccion = new TransactionScope()) { if (animal != null) { var animalBL = new AnimalBL(); // Se valida el flag de EsCargaInicial switch (esCargaInicial) { case FlagCargaInicial.EsCargaInicial: var deteccionGrabar = new DeteccionInfo { CorralID = muerte.CorralId, LoteID = muerte.LoteId, UsuarioCreacionID = muerte.UsuarioCreacionID }; // Se intercambian aretes por encontrarse el animal en un corral distinto y ser carga inicial animalBL.ReemplazarAretes(animal, deteccionGrabar); break; case FlagCargaInicial.EsAreteNuevo: // Se Reemplaza arete nuevo sobre uno existente del lote animalBL.ReemplazarAreteMismoCorral(animal); break; } } if (muerte.Corral.GrupoCorral != GrupoCorralEnum.Recepcion.GetHashCode() && string.IsNullOrWhiteSpace(muerte.Arete)) { muerte.Arete = GenerarAreteGenerico(muerte); } var muerteDal = new MuerteDAL(); resultado = muerteDal.GuardarMuerte(muerte); // Se cierral la transaccion transaccion.Complete(); } return(resultado); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
internal int Guardar(DeteccionInfo deteccionGrabar, FlagCargaInicial esCargaInicial, AnimalInfo animal) { try { Logger.Info(); int resultado; var transactionOption = new TransactionOptions(); transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; using (var transaction = new TransactionScope(TransactionScopeOption.Required, transactionOption)) { if (animal != null) { var animalBL = new AnimalBL(); // Se valida el flag de EsCargaInicial switch (esCargaInicial) { case FlagCargaInicial.EsCargaInicial: // Se intercambian aretes por encontrarse el animal en un corral distinto y ser carga inicial animalBL.ReemplazarAretes(animal, deteccionGrabar); break; case FlagCargaInicial.EsAreteNuevo: // Se Reemplaza arete nuevo sobre uno existente del lote animalBL.ReemplazarAreteMismoCorral(animal); break; } } var deteccionDAL = new DeteccionDAL(); resultado = deteccionDAL.Guardar(deteccionGrabar); // Se cierral la transaccion transaction.Complete(); } return(resultado); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }