Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
154 stars 152 forks source link

Adding Warehouse #342

Open Santiago365 opened 5 years ago

Santiago365 commented 5 years ago

Hello,

I am trying to create a new warehouse using PrestaSharp libraries but I get an error.

WarehouseFactory WarehouseFactory = new WarehouseFactory(BaseUrl, Account, Password);
ShopFactory ShopFactory = new ShopFactory(BaseUrl, Account, Password);

warehouse Warehouse = new warehouse();
Warehouse.id = 3;
Warehouse.name = "net";
Warehouse.id_address = 3028;
Warehouse.id_currency = 1;
Warehouse.id_employee = 12;
 Warehouse.management_type = "WA";
 Warehouse.reference = "test";

********This is the line I get the error from.....*********
 Warehouse.associations.shops.Add(new Bukimedia.PrestaSharp.Entities.AuxEntities.shop());

 WarehouseFactory.Add(Warehouse);

Not sure if I'm doing something wrong but it is supposed that is very simple.

Retrieved error is (System.NullReferenceException):

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=WindowsFormsApp2 StackTrace: at WindowsFormsApp2.Form1.button2_Click(Object sender, EventArgs e) in C:\Users\santi\source\repos\WindowsFormsApp2\WindowsFormsApp2\Form1.cs:line 64 at System.Windows.Forms.Control.OnClick(EventArgs e) at System.Windows.Forms.Button.OnClick(EventArgs e) at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent) at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ButtonBase.WndProc(Message& m) at System.Windows.Forms.Button.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam) at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg) at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData) at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context) at System.Windows.Forms.Application.Run(Form mainForm) at WindowsFormsApp2.Program.Main() in

Thank you so much guys!!!

Santiago365 commented 5 years ago

I tried this:

            Bukimedia.PrestaSharp.Entities.AuxEntities.AssociationsWarehouse AssociationsWarehouse = new Bukimedia.PrestaSharp.Entities.AuxEntities.AssociationsWarehouse();
            Bukimedia.PrestaSharp.Entities.AuxEntities.shop shop = new Bukimedia.PrestaSharp.Entities.AuxEntities.shop();
            shop.id = 1;

            AssociationsWarehouse.shops.Add(shop);

            Warehouse.associations = AssociationsWarehouse;

I don't get any error, but still doing nothing.