示例#1
0
        public void Add([FromForm] ProductData info)
        {
            ArbolB <ProductData> .IniciarArbol("Product", new StringToObject(ProductData.StringToObject), new ObjectToString(ProductData.ObjectToString));

            SDES.obtainKey();
            ArbolB <ProductData> .InsertarArbol(new ProductData { ID = ArbolB <ProductData> .newID(), Name = info.Name, Price = info.Price });
        }
示例#2
0
        public ActionResult Add([FromBody] Movie[] NMovie)
        {
            try
            {
                var grado = 7;
                var path  = Path.Combine(Environment.CurrentDirectory, "arbol.txt");
                if (!ArbolB <Movie> .ExisteArbol())
                {
                    string text = $"{grado.ToString("0000;-0000")}|0000|0001|";
                    System.IO.File.WriteAllText(path, text);
                }

                var PtS = new MovieToSring(Movie.MovieToString);
                var StP = new StringToMovie(Movie.StringToMovie);
                for (int i = 0; i < NMovie.Length; i++)
                {
                    ArbolB <Movie> .InsertarArbol(NMovie[i], StP, PtS);
                }
                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
示例#3
0
        public void Add([FromForm] OfficeData info)
        {
            ArbolB <OfficeData> .IniciarArbol("Office", new StringToObject(OfficeData.StringToObject), new ObjectToString(OfficeData.ObjectToString));

            SDES.obtainKey();
            ArbolB <OfficeData> .InsertarArbol(new OfficeData { ID = ArbolB <OfficeData> .newID(), Name = info.Name, Address = info.Address });
        }
示例#4
0
        public void transfer([FromForm] int idProduct, [FromForm] int idO1, [FromForm] int idO2, [FromForm] int cant)
        {
            SDES.obtainKey();
            ArbolB <OfficeProduct> .IniciarArbol("OfficeProduct", new StringToObject(OfficeProduct.StringToObject), new ObjectToString(OfficeProduct.ObjectToString));

            var data1 = ArbolB <OfficeProduct> .Recorrido(new OfficeProduct { IdOffice = idO1, IdProduct = idProduct }, 1);

            var data2 = ArbolB <OfficeProduct> .Recorrido(new OfficeProduct { IdOffice = idO2, IdProduct = idProduct }, 1);

            if (data1.Count != 0 && data1[0].Inventory - cant >= 0)
            {
                if (data2.Count == 0)
                {
                    ArbolB <OfficeProduct> .InsertarArbol(new OfficeProduct { IdOffice = idO2, IdProduct = idProduct, Inventory = cant });
                }
                else
                {
                    data2[0].Inventory = data2[0].Inventory + cant;
                    ArbolB <OfficeProduct> .Modificar(data2[0], new string[2] {
                        data2[0].Inventory.ToString(), string.Empty
                    }, new Modify(OfficeProduct.Alter));
                }
                data1[0].Inventory = data1[0].Inventory - cant;
                ArbolB <OfficeProduct> .Modificar(data1[0], new string[2] {
                    data1[0].Inventory.ToString(), string.Empty
                }, new Modify(OfficeProduct.Alter));
            }
        }
示例#5
0
        public void Add([FromForm] OfficeProduct info)
        {
            ArbolB <OfficeProduct> .IniciarArbol("OfficeProduct", new StringToObject(OfficeProduct.StringToObject), new ObjectToString(OfficeProduct.ObjectToString));

            SDES.obtainKey();
            ArbolB <OfficeProduct> .InsertarArbol(new OfficeProduct { IdOffice = info.IdOffice, IdProduct = info.IdProduct, Inventory = info.Inventory });
        }
        public static void InsertCSV(Stream info)
        {
            using (var archive = new StreamReader(info))
            {
                var line = string.Empty;
                while ((line = archive.ReadLine()) != null)
                {
                    var entreComillas = false;
                    var partes        = new List <string>();
                    var aux           = string.Empty;
                    foreach (var caracter in line)
                    {
                        if (entreComillas)
                        {
                            if (caracter == '\"')
                            {
                                entreComillas = false;
                            }
                            else
                            {
                                aux += caracter;
                            }
                        }
                        else
                        {
                            if (caracter == ',')
                            {
                                partes.Add(aux);
                                aux = string.Empty;
                            }
                            else if (caracter == '\"')
                            {
                                entreComillas = true;
                            }
                            else
                            {
                                aux += caracter;
                            }
                        }
                    }
                    if (aux != string.Empty)
                    {
                        partes.Add(aux);
                    }

                    ArbolB <ProductData> .InsertarArbol(new ProductData { ID = ArbolB <ProductData> .newID(), Name = partes[0], Price = Convert.ToDouble(partes[1]) });
                }
            }
        }
示例#7
0
        public void Agregar([FromForm] Producto dato)
        {
            ArbolB <Producto> .IniciarArbol("Productos", new StringToObject(Producto.StringToProducto), new ObjectToString(Producto.ProductoToString));

            ArbolB <Producto> .InsertarArbol(dato);
        }