Esempio n. 1
0
 public static void InputOutputInsert(InputOutputEntity inputOutputEntity)
 {
     using (var contexto = new InventaryContext())
     {
         contexto.InputOutputs.Add(inputOutputEntity);
         contexto.SaveChanges();
     }
 }
Esempio n. 2
0
 public void CreateCategory(InputOutputEntity oInOut)
 {
     using (var db = new InventaryContext())
     {
         db.InOuts.Add(oInOut);
         db.SaveChanges();
     }
 }
 public void UpdateInputOutput(InputOutputEntity inuout)
 {
     using (var db = new InventaryContext())
     {
         db.InputOutputs.Update(inuout);
         db.SaveChanges();
     }
 }
 public static void UpdateOutput(InputOutputEntity oOutput)
 {
     using (var db = new InventaryContext())
     {
         db.InOuts.Update(oOutput);
         db.SaveChanges();
     }
 }
Esempio n. 5
0
 public void InputOutputUpdate(InputOutputEntity inputOutputEntity)
 {
     using (var contexto = new InventaryContext())
     {
         contexto.InputOutputs.Update(inputOutputEntity);
         contexto.SaveChanges();
     }
 }
 public void CreateInputOutput(InputOutputEntity inout)
 {
     using (var db = new InventaryContext())
     {
         db.InputOutputs.Add(inout);
         db.SaveChanges();
     }
 }
Esempio n. 7
0
 public static void UpdateInputOutput(InputOutputEntity inputOutput)
 {
     using (var db = new InventoryContext())
     {
         db.InputOutputs.Add(inputOutput);
         db.SaveChanges();
     }
 }
Esempio n. 8
0
 public Task DeleteInputOutput(InputOutputEntity oOutput)
 {
     using (var db = new EntitiesContext())
     {
         db.InOuts.Remove(oOutput);
         return(Task.FromResult(db.SaveChanges()));
     }
 }
Esempio n. 9
0
 public void UpdateItem(InputOutputEntity item)
 {
     using (var db = new InventarioContext())
     {
         db.InOuts.Update(item);
         db.SaveChanges();
     }
 }
Esempio n. 10
0
 public void UpdateInputOutput(InputOutputEntity objInputOutput)
 {
     using (var db = new InventoryContext())
     {
         db.InOut.Update(objInputOutput);
         db.SaveChanges();
     }
 }
 public void DeleteInOut(InputOutputEntity oInOut)
 {
     using (var db = new InventoryContext())
     {
         db.Remove(oInOut);
         db.SaveChanges();
     }
 }
        public static void CreateInputOutput(InputOutputEntity inputOutput)
        {
            using (var db = new InventoryContext())
            {
                inputOutput.Date = DateTime.Now;
                db.InputOutputs.Add(inputOutput);

                db.SaveChanges();
            }
        }
Esempio n. 13
0
        public static Business_Response ValidateCreateInputOutput(InputOutputEntity oInputOutput)
        {
            using var db = new InventoryContext();
            var inputOutputs           = db.InputOutputs.ToList();
            var storages               = db.Storages.ToList();
            Business_Response response = new Business_Response();

            //Referencia
            do
            {
                oInputOutput.InputOutputId = Guid.NewGuid().ToString();//Asigna un identificador a la bodega hasta garantizar que sea único.
            } while (inputOutputs.Where(io => io.InputOutputId == oInputOutput.InputOutputId).Any());

            //Asignar la hora actual.
            oInputOutput.InputOutputDate = DateTime.Now;

            InputOutputEntity cInputOutput = (InputOutputEntity)oInputOutput.Clone();

            //Identificador del almacenamiento válido.
            if (!storages.Where(st => st.StorageId == cInputOutput.StorageId).Any())
            {
                response.Error = true;
                response.ErrorMessages.Add($"La referencia del producto seleccionado no existe.");
                if (cInputOutput.Quantity < 1)
                {
                    response.Error = true;
                    response.ErrorMessages.Add($"La cantidad debe ser mayor o igual a 1.");
                }
            }
            else
            {
                var oStorage = storages.LastOrDefault(s => s.StorageId == oInputOutput.StorageId);//Evita volver a leer desde la base de datos Business_Storage.StorageById(oInputOutput.StorageId);
                var oProduct = oStorage.Product;
                if (cInputOutput.Quantity < 1)
                {
                    response.Error = true;
                    response.ErrorMessages.Add($"La cantidad debe ser mayor o igual a 1.");
                }
                else
                {
                    if (!oInputOutput.IsInput && (oInputOutput.Quantity > oStorage.PartialQuantity))
                    {
                        response.Error = true;
                        response.ErrorMessages.Add($"La cantidad a retirar ({oInputOutput.Quantity}) es mayor que la cantidad del almacen ({oStorage.PartialQuantity}).");
                    }
                }
            }
            return(response);
        }
