/// <summary> /// Metodo para Guardar/Modificar una entidad LoteDistribucionAlimento /// </summary> /// <param name="info"></param> public int Guardar(LoteDistribucionAlimentoInfo info) { try { Logger.Info(); var loteDistribucionAlimentoDAL = new LoteDistribucionAlimentoDAL(); int result = info.LoteDistribucionAlimentoID; if (info.LoteDistribucionAlimentoID == 0) { result = loteDistribucionAlimentoDAL.Crear(info); } else { loteDistribucionAlimentoDAL.Actualizar(info); } return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Metodo para Crear un registro de LoteDistribucionAlimento /// </summary> /// <param name="info">Valores de la entidad que será creada</param> internal int Crear(LoteDistribucionAlimentoInfo info) { try { Logger.Info(); Dictionary <string, object> parameters = AuxLoteDistribucionAlimentoDAL.ObtenerParametrosCrear(info); int result = Create("LoteDistribucionAlimento_Crear", parameters); return(result); } catch (SqlException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (DataException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene un registro de LoteDistribucionAlimento /// </summary> /// <param name="loteDistribucionAlimentoID">Identificador de la LoteDistribucionAlimento</param> /// <returns></returns> internal LoteDistribucionAlimentoInfo ObtenerPorID(int loteDistribucionAlimentoID) { try { Logger.Info(); Dictionary <string, object> parameters = AuxLoteDistribucionAlimentoDAL.ObtenerParametrosPorID(loteDistribucionAlimentoID); DataSet ds = Retrieve("LoteDistribucionAlimento_ObtenerPorID", parameters); LoteDistribucionAlimentoInfo result = null; if (ValidateDataSet(ds)) { result = MapLoteDistribucionAlimentoDAL.ObtenerPorID(ds); } return(result); } catch (SqlException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (DataException ex) { Logger.Error(ex); throw new ExcepcionServicio(MethodBase.GetCurrentMethod(), ex); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Método que obtiene un registro /// </summary> /// <param name="ds"></param> /// <returns></returns> public static LoteDistribucionAlimentoInfo ObtenerPorID(DataSet ds) { try { Logger.Info(); DataTable dt = ds.Tables[ConstantesDAL.DtDatos]; LoteDistribucionAlimentoInfo entidad = (from info in dt.AsEnumerable() select new LoteDistribucionAlimentoInfo { LoteDistribucionAlimentoID = info.Field <int>("LoteDistribucionAlimentoID"), Lote = new LoteInfo { LoteID = info.Field <int>("LoteID"), Lote = info.Field <string>("Lote") }, TipoServicio = new TipoServicioInfo { TipoServicioId = info.Field <int>("TipoServicioID"), Descripcion = info.Field <string>("TipoServicio") }, EstatusDistribucion = new EstatusInfo { EstatusId = info.Field <int>("EstatusID"), Descripcion = info.Field <string>("Estatus") }, Fecha = info.Field <DateTime>("Fecha"), Activo = info.Field <bool>("Activo").BoolAEnum(), }).First(); return(entidad); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene una entidad LoteDistribucionAlimento por su Id /// </summary> /// <param name="loteDistribucionAlimentoID">Obtiene una entidad LoteDistribucionAlimento por su Id</param> /// <returns></returns> public LoteDistribucionAlimentoInfo ObtenerPorID(int loteDistribucionAlimentoID) { try { Logger.Info(); var loteDistribucionAlimentoDAL = new LoteDistribucionAlimentoDAL(); LoteDistribucionAlimentoInfo result = loteDistribucionAlimentoDAL.ObtenerPorID(loteDistribucionAlimentoID); return(result); } catch (ExcepcionGenerica) { throw; } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }
/// <summary> /// Obtiene parametros para crear /// </summary> /// <param name="info">Valores de la entidad</param> /// <returns></returns> public static Dictionary <string, object> ObtenerParametrosCrear(LoteDistribucionAlimentoInfo info) { try { Logger.Info(); var parametros = new Dictionary <string, object> { { "@LoteID", info.Lote.LoteID }, { "@TipoServicioID", info.TipoServicio.TipoServicioId }, { "@EstatusDistribucionID", info.EstatusDistribucion.EstatusId }, { "@Fecha", info.Fecha }, { "@Activo", info.Activo }, { "@UsuarioCreacionID", info.UsuarioCreacionID }, }; return(parametros); } catch (Exception ex) { Logger.Error(ex); throw new ExcepcionDesconocida(MethodBase.GetCurrentMethod(), ex); } }