private void Btn_Simpan_Click(object sender, RoutedEventArgs e) { try { _supplierServices = new SupplierServices(); if (string.IsNullOrEmpty(NamaSupplier.Text)) { MessageBox.Show("Nama Supplier tidak boleh kosong", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } var Dto = new MasterSupplierDto(); Dto.NAMA_SUPPLIER = NamaSupplier.Text; Dto.ALAMAT_SUPPLIER = Alamat.Text; Dto.ID = Convert.ToInt32(IdSupplier.Text); Dto.STATUS = (Status)StatusSupplier.SelectedItem; var GetDataExisting = _supplierServices.GetAll().Where(x => !string.IsNullOrEmpty(x.NAMA_SUPPLIER) && x.NAMA_SUPPLIER.ToUpper() == Dto.NAMA_SUPPLIER.ToUpper()).FirstOrDefault(); if (GetDataExisting != null && GetDataExisting.ID != Dto.ID) { MessageBox.Show("Nama Supplier sudah ada", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } _supplierServices.Save(Dto); MessageBox.Show("Update Data Sukses", "Sukses", MessageBoxButton.OK, MessageBoxImage.Information); CloseWin(); } catch (Exception exp) { MessageBox.Show("Update Data Error", "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private bool FilterCandidates(object obj) { MasterSupplierDto c = (MasterSupplierDto)obj; return(filters.Values .Aggregate(true, (prevValue, predicate) => prevValue && predicate(c))); }
public void Save(MasterSupplierDto Dto) { var Db = AutoMapper.Mapper.Map <master_supplier>(Dto); Uow = new UnitOfWorks(); _masterSupplierRepo = Uow.GetGenericRepository <master_supplier>(); _masterSupplierRepo.InsertOrUpdate(Db); Uow.SaveChanges(); }