private void UploadDetails(object obj) { try { var client = obj as ClientModel; ToBuysData toBuysData = new ToBuysData(); var orders = toBuysData.GetToBuysByClientId(new { ClientId = client.Id }); ToBuysProductsData toBuysProductsData = new ToBuysProductsData(); List <WHProductModel> productsDB = new List <WHProductModel>(); orders.ForEach(x => productsDB.Add(toBuysProductsData.GetProductById(new { x.ProductId }))); BindableCollection <WareHouseProductModel> products = new BindableCollection <WareHouseProductModel>(_mapper.Map <List <WareHouseProductModel> >(productsDB)); _windowManager.ShowWindow(IoC.Get <ToBuyDetailsViewModel>()); _events.PublishOnUIThread(new ToBuyDetailsEventModel(products, client, orders)); } catch (Exception ex) { MessageBox.Show("Message: \n" + ex.Message + '\n' + "StackTrase: \n" + ex.StackTrace + '\n' + "InnerException: \n" + ex.InnerException); } }
public async Task MakeToBuy() { if (CanMakeToBuy) { ToBuysProductsData toBuysProductsData = new ToBuysProductsData(); var productsToAdd = new List <WareHouseProductModel>(ProductsToAdd); var products = _mapper.Map <List <WHPostProductModel> >(productsToAdd); List <WHProductModel> productsWithID = new List <WHProductModel>(); products.ForEach(prod => productsWithID.Add(toBuysProductsData.PostProduct(prod))); BindableCollection <WareHouseProductModel> productsToBuy = new BindableCollection <WareHouseProductModel>(_mapper.Map <List <WareHouseProductModel> >(productsWithID)); _windowManager.ShowWindow(_makeToBuyViewModel); await _events.PublishOnUIThreadAsync(new MakeToBuyEventModel(productsToBuy)); } }
private void ExecuteFinishOrder(object obj) { var client = obj as ClientModel; ToBuysData _toBuysData = new ToBuysData(); ToBuysProductsData _toBuysProductsData = new ToBuysProductsData(); var orders = _toBuysData.GetToBuysAllByClientId(new { ClientId = client.Id }); List <WHProductModel> productModels = new List <WHProductModel>(); orders.ForEach(x => productModels.Add(_toBuysProductsData.GetProductById(new { x.ProductId }))); List <HPostModel> historyPostModels = new List <HPostModel>(); for (int i = 0; i < orders.Count; i++) { historyPostModels.Add(new HPostModel { Sender = false, ProductId = orders[i].ProductId, FactoryNumber = productModels[i].FactoryNumber, Name = productModels[i].Name, Set = productModels[i].Set, Type = productModels[i].Type, Photo = productModels[i].Photo, ProductQuantity = orders[i].ProductQuantity, ProductDescription = productModels[i].ProductDescription, ProductNetPrice = orders[i].ProductNetPrice, ProductSellPrice = orders[i].ProductSellPrice, OrderDateTime = orders[i].OrderDateTime, ClientId = client.Id }); } HistoryData historyData = new HistoryData(); foreach (var item in historyPostModels) { historyData.PostHistory(item); } RefreshView(); }