public ActionResult <IEnumerable <string> > Inventory(IFormFile file) { EncriptarSDES.StartKey(); if (file == null || file.Length == 0) { return(BadRequest("El archivo esta vacio o no selecciono ningun archivo.")); } BTree <Comp_Product> .Create(treeFile, new ToObject(Comp_Product.ConvertToObject), new ToString(Comp_Product.ConverttToString)); Comp_Product.LoadInventory(file.OpenReadStream()); return(Ok("Se han ingresado los valores con exito.")); }
public ActionResult <IEnumerable <string> > postProduct([FromForm] Comp_Product product) { EncriptarSDES.StartKey(); if (product._name != null && product._price >= 0) { BTree <Comp_Product> .Create(treeFile, new ToObject(Comp_Product.ConvertToObject), new ToString(Comp_Product.ConverttToString)); BTree <Comp_Product> .ValidateIncert(new Comp_Product { _id = BTree <Comp_Product> .KnowId(), _name = product._name, _price = product._price }); } else { return(BadRequest("Solicitud erronea.")); } return(Ok("Dato ingresado correctamente.")); }
public ActionResult <IEnumerable <string> > putProduct([FromForm] Comp_Product product) { EncriptarSDES.StartKey(); if (product._price < 0) { return(BadRequest("El precio del producto debe ser mayor a 0.")); } BTree <Comp_Product> .Create(treeFile, new ToObject(Comp_Product.ConvertToObject), new ToString(Comp_Product.ConverttToString)); if (BTree <Comp_Product> .Traversal(new Comp_Product { _id = product._id }, 1).Count == 0) { return(NotFound("El id no se encontro.")); } BTree <Comp_Product> .ValidateEdit(product, new string[2] { product._name, product._price.ToString() }, new Edit(Comp_Product.Modify)); return(Ok("El id: " + product._id + " fue actualizado.")); }