public SupplyAddViewModel() { _currentWindow = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault(); _categoriesDialog = new CategoriesShowDialog(); _categoryDialog = new SupplyCategoryInfromationDialog(); Clients = new ObservableCollection <Client>(_clientServ.GetClients()); NewSupply.Date = DateTime.Now; PlacesSuggestions = _supplyFutureServ.GetPlacesSuggetions(); NewSupplyFuture.Date = DateTime.Now; }
public SupplyUpdateViewModel() { _currentWindow = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault(); _categoriesDialog = new CategoriesShowDialog(); _categoryDialog = new SupplyCategoryInfromationDialog(); _supplyCategories = new ObservableCollection <SupplyCategoryVM>(_supplyCategoryServ.GetSupplyCategoriesVM(ID)); _selectedSupply = _supplyServ.GetSupply(ID); _selectedSupplyFuture = _supplyFutureServ.GetSupplyFuture(ID); if (SelectedSupplyFuture == null) { SelectedSupplyFuture = new SupplyFuture(); SelectedSupplyFuture.Date = DateTime.Now; } PlacesSuggestions = _supplyFutureServ.GetPlacesSuggetions(); }
public SupplyOfferConvertViewModel() { _currentWindow = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault(); _categoriesDialog = new CategoriesShowDialog(); _categoryDialog = new SupplyCategoryInfromationDialog(); Clients = new ObservableCollection <Client>(_clientServ.GetClients()); NewSupply.Date = DateTime.Now; PlacesSuggestions = _supplyFutureServ.GetPlacesSuggetions(); NewSupplyFuture.Date = DateTime.Now; var supplyOffer = _supplyOfferServ.GetSupplyOffer(ID); NewSupply.ClientID = supplyOffer.ClientID; var supplyOfferCategories = _supplyOfferCategoryServ.GetSupplyOfferCategories(ID); foreach (var item in supplyOfferCategories) { var cat = _categoryServ.GetCategory(item.CategoryID); _supplyCategories.Add(new SupplyCategoryVM { Category = item.Category, CategoryID = item.CategoryID, Company = item.Company, Discount = item.Discount, DiscountValue = item.DiscountValue, DiscountValueTotal = item.DiscountValueTotal, Price = cat.Price, Qty = item.Qty, Cost = cat.Cost, CostTotal = item.CostTotal, CostAfterDiscount = item.CostAfterDiscount, CostAfterTax = item.CostAfterTax, CostTotalAfterDiscount = item.CostTotalAfterDiscount, CostTotalAfterTax = item.CostTotalAfterTax, Tax = item.Tax, TaxValue = item.TaxValue, TaxValueTotal = item.TaxValueTotal }); } NewSupply.Cost = SupplyCategories.Sum(s => s.CostTotal); NewSupply.CostAfterTax = SupplyCategories.Sum(s => s.CostTotalAfterTax); NewSupply.TotalDiscount = SupplyCategories.Sum(s => s.DiscountValueTotal); NewSupply.OldDebt = _clientAccountServ.GetClientAccount(supplyOffer.Client.ID) + supplyOffer.Client.AccountStart; }