public bool AgregarCategoria(string descripcion) { try { if (BuscarCategoria(descripcion)) { return(false); } else { Modelo.CATEGORIA categoria = new Modelo.CATEGORIA(); categoria.DESCRIPCION = Descripcion; ConectorDALC.ModeloAlmacen.CATEGORIA.Add(categoria); ConectorDALC.ModeloAlmacen.SaveChanges(); return(true); } } catch (Exception ex) { return(false); throw new ArgumentException("Error al agregar categoria" + ex); } }
public bool BuscarCategoria(string descripcion) { try { Modelo.CATEGORIA tipo = ConectorDALC.ModeloAlmacen.CATEGORIA.FirstOrDefault(c => c.DESCRIPCION == descripcion); if (tipo != null) { return(true); } else { return(false); } } catch (Exception ex) { return(false); throw new ArgumentException("Error al buscar" + ex); } }
public bool EliminarCategoria(string descripcion) { try { if (BuscarCategoria(descripcion)) { Modelo.CATEGORIA categoria = ConectorDALC.ModeloAlmacen.CATEGORIA.FirstOrDefault(c => c.DESCRIPCION == descripcion); ConectorDALC.ModeloAlmacen.CATEGORIA.Remove(categoria); ConectorDALC.ModeloAlmacen.SaveChanges(); return(true); } else { return(false); } } catch (Exception ex) { return(false); throw new ArgumentException("Error al eliminar categoria: " + ex); } }