public void Add(Product t) { Products.Add(t); try { Sellers.FirstOrDefault(seller => seller.Name == t.Seller).Products.Add(t); } catch (Exception) { Add(new Seller { Name = t.Seller, Products = new List <Product> { t } }); } try { Brands.FirstOrDefault(brands => brands.Name == t.Brand).Products.Add(t); } catch (Exception) { Add(new Brand { Name = t.Brand, Products = new List <Product> { t } }); } }
public void ApplySelectedFilter(SearchItems filter) { this.SelectedFilter = filter; foreach (string brand in filter.Brands) { CheckBoxItemBrands item = Brands.FirstOrDefault(i => i.ID == brand); if (item != null) { item.IsChecked = true; } } foreach (Color color in filter.Colors) { var item = Colors.FirstOrDefault(i => i.color == color); if (item != null) { item.IsChecked = true; } } ApplyPropertyFilters(Styles, filter.Styles); ApplyPropertyFilters(Necklines, filter.Necklines); ApplyPropertyFilters(Silhouettes, filter.Silhouettes); SelectedMinPrice = filter.SelectedMinPrice ?? MinPrice; SelectedMaxPrice = filter.SelectedMaxPrice ?? MaxPrice; }
private void OnLoadedProdcut(Product product) { Title = product == null ? "Create Product" : "Update Product"; Product = product; Initialize(); if (Product != null) { if (Product.Category == null) { if (Categories.Count > 0) { throw new ArgumentNullException("Product.Category", "User creates product without select category."); } } else { if (Categories.Count <= 0) { throw new ArgumentOutOfRangeException("Product.Category", "There is no category in database."); } } if (Product.Brand == null) { if (Brands.Count > 0) { throw new ArgumentNullException("Product.Brand", "User creates product without select brand."); } } else { if (Brands.Count <= 0) { throw new ArgumentOutOfRangeException("Product.Brand", "There is no brand in database."); } } Product.Category = Categories.FirstOrDefault(c => c.Id == Product.CategoryId); Product.Brand = Brands.FirstOrDefault(b => b.Id == Product.BrandId); } else { Product = new Product { Category = Categories.FirstOrDefault(), Brand = Brands.FirstOrDefault(), Config = new Config() }; } ShowDialog(); }
protected async Task UpdateProduct() { if (HasDiscount) { double.TryParse(DiscountedPrice, out var newPrice); Product.DiscountedPrice = newPrice; } else { Product.DiscountedPrice = Product.Price; } Product.Category = Categories.FirstOrDefault(cat => cat.Id == Category); Product.Brand = Brands.FirstOrDefault(brand => brand.Id == Brand); Product.Status = (int)(IsPublic ? Consts.Status.Public : Consts.Status.Hidden); var result = await MegaService.HttpClient.PostJsonAsync <bool>("/api/product/Update/", Product); Toastr(result); StateHasChanged(); }
public Bag Translate(Thee source) { var teabrand = Brands.FirstOrDefault(brand => brand.Name == source.TheeMerk.Trim()); var teabagType = BagTypes.FirstOrDefault(bagType => bagType.Name == source.TheeSoortzakje.Trim()); var teacountry = Countries.FirstOrDefault(country => country.Name == source.TheeLandvanherkomst.Trim()); return(new Bag(null, "36544cc9-36ae-42c0-b614-a5a2010d4258", source.MainID, new Domain.RefValue(teabrand.Id, teabrand.Name), source.TheeSerie.Trim(), source.TheeSmaak.Trim(), source.TheeKenmerken.Trim(), teabagType != null ? new Domain.RefValue(teabagType.Id, teabagType.Name) : null, teacountry != null ? new Domain.RefValue(teacountry.Id, teacountry.Name) : null, source.TheeSerienummer.Trim(), ParseInvoerDatum(source), Images.FirstOrDefault(image => image.Filename == $"{source.MainID}.jpg")?.Id)); }
private async Task OnSaveBrand() { if (Name != "" && Description != "" && ImageBrand != null) { var itemDB = db.Brand.FirstOrDefault(x => x.IdBrand == SelectedBrand.IdBrand); itemDB.Name = Name; itemDB.Description = Description; itemDB.Logo = image.ImageToString(ImageBrand); await db.SaveChangesAsync(); var item = Brands.FirstOrDefault(x => x.IdBrand == SelectedBrand.IdBrand); item.Name = Name; item.Description = Description; item.Logo = image.ImageToString(ImageBrand); item.LogoImage = image.StringToImage(item.Logo); VisibleBrandAR = true; VisibleBrandSC = false; ClearBrandParameters(); } else { MessageBox.Show("Неверные данные! Повторите попытку!"); } }
public void SetItemDetails() { if (currentGroupItem == null || currentGroupItem.IsSpoof) { SelectedBrand = null; SelectedFreq = null; SelectedDeliveryMethod = null; SelectedPlatform = null; SelectedSpecialist = null; ContractName = null; if (ReportTypes != null) { ReportTypes.ForEach((thislist, thisreport) => RemoveWeakEventListener(thisreport, ReportListener)); ReportTypes = new ObservableReportTypes(safeReportTypes, true); ReportTypes.ForEach((thislist, thisreport) => AddWeakEventListener(thisreport, ReportListener)); } ClientLocations = null; RaisePropertyChanged("ReportTypes"); ReportText = "Select Report Types..."; return; } if (/*DB.Connnected &&*/ ReportTypes == null) { ReportTypes = new ObservableReportTypes(ReportTypesTarget.GetReportTypesAsList()); safeReportTypes = new ObservableReportTypes(ReportTypes, true); } if (CurrentGroupItem.ContractID == null) { ContractName = "No Contract assigned."; } else { Contract contract = ContractTarget.GetByContractID((int)CurrentGroupItem.ContractID); if (contract == null) { ContractName = "No contract found for this Group."; } else { ContractName = contract.DESCR; } } AddWeakEventListener(CurrentGroupItem, EncryptListener); IgReports = InvoiceGrpReportsTarget.GetById(currentGroupItem.InvoiceGrpId); foreach (ReportType reportType in ReportTypes) { foreach (InvoiceGrpReport igr in IgReports) { if (igr.REPORT_TYPE_ID == reportType.REPORT_TYPE_ID) { reportType.IsSelected = true; } else { reportType.IsSelected = false; } } } RaisePropertyChanged("ReportTypes"); base.ViewCore.UpdateCB(); SelectedSpecialist = (Specialists.First(ss => ss.Id == currentGroupItem.BillingSpecialistID) as BillingSpecialist); SelectedFreq = (Freqs.First(f => f.FREQ == currentGroupItem.BillingFrequency) as Freq); SelectedPlatform = (Platforms.First(p => p.PLATFORM == currentGroupItem.PrimaryPlatform) as Platform); SelectedDeliveryMethod = (DeliveryMethods.First(dm => dm.TheDeliveryMethod == currentGroupItem.DeliveryMethod) as DeliveryMethod); SelectedBrand = (Brands.FirstOrDefault(b => b.BRAND == currentGroupItem.Brand) as Brand); SelectedRemitTo = (RemitTos.First(r => r.REMIT_TO_ID == currentGroupItem.RemitToID) as RemitTo); SelectedInvoiceStyle = (InvoiceStyles.First(i => i.INVOICE_STYLE == currentGroupItem.InvoiceStyle) as InvoiceStyle); SelectedInvoiceGrpStatus = (InvoiceGrpStatuss.First(i => i.INVOICE_GRP_STATUS == currentGroupItem.InvoiceGroupStatus) as InvoiceGrpStatus); if (ClientLocations != null) { ClientLocations.CollectionChanged -= ClientLocCollectionChanged; } ClientLocations = ExtClientTarget.FetchLocations(CurrentGroupItem.InvoiceGrpId, true); ClientLocations.CollectionChanged += ClientLocCollectionChanged; currentGroupItem.Modified = false; GroupVM.EnablePicker = true; }
public Brand GetBrand(string code) => Brands.FirstOrDefault(b => b.Code == code);
public Brand GetBrandById(long brandId) { return(Brands.FirstOrDefault(s => s.Id == brandId)); }