public void GetListSupplierFromCompnay(List <string> ListCompanyId) { SupplierFactory _SupplierFactory = new SupplierFactory(); var dataSupplier = _SupplierFactory.GetData().Where(x => x.IsActived && ListCompanyId.Contains(x.CompanyId)).ToList(); foreach (var item in dataSupplier) { ListSupplier.Add(new SelectListItem { Text = item.Name, Value = item.Id }); } }
private async void Submit(string obj) { try { var newsup = new Supplier() { Name = Name, Delegate = Delegate, Email = Email, Phone = Phone, }; if (SupImg != null) { newsup.Avatar = SupImg.ConvertToByte(); } if (obj == null) { //Create new sup var objresult = await supplier_repo.Add(newsup); if (objresult != null) { dc = new DialogContent() { Content = "Thêm Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); ListSupplier.Add(objresult); } else { dc = new DialogContent() { Content = "Thêm Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } } else { //update sup newsup.SupID = Convert.ToInt32(obj); if (await supplier_repo.Update(newsup)) { dc = new DialogContent() { Content = "Cập Nhật Thành Công", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); ListSupplier = new ObservableCollection <Supplier>(await supplier_repo.GetAllAsync()); } else { dc = new DialogContent() { Content = "Cập Nhật Thất Bại", Tilte = "Thông Báo" }; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } } } catch { dc.Content = "Có Lỗi"; dc.Tilte = "Thông Báo"; dialog = new DialogOk() { DataContext = dc }; DialogHost.CloseDialogCommand.Execute(null, null); await DialogHost.Show(dialog, DialogHostId); } }