private static void updateinventorylogonsale(int productid, double productquantity, int saleid, string comment)
        {
            var inventorylogrepo = new inventorylogrepo();

            data.dapper.inventorylog ir = new inventorylog();
            ir.quantity = -productquantity;
            ir.date     = DateTime.Now;
            ir.fk_product_in_inventorylog = productid;
            ir.note = "Detucted inventory on sale id " + saleid + comment;
            inventorylogrepo.save(ir);
        }
        private static void updateinventorylogonpurchase(int productid, double productquantity, int purchaseid, string inventorylogcomment)
        {
            var inventorylogrepo = new inventorylogrepo();

            data.dapper.inventorylog ir = new inventorylog();
            ir.quantity = productquantity;
            ir.date     = DateTime.Now;
            ir.fk_product_in_inventorylog = productid;
            ir.note = "Added inventory on purchase id " + purchaseid + inventorylogcomment;
            inventorylogrepo.save(ir);
        }
 public static void updateinventorylogonproductcreate(data.dapper.product p)
 {
     if (p.quantity != 0)
     {
         var inventorylogrepo        = new inventorylogrepo();
         data.dapper.inventorylog ir = new inventorylog();
         ir.quantity = p.quantity;
         ir.date     = DateTime.Now;
         ir.fk_product_in_inventorylog = p.id;
         ir.note = "Added inventory on product create";
         inventorylogrepo.save(ir);
     }
 }
        public static void updateinventorylogonproductupdate(int productid, double newinventory, double oldinventory)
        {
            if (newinventory == oldinventory)
            {
                return;
            }
            var inventorylogrepo = new inventorylogrepo();

            data.dapper.inventorylog ir = new inventorylog();
            ir.date = DateTime.Now;
            ir.fk_product_in_inventorylog = productid;
            ir.quantity = newinventory - oldinventory;
            if (newinventory > oldinventory)
            {
                ir.note = "Added inventory on product update";
            }
            else if (newinventory < oldinventory)
            {
                ir.note = "Detucted inventory on product update";
            }
            inventorylogrepo.save(ir);
        }