Esempio n. 14
0
 public Task CreateOutput(InputOutputEntity oOutput)
 {
     using (var db = new EntitiesContext())
     {
         using (var transaction = db.Database.BeginTransaction())
         {
             if (oOutput.WhereHouse != null && oOutput.Product != null)
             {
                 if (db.Storages.Any(s => s.Product.Id == oOutput.Product.Id && s.WhereHouse.Id == oOutput.WhereHouse.Id))
                 {
                     oOutput.Storage = db.Storages.Where(s => s.Product.Id == oOutput.Product.Id && s.WhereHouse.Id == oOutput.WhereHouse.Id).FirstOrDefault();
                     oOutput.Storage.PartialQuantity = oOutput.IsInput == true ? oOutput.Storage.PartialQuantity + oOutput.Quantity : oOutput.Storage.PartialQuantity - oOutput.Quantity;
                     db.Storages.Update(oOutput.Storage);
                     db.SaveChanges();
                 }
                 else
                 {
                     StorageEntity storageEntity = new StorageEntity()
                     {
                         LasUpdate       = DateTime.Now,
                         PartialQuantity = oOutput.Quantity,
                         Product         = db.Products.Find(oOutput.Product.Id),
                         WhereHouse      = db.WhereHouses.Find(oOutput.WhereHouse.Id)
                     };
                     db.Storages.Add(storageEntity);
                     db.SaveChanges();
                     oOutput.Storage = storageEntity;
                 }
             }
             oOutput.Storage = oOutput.Storage == null ? null : db.Storages.Find(oOutput.Storage.Id);
             db.InOuts.Add(oOutput);
             db.SaveChanges();
             transaction.Commit();
         }
         return(Task.FromResult(db.SaveChanges()));
     }
 }
Esempio n. 15
0
 public static void UpdateInputOutput(InputOutputEntity oInputOutput)
 {
     using var db = new InventoryContext(); //Ejecuta dispose (Limpiar memoria) cuando ya no se usa db.
     db.InputOutputs.Update(oInputOutput);  //Actualiza el valor en el objeto.
     db.SaveChanges();                      //Actualiza el objeto en la base de datos.
 }
Esempio n. 16
0
 public static void CreateInputOutput(InputOutputEntity oInputOutput)
 {
     using var db = new InventoryContext(); //Ejecuta dispose (Limpiar memoria) cuando ya no se usa db.
     db.InputOutputs.Add(oInputOutput);     //Agrega el elemento al contexto.
     db.SaveChanges();                      //Agrega a la base de datos.
 }
        public string SaveInOut(ProductEntity OProduct, List <StorageEntity> Ostorages, StorageEntity OStorage, InputOutputEntity oInOut)
        {
            OStorage = Ostorages.LastOrDefault(s => s.StorageId == oInOut.StorageId);
            OProduct = OStorage.Product;

            if (oInOut.IsInput)
            {
                OStorage.PartialQuantity = OStorage.PartialQuantity + oInOut.Quantity;
                updateStore.Update(OStorage);

                OProduct.TotalQuantity = OProduct.TotalQuantity + oInOut.Quantity;
                updateProduct.Update(OProduct);

                return($"El producto {OProduct.ProductName} ha sido actualizado");
            }
            else
            {
                if (IsBiggerThanZero(oInOut.Quantity, OStorage.PartialQuantity))
                {
                    OStorage.PartialQuantity = OStorage.PartialQuantity - oInOut.Quantity;
                    updateStore.Update(OStorage);

                    OProduct.TotalQuantity = OProduct.TotalQuantity - oInOut.Quantity;
                    updateProduct.Update(OProduct);

                    return($"El producto {OProduct.ProductName} ha sido actualizado");
                }
                else
                {
                    return($"No existe la cantidad en bodega del produco {OProduct.ProductName} ");
                }
            }
        }