public bool AddLabelInfo(long ParenDishId) { ItemLabelInfo l = new ItemLabelInfo() { ParenItemId = ParenDishId, SerialNumber = ItemLabelsInfo.Where(a => a.ParenItemId == ParenDishId).Count() + 1 }; var res = DBDataExtractor <ItemLabelInfo> .AddItem(DBProvider.Client.CreateItemLabelInfo, l); if (res > 0) { l.Id = res; ItemLabelsInfo.Add(l); Dishes.SingleOrDefault(a => a.Id == ParenDishId).LabelsCount++; return(true); } return(false); }
public void DataCatalogsFill() { try { _logger.Debug("DataCatalogsFill start"); //OperationResultValue<UpdateResult> res = DBProvider.Client.GetUpdatesForSession(""); //var res2 = res.Result.UpdatedData[0] as OrderToGo; OnDataCatalogMessage("Загружаю список операторов"); //managerOperator = DBDataExtractor<User>.GetDataList(DBProvider.Client.GetUserList) == null ? new FullyObservableCollection<User>() : new FullyObservableCollection<User>(DBDataExtractor<User>.GetDataList(DBProvider.Client.GetUserList)); managerOperator = DBDataExtractor <User> .GetDataList(DBProvider.Client.GetUserList); OnDataCatalogMessage("Загружаю контакты"); ContactPerson = DBDataExtractor <ContactPerson> .GetDataList(DBProvider.Client.GetContactPersonList); /* * ToGoCustomers = DBDataExtractor<OrderCustomer>.GetDataList(DBProvider.Client.GetOrderCustomerList); * ToGoCustomersAddresses = new FullyObservableCollection<OrderCustomerAddress>(); * foreach (var cust in ToGoCustomers) * { * foreach (var addr in cust.Addresses) * { * ToGoCustomersAddresses.Add(addr); * } * } */ OnDataCatalogMessage("Загружаю наклейки"); //ItemLabelsInfo = DBDataExtractor<ItemLabelInfo>.GetDataList(DBProvider.Client.GetItemLabelInfoList) == null ? new FullyObservableCollection<ItemLabelInfo>() : new FullyObservableCollection<ItemLabelInfo>(DBDataExtractor<ItemLabelInfo>.GetDataList(DBProvider.Client.GetItemLabelInfoList)); ItemLabelsInfo = DBDataExtractor <ItemLabelInfo> .GetDataList(DBProvider.Client.GetItemLabelInfoList); DishLogicGroup = DBDataExtractor <DishLogicGroup> .GetDataList(DBProvider.Client.GetDishLogicGroupsList); DishKitchenGroup = DBDataExtractor <DishKitchenGroup> .GetDataList(DBProvider.Client.GetDishKitсhenGroupsList); OnDataCatalogMessage("Загружаю авиакомпании"); PaymentGroups = DBDataExtractor <PaymentGroup> .GetDataList(DBProvider.Client.GetPaymentGroupList); Payments = DBDataExtractor <Payment> .GetDataList(DBProvider.Client.GetPaymentList); foreach (var a in Payments) { if (a.PaymentGroupId != 0) { a.PaymentGroup = PaymentGroups.SingleOrDefault(b => b.Id == a.PaymentGroupId); } PaymentsSourceCache.AddOrUpdate(a); } Discounts = DBDataExtractor <Discount> .GetDataList(DBProvider.Client.GetDiscountList); AllAirCompanies = new FullyObservableCollection <AirCompany>(DBDataExtractor <AirCompany> .GetDataList(DBProvider.Client.GetAirCompanyList) //.Where(a => !DBProvider.SharAirs.Contains(a.Id) || ((Authorization.CurentUser != null) && ((Authorization.CurentUser.UserName == "sh.user") || (Authorization.IsDirector)))) .OrderBy(a => a.Name)); foreach (var a in AllAirCompanies) { if (a.PaymentId != null) { a.PaymentType = Payments.SingleOrDefault(b => b.Id == a.PaymentId); } if (a.DiscountId != null) { a.DiscountType = Discounts.SingleOrDefault(b => b.Id == a.DiscountId); } } AirCompanies = new FullyObservableCollection <AirCompany>(AllAirCompanies.Where(a => a.IsActive && (!DBProvider.SharAirs.Contains(a.Id) || ((Authorization.CurentUser != null) && ((Authorization.CurentUser.UserName == "sh.user") || (Authorization.IsDirector)))))); //AirCompanies = DBDataExtractor<AirCompany>.GetDataList(DBProvider.Client.GetAirCompanyList); //DeliveryPlaces = DBDataExtractor<DeliveryPlace>.GetDataList(DBProvider.Client.GetDeliveryPlaceList) == null ? new FullyObservableCollection<DeliveryPlace>() : new FullyObservableCollection<DeliveryPlace>(DBDataExtractor<DeliveryPlace>.GetDataList(DBProvider.Client.GetDeliveryPlaceList)); DeliveryPlaces = DBDataExtractor <DeliveryPlace> .GetDataList(DBProvider.Client.GetDeliveryPlaceList); Drivers = DBDataExtractor <Driver> .GetDataList(DBProvider.Client.GetDriverList) == null ? new FullyObservableCollection <Driver>() : new FullyObservableCollection <Driver>(DBDataExtractor <Driver> .GetDataList(DBProvider.Client.GetDriverList)); mDiscounts = DBDataExtractor <Discount> .GetDataList(DBProvider.Client.GetDiscountList) == null ? new FullyObservableCollection <Discount>() : new FullyObservableCollection <Discount>(DBDataExtractor <Discount> .GetDataList(DBProvider.Client.GetDiscountList)); OnDataCatalogMessage("Загружаю блюда"); Dishes = DBDataExtractor <Dish> .GetDataList(DBProvider.Client.GetDishList); foreach (var d in Dishes) { if (d.DishKitсhenGroupId > 0) { try { d.DishKitсhenGroup = DishKitchenGroup.Single(a => a.Id == d.DishKitсhenGroupId); } catch { } } if (d.DishLogicGroupId > 0) { try { d.DishLogicGroup = DishLogicGroup.Single(a => a.Id == d.DishLogicGroupId); } catch { } } d.LabelsCount = ItemLabelsInfo.Where(a => a.ParenItemId == d.Id).Count(); } OnDataCatalogMessage("Загружаю cписок клиентов"); marketingChannels = DBDataExtractor <MarketingChannel> .GetDataList(DBProvider.Client.GetMarketingChannelList); ItemLabelsInfo.ItemPropertyChanged += ItemLabelsInfo_ItemPropertyChanged; RefreshDynamicData(); _logger.Debug("DataCatalogsFill end"); } catch (Exception e) { _logger.Debug($"DataCatalogsFill error {e.Message}"); MainClass.SetNeedExit("Ошибка загрузки справочников " + e.Message); } /* * foreach (var d in DBDataExtractor<Dish>.GetDataList(DBProvider.Client.GetDishList) == null ? new FullyObservableCollection<Dish>() : new FullyObservableCollection<Dish>(DBDataExtractor<Dish>.GetDataList(DBProvider.Client.GetDishList))) * { * dishes.Add(d); * } */ }