Exemplo n.º 1
0
        public Subcategoria AgregarSubcategoria(string nombre, string descripcion, CategoriaEstado estado)
        {
            var errores = PuedeAgregarSubcategoria(nombre, descripcion, estado);

            if (errores.Any())
            {
                throw new System.InvalidOperationException(string.Join(',', errores));
            }
            var subcategoria = new Subcategoria
            {
                Nombre      = nombre,
                Descripcion = descripcion,
                Estado      = estado
            };

            Subcategorias.Add(subcategoria);
            return(subcategoria);
        }
Exemplo n.º 2
0
        public List <string> PuedeAgregarSubcategoria(string nombre, string descripcion, CategoriaEstado estado)
        {
            List <string> errores = new List <string>();

            if (string.IsNullOrEmpty(nombre))
            {
                errores.Add("Debe especificar un nombre");
            }
            return(errores);
        }