/// <summary> /// Actualiza el registro mediente el ID que contiene el objeto proporcionado como parametro. /// </summary> /// <param name="_ArticuloEntregado">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(ArticuloEntregado _ArticuloEntregado, ref string _InformacionDelError) { using (BDRestauranteEntities BBDD = new BDRestauranteEntities()) { try { ArticuloEntregado ObjetoActualizado = BBDD.ArticuloEntregado.SingleOrDefault(Identificador => Identificador.ID_ArticuloEntregado == _ArticuloEntregado.ID_ArticuloEntregado); if (ObjetoActualizado != null) { ObjetoActualizado.ID_ArticuloEntregado = _ArticuloEntregado.ID_ArticuloEntregado; 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="_ArticuloEntregado">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(ArticuloEntregado _ArticuloEntregado, ref string _InformacionDelError) { using (BDRestauranteEntities BBDD = new BDRestauranteEntities()) { try { BBDD.ArticuloEntregado.Add(_ArticuloEntregado); 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); } } }