Example #1
0
 public Presupuesto(PersonaProveedora persona, EntidadJuridicaProveedora entidad, List<Item> items, Compra compra, string detalle, List<DocumentoComercial> documentosComerciales)
 {
     Persona = persona;
     Entidad = entidad;
     Items = items;
     Detalle = detalle;
     DocumentosComerciales = documentosComerciales;
     Compra = compra;
     ValorTotal = valorTotal();
 }
Example #2
0
 /*
 Al momento de crear la compra, ya le paso la lista de items con el valor total de cada uno, osea lo que salieron cuando compre. 
 Lo mismo pasa con el proveedor (ya compre, ya se el valor de los items, ya se a quien le compre)
 La compra que necesita presupuestos, NO necesariamente tiene que hacerse en base a uno de esos presupuestos. Basicamente puedo comprar donde quiera
 (y despues se validara la compra, pero no me importa)
  */
 public Compra( int cantidadDePresupuestosRequeridos, CriterioCompra criterio, List<Item> items, List<Usuario> revisores, PersonaProveedora persona, EntidadJuridicaProveedora entidad)
 {
     CantidadDePresupuestosRequeridos = cantidadDePresupuestosRequeridos;
     Bandeja = new List<Mensaje>();
     Revisores = new List<Usuario>() { };
     Criterio = criterio;
     Presupuestos = new List<Presupuesto>();
     Items = items;
     Revisores = revisores;
     Persona = persona;
     Entidad = entidad;
     ValorTotal = valorTotal();
 }
