public AdjustSerialNumbersViewModel(ObservableCollection <SerialNumber> serialNumbers) { SerialNumbers = new ObservableCollection <SerialNumber>(); Title = "List Serial Numbers"; foreach (SerialNumber imei in serialNumbers) { SerialNumbers.Add(imei); } MessagingCenter.Subscribe <AddSerialNumbersPage, IEnumerable <Stock> >(this, "AddMixedStocks", (async(obj, stocks) => { var newstocks = stocks as IEnumerable <Stock>; await StoreDataStore.AddStocksAsync(App.currentStore.StoreId, newstocks); })); MessagingCenter.Subscribe <SubtractSerialNumbersPage, IEnumerable <Stock> >(this, "SubtractMixedStocks", (async(obj, stocks) => { var newstocks = stocks as IEnumerable <Stock>; await StoreDataStore.SubtractStocksAsync(App.currentStore.StoreId, newstocks); })); MessagingCenter.Subscribe <PurchaseOrderSerialNumberPage, IEnumerable <Stock> >(this, "ReceiveMixedPurchaseOrder", (async(obj, stocks) => { DateTime currentDateTime = DateTime.Now; Order order = new Order { OrderDate = currentDateTime, StoreId = App.currentStore.StoreId, UserId = App.currentUser.Id, OrderItems = new Collection <OrderItems>() }; foreach (Stock stock in stocks) { order.OrderItems.Add(new OrderItems { OrderId = order.OrderId, ProductId = stock.ProductId, Quantity = stock.Quantity }); } var newstocks = stocks as IEnumerable <Stock>; await StoreDataStore.AddStocksAsync(App.currentStore.StoreId, newstocks); await OrderDataStore.AddOrderAync(order); })); //MessagingCenter.Subscribe<AddSerialNumbersPage, IEnumerable<Stock>>(this, "AddSerialNumbers", async (obj, stocks) => //{ // var newSerialNumbers = serialNumbers as IEnumerable<SerialNumber>; // await Serial.AddStocksAsync(App.currentStore.StoreId, newstocks); //}); //GetSerialFieldsCommand = new Command(async () => await ExecuteGetSerialFields()); //MessagingCenter.Subscribe<AddnewSerialPage, Product>(this, "AddItem", async (obj, item) => //{ // var newItem = item as Product; // Products.Add(newItem); // await DataStore.AddProductAsync(newItem); //}); }
public PurchaseOrderViewModel() { Title = "Purchase Order"; Order = new Order { OrderDate = DateTime.Now, StoreId = App.currentStore.StoreId, UserId = App.currentUser.Id, OrderItems = new Collection <OrderItems>() }; Stocks = new ObservableCollection <Stock>(); MessagingCenter.Subscribe <PurchaseOrderPage, IEnumerable <Stock> >(this, "ReceivePurchaseOrder", (Action <PurchaseOrderPage, IEnumerable <Stock> >)(async(obj, stocks) => { foreach (Stock stock in stocks) { Order.OrderItems.Add(new OrderItems { OrderId = Order.OrderId, ProductId = stock.ProductId, Quantity = stock.Quantity }); } var newstocks = stocks as IEnumerable <Stock>; await StoreDataStore.AddStocksAsync(App.currentStore.StoreId, (IEnumerable <Stock>)newstocks); await OrderDataStore.AddOrderAync(Order); })); }