Example #1
0
        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;
        }
Example #2
0
        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;
        }
Example #3
0
        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;
        }
Example #4
0
        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;
        }
Example #5
0
        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;
        }
Example #6
0
        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;
        }