private static Supplier GetByIDUsingEF(int supplierID) { Supplier supplier = null; using (var db = new RetailContext()) { supplier = db.Suppliers .Where(s => s.SupplierID == supplierID) .SingleOrDefault(); } return supplier; }
private static IList<Supplier> GetAllUsingEF() { var daftarSupplier = new List<Supplier>(); using (var db = new RetailContext()) { daftarSupplier = db.Suppliers .OrderBy(s => s.NamaSupplier) .ToList(); } return daftarSupplier; }
private static IList<Supplier> GetByNameUsingEF(string namaSupplier) { var daftarSupplier = new List<Supplier>(); using (var db = new RetailContext()) { daftarSupplier = db.Suppliers .Where(s => s.NamaSupplier.Contains(namaSupplier)) .OrderBy(s => s.NamaSupplier) .ToList(); } return daftarSupplier; }
private static int DeleteUsingEF(Supplier supplier) { var result = 0; using (var db = new RetailContext()) { db.Entry(supplier).State = EntityState.Deleted; db.SaveChanges(); result = 1; } return result; }
private static Beli GetPembelianUsingEF(string nota) { Beli beli; using (var db = new RetailContext()) { beli = db.Belis .Include(bl => bl.Supplier) .Include(bl => bl.ItemBelis.Select(ib => ib.Barang)) .Where(bl => bl.Nota == nota) .SingleOrDefault(); } return beli; }
private static int AddPembelianUsingEF(Beli beli) { var result = 0; using (var db = new RetailContext()) { try { db.Entry(beli).State = EntityState.Added; db.SaveChanges(); result = 1; } catch { } } return result; }