/// <summary> /// Actualiza el registro mediente el ID que contiene el objeto proporcionado como parametro. /// </summary> /// <param name="_EstadoClienteXPedido">Objeto que contiene los datos del registro al que se le van a actualizar los datos.</param> ///<param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el /// metodo devuelva null (debido a que ocurrio un error).</param> public int Actualizar(EstadoClienteXPedido _EstadoClienteXPedido, ref string _InformacionDelError) { using (BDRestauranteEntities BBDD = new BDRestauranteEntities()) { try { EstadoClienteXPedido ObjetoActualizado = BBDD.EstadoClienteXPedido.SingleOrDefault(Identificador => Identificador.ID_EstadoClienteXPedido == _EstadoClienteXPedido.ID_EstadoClienteXPedido); if (ObjetoActualizado != null) { return(BBDD.SaveChanges()); } else { return(0); } } catch (Exception Error) { _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" + $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" + $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" + $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " + $"ESTE ERROR PARA QUE SEA ARREGLADO."; return(0); } } }
/// <summary> /// Crea un nuevo registro a partir de los datos que contiene el objeto pasado por parametro. /// </summary> /// <param name="_EstadoClienteXPedido">Objeto que contiene los datos del nuevo registro que se creará.</param> ///<param name="_InformacionDelError">Devuelve una cadena de texto con informacion para el usuario en caso de que el /// metodo devuelva null (debido a que ocurrio un error).</param> public int Crear(EstadoClienteXPedido _EstadoClienteXPedido, ref string _InformacionDelError) { using (BDRestauranteEntities BBDD = new BDRestauranteEntities()) { try { BBDD.EstadoClienteXPedido.Add(_EstadoClienteXPedido); return(BBDD.SaveChanges()); } catch (Exception Error) { _InformacionDelError = $"OCURRIO UN ERROR INESPERADO AL INTENTAR LISTAR LA INFORMACIÓN: {Error.Message}\r\n\r\n" + $"ORIGEN DEL ERROR: {Error.StackTrace}\r\n\r\n" + $"OBJETO QUE GENERÓ EL ERROR: {Error.Data}\r\n\r\n\r\n" + $"ENVIE AL PROGRAMADOR UNA FOTO DE ESTE MENSAJE CON UNA DESCRIPCION DE LO QUE HIZO ANTES DE QUE SE GENERARÁ " + $"ESTE ERROR PARA QUE SEA ARREGLADO."; return(0); } } }