Exemplo n.º 1
0
 public int Insert(Editorial model)
 {
     model.idEditorial  = SequenceTools.NextValSequence("EDITORIAL_SEQ");
     model.maximoLibros = model.maximoLibros ?? -1;
     _repository.Insert(model);
     return(model.idEditorial);
 }
Exemplo n.º 2
0
 private IEnumerable <IEnumerable <Type> > AllGenericBase(Type def, IEnumerable <Type> args, Type[] tparams, Type[] targs, int pos)
 {
     if (pos >= targs.Length)
     {
         Type con;
         try{
             con = def.MakeGenericType(targs);
         }catch (ArgumentException)
         {
             yield break;
         }
         yield return(new Type[] { con });
     }
     else
     {
         foreach (Type t in args)
         {
             if (!ConstraintsOkay(tparams[pos], t))
             {
                 continue;
             }
             targs[pos] = t;
             yield return(SequenceTools.SelectManyInfinite(AllGenericBase(def, args, tparams, (Type[])targs.Clone(), pos + 1)));
         }
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// Returns all constructed generic types from a type.
 /// </summary>
 /// <param name="def">The type definition.</param>
 /// <param name="args">The possible type arguments.</param>
 public IEnumerable <Type> AllGeneric(Type def, IEnumerable <Type> args)
 {
     if (!def.IsGenericTypeDefinition)
     {
         return(Type.EmptyTypes);
     }
     Type[] tparams = def.GetGenericArguments();
     Type[] targs   = new Type[tparams.Length];
     return(SequenceTools.SelectManyInfinite(AllGenericBase(def, args, tparams, targs, 0)));
 }
Exemplo n.º 4
0
 private IEnumerable <Type> AllGenericTypes(IEnumerable <Type> source)
 {
     if (Generic)
     {
         return(SequenceTools.SelectManyInfinite(source.Select(t => AllGenericItself(t, AllTypes(source)))));
     }
     else
     {
         return(source);
     }
 }
Exemplo n.º 5
0
 public int Insert(Libro model)
 {
     //validacion
     using (var context = new LibreriaDBContext())
     {
         var maxLibros = (from e in context.editorial
                          where e.idEditorial == model.idEditorial
                          select e.maximoLibros).FirstOrDefault();
         var librosTotales = context.libro.Where(x => x.idEditorial == model.idEditorial).Select(x => x).Count();
         //var librosTotales = (from l in context.libro
         //                     where l.idEditorial == model.idEditorial
         //                     select l.idLibro).Count();
         if (maxLibros == librosTotales)
         {
             throw new Exception("No es posible registrar el libro, se alcanzó el máximo permitido");
         }
         model.idLibro = SequenceTools.NextValSequence("LIBRO_SEQ");
         _repository.Insert(model);
         return(model.idAutor);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Returns all constructed generic types from a type. Also yields the definition.
        /// </summary>
        /// <param name="def">The type definition.</param>
        /// <param name="args">The possible type arguments.</param>
        public IEnumerable <Type> AllGenericItself(Type def, IEnumerable <Type> args)
        {
            yield return(def);

            if (!def.IsGenericTypeDefinition)
            {
                yield break;
            }
            if (GenericParameters)
            {
                var tparams = def.GetGenericArguments();
                foreach (Type t in tparams)
                {
                    yield return(t);
                }
                args = SequenceTools.SelectManyOuter(args, tparams);
            }
            foreach (Type t in AllGeneric(def, args))
            {
                yield return(t);
            }
        }
Exemplo n.º 7
0
        private IEnumerable <Type> AllDerivedBase(Type type)
        {
            if (
                !type.IsByRef && (!type.IsGenericTypeDefinition || DerivedFromOpenGeneric) &&
                (DerivedFromStatic || (!type.IsAbstract || !type.IsSealed))
                )
            {
                IEnumerable <Type> byrefs   = Type.EmptyTypes;
                IEnumerable <Type> pointers = Type.EmptyTypes;
                if (Pointers)
                {
                    if (ReferenceTypePointers || (type.IsValueType || type.IsPointer))
                    {
                        try{
                            pointers = AllDerivedRecursive(type.MakePointerType());
                        }catch (TypeLoadException)
                        {
                        }
                    }
                }
                if (ByRefs)
                {
                    try{
                        byrefs = AllDerivedRecursive(type.MakeByRefType());
                    }catch (TypeLoadException)
                    {
                    }
                }

                var arrays = AllArrays(type).Select(t => AllDerivedRecursive(t));

                return(SequenceTools.SelectManyOuter(new[] { byrefs, pointers }.Concat(arrays)));
            }
            else
            {
                return(Type.EmptyTypes);
            }
        }
Exemplo n.º 8
0
 /// <summary>
 /// Enumerates all types constructed from the input.
 /// </summary>
 /// <param name="source">The input types.</param>
 public IEnumerable <Type> AllTypes(IEnumerable <Type> source)
 {
     return(SequenceTools.SelectManyInfinite(AllGenericTypes(source).Select(t => AllDerivedRecursive(t))));
 }
Exemplo n.º 9
0
 public int Insert(Autor model)
 {
     model.idAutor = SequenceTools.NextValSequence("AUTOR_SEQ");
     _repository.Insert(model);
     return(model.idAutor);
 }
Exemplo n.º 10
0
 public int Insert(Genero model)
 {
     model.idGenero = SequenceTools.NextValSequence("GENERO_SEQ");
     _repository.Insert(model);
     return(model.idGenero);
 }