Example #3
0
                /*
                 * Crea x cantidad de objetos con valores aleatorios. Ejemplo:
                 * List<Usuario> usuarios = crear<Usuario>(20); // Crea una lista de 20 usuarios
                 *
                 * Si se necesita solo 1 objeto aleatorio, se puede hacer así:
                 * Usuario u = crear<Usuario>(1)[0];
                 */
                static List <T> crear <T>(int cantidad)
                {
                    var lista = new List <dynamic> {
                    };

                    using (var contexto = new DB_Context())
                    {
                        for (int i = 0; i < cantidad; i++)
                        {
                            Random random      = new Random();
                            var    actividades = new List <Actividad> {
                                new Servicios(), new Agropecuario(), new Comercio(), new IndustriaYMineria(), new Construccion()
                            };

                            //if (typeof(Usuario) == typeof(T))
                            //    lista.Add(new Usuario("Usuario-" + i.ToString(), "Contraseña-" + i.ToString()));

                            if (typeof(Mensaje) == typeof(T))
                            {
                                lista.Add(new Mensaje("Texto-" + i.ToString()));
                            }

                            if (typeof(Criterio) == typeof(T))
                            {
                                lista.Add(new Criterio("NombreCriterio-" + i.ToString(), null));
                            }

                            if (typeof(Categoria) == typeof(T))
                            {
                                lista.Add(new Categoria("NombreCategoria-" + i.ToString(), new Criterio("NombreCriterio-" + i.ToString(), null)));
                            }

                            if (typeof(Item) == typeof(T))
                            {
                                lista.Add(new Item("Nombre-" + i.ToString(), "Descripcion-" + i.ToString(), random.Next(50, 6000), crear <Categoria>(random.Next(1, 3))));
                            }

                            if (typeof(MedioDePago) == typeof(T))
                            {
                                lista.Add(new MedioDePago("AR", random.Next(0, 10).ToString(), "TipoDePago-" + i.ToString()));
                            }

                            if (typeof(DocumentoComercial) == typeof(T))
                            {
                                lista.Add(new DocumentoComercial(random.Next(0, 10), "TipoDocumento-" + i.ToString()));
                            }

                            if (typeof(PersonaProveedora) == typeof(T))
                            {
                                lista.Add(new PersonaProveedora(crear <Direccion>(1)[0], random.Next(00000000, 99999999).ToString(), "Nombre-" + i.ToString()));
                            }

                            if (typeof(EntidadJuridicaProveedora) == typeof(T))
                            {
                                lista.Add(new EntidadJuridicaProveedora(crear <Direccion>(1)[0], "CodigoInscripcion-" + i.ToString(), "CUIT-" + i.ToString(), "RazonSocial-" + i.ToString()));
                            }

                            if (typeof(OperacionDeEgreso) == typeof(T))
                            {
                                lista.Add(new OperacionDeEgreso(crear <Compra>(1)[0], crear <MedioDePago>(1)[0], crear <DocumentoComercial>(random.Next(1, 5)), DateTime.Now));
                            }

                            if (typeof(OperacionDeIngreso) == typeof(T))
                            {
                                lista.Add(new OperacionDeIngreso("Descripcion-" + i.ToString(), null, random.Next(10, 100000), DateTime.Now));
                            }

                            if (typeof(Presupuesto) == typeof(T))
                            {
                                lista.Add(new Presupuesto(null, null, crear <Item>(random.Next(0, 5)), null, "Detalle-" + i.ToString(), crear <DocumentoComercial>(random.Next(0, 5))));
                            }

                            if (typeof(Direccion) == typeof(T))
                            {
                                lista.Add(new Direccion("Calle-" + i.ToString(), i.ToString(), i, null));
                            }

                            if (typeof(Compra) == typeof(T))
                            {
                                PersonaProveedora         pp  = null;
                                EntidadJuridicaProveedora ejp = null;
                                int presReq      = random.Next(0, 5);
                                var presupuestos = crear <Presupuesto>(presReq);
                                var mensajes     = crear <Mensaje>(random.Next(0, 5));

                                // Para crear la compra con proveedor
                                if (random.Next(0, 2) == 0)
                                {
                                    pp = crear <PersonaProveedora>(1)[0];
                                }
                                else
                                {
                                    ejp = crear <EntidadJuridicaProveedora>(1)[0];
                                }

                                var c = new Compra(presReq, new MenorValor(), crear <Item>(random.Next(0, 5)), null, pp, ejp);

                                for (int j = 0; j < presReq; j++)
                                {
                                    c.agregarPresupuesto(presupuestos[j]);
                                }

                                for (int k = 0; k < mensajes.Count; k++)
                                {
                                    c.agregarMensaje(mensajes[k].texto);
                                }

                                lista.Add(c);
                            }

                            //Está comentado porque crea todas las orgs con el mismo nombre
                            if (typeof(Organizacion) == typeof(T))
                            {
                                if (random.Next(0, 2) == 0)
                                {
                                    lista.Add(crear <Empresa>(1)[0]);
                                }
                                else
                                {
                                    lista.Add(crear <OSC>(1)[0]);
                                }
                            }

                            if (typeof(Empresa) == typeof(T))
                            {
                                EntidadBase     eb = null;
                                EntidadJuridica ej = null;

                                if (random.Next(0, 2) == 0)
                                {
                                    eb = crear <EntidadBase>(1)[0];
                                }
                                else
                                {
                                    ej = crear <EntidadJuridica>(1)[0];
                                }

                                lista.Add(
                                    new Empresa(
                                        actividades[random.Next(0, 5)],
                                        random.Next(0, 50),
                                        random.Next(0, 1) == 0,
                                        "NombreEmpresa-" + i.ToString(),
                                        random.Next(1000, 100000),
                                        eb,
                                        ej,
                                        crear <Usuario>(random.Next(0, 10)))
                                    );
                            }

                            if (typeof(OSC) == typeof(T))
                            {
                                EntidadBase     eb = null;
                                EntidadJuridica ej = null;

                                if (random.Next(0, 2) == 0)
                                {
                                    eb = crear <EntidadBase>(1)[0];
                                }
                                else
                                {
                                    ej = crear <EntidadJuridica>(1)[0];
                                }

                                lista.Add(new OSC(
                                              actividades[random.Next(0, 4)],
                                              random.Next(0, 50),
                                              "NombreOSC-" + i.ToString(),
                                              random.Next(1000, 100000),
                                              eb,
                                              ej,
                                              crear <Usuario>(random.Next(0, 10)))
                                          );
                            }

                            if (typeof(TipoEntidad) == typeof(T))
                            {
                                if (random.Next(0, 2) == 0)
                                {
                                    lista.Add(crear <EntidadBase>(1));
                                }
                                else
                                {
                                    lista.Add(crear <EntidadJuridica>(1));
                                }
                            }

                            if (typeof(EntidadBase) == typeof(T))
                            {
                                EntidadJuridica ej = crear <EntidadJuridica>(1)[0];
                                ej.BasesAsociadas = new List <EntidadBase> {
                                };                                             // Vacio las entidades base aleaotrias creadas
                                EntidadBase eb = new EntidadBase("Descripción-" + i.ToString(), ej, crear <Direccion>(1)[0]);
                                ej.BasesAsociadas.Add(eb);

                                lista.Add(eb);
                            }

                            if (typeof(EntidadJuridica) == typeof(T))
                            {
                                var eb = new List <EntidadBase> {
                                };

                                if (random.Next(0, 10) > 7)
                                {
                                    eb = crear <EntidadBase>(random.Next(0, 3));
                                }

                                lista.Add(new EntidadJuridica(eb, "CodigoInscripción-" + i.ToString(), "CUIT-" + i.ToString(), crear <Direccion>(1)[0], "RazonSocial-" + i.ToString()));
                            }
                        }
                    }

                    return(lista.Cast <T>().ToList());
                }