Esempio n. 1
0
 public ICollection <Category> GetAllEntities()
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         return(EntityContext.Categories.ToList());
     }
 }
Esempio n. 2
0
 public ICollection <Product> GetAllEntities()
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         return(EntityContext.Products.ToList());
     }
 }
Esempio n. 3
0
 public ICollection <Order> GetAllEntities()
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         return(EntityContext.Orders.ToList());
     }
 }
Esempio n. 4
0
 public void InsertEntity(Order entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Orders.Add(entity);
         EntityContext.SaveChanges();
     }
 }
Esempio n. 5
0
 public void InsertEntity(Product entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Products.Add(entity);
         EntityContext.SaveChanges();
     }
 }
Esempio n. 6
0
 public void InsertEntity(Category entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Categories.Add(entity);
         EntityContext.SaveChanges();
     }
 }
 public void ModifyEntity(OrderDetails entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.OrderDetails.Attach(entity);
         EntityContext.SaveChanges();
     }
 }
Esempio n. 8
0
 public void ModifyEntity(Order entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         EntityContext.Orders.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Modified;
         EntityContext.SaveChanges();
     }
 }
Esempio n. 9
0
 public void RemoveEntity(Product entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.Products.Remove(entity);
         EntityContext.Products.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Esempio n. 10
0
 public void RemoveEntity(OrderDetails entity)
 {
     // TODO: Remove the OrderDetail from the main list and the list in the Order
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.OrderDetails.Remove(entity);
         EntityContext.OrderDetails.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Esempio n. 11
0
 public void RemoveEntity(Order entity)
 {
     // TODO: Order and order details should be deleted
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.Orders.Remove(entity);
         EntityContext.Orders.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Esempio n. 12
0
 public void RemoveEntity(Category entity)
 {
     // TODO : check if all the product exist in the category should be deleted or not
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //EntityContext.Categories.Remove(entity);
         EntityContext.Categories.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Esempio n. 13
0
 //   Hint:The path is to set the IsActive property to 1 and we know that if a
 // property's IsActive value is 1, it is a deleted entity.
 public void RemoveEntity(Customer entity)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         //entity.IsActive = 1;
         //EntityContext.Customers.Attach(entity);
         //EntityContext.Entry(entity).State = EntityState.Modified;
         //EntityContext.Customers.Remove(entity);
         EntityContext.Customers.Attach(entity);
         EntityContext.Entry(entity).State = EntityState.Deleted;
         EntityContext.SaveChanges();
     }
 }
Esempio n. 14
0
 public Product GetEntity(long EntityId)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         foreach (var Product in GetAllEntities())
         {
             if (Product.ProductId == EntityId)
             {
                 return(Product);
             }
         }
         return(null);
     }
 }
Esempio n. 15
0
 public Category GetEntity(long EntityId)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         foreach (var Category in GetAllEntities())
         {
             if (Category.CategoryId == EntityId)
             {
                 return(Category);
             }
         }
         return(null);
     }
 }
Esempio n. 16
0
 public Order GetEntity(long EntityId)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         foreach (var Order in GetAllEntities())
         {
             if (Order.OrderId == EntityId)
             {
                 return(Order);
             }
         }
         return(null);
     }
 }
Esempio n. 17
0
 // Get all products in a same category
 public ICollection <Product> GetAllEntities(Category category)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         List <Product> Products = new List <Product>();
         foreach (var product in GetAllNonDeletedEntities())
         {
             if (product.CategoryId == category.CategoryId)
             {
                 Products.Add(product);
             }
         }
         return(Products);
     }
 }
Esempio n. 18
0
 public ICollection <OrderDetails> GetAllEntities(Order order)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         List <OrderDetails> orderDetails = new List <OrderDetails>();
         foreach (var item in GetAllEntities())
         {
             if (item.OrderId == order.OrderId)
             {
                 orderDetails.Add(item);
             }
         }
         return(orderDetails);
     }
 }
Esempio n. 19
0
 // Get all Customers that the value of IsActive is Zero
 // (It means they are not deleted from the data base)
 public ICollection <Customer> GetAllNonDeletedEntities()
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         List <Customer> NonDeletedCustomers = new List <Customer>();
         foreach (var Customer in GetAllEntities())
         {
             if (Customer.IsActive == 0)
             {
                 NonDeletedCustomers.Add(Customer);
             }
         }
         return(NonDeletedCustomers);
     }
 }
Esempio n. 20
0
 // Get all products with a same supplier
 public ICollection <Product> GetAllEntities(Supplier supplier)
 {
     using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
     {
         var SupplierProducts = new List <Product>();
         foreach (var product in GetAllEntities())
         {
             if (product.SupplierId == supplier.SupplierId)
             {
                 SupplierProducts.Add(product);
             }
         }
         return(SupplierProducts);
     }
 }
Esempio n. 21
0
        public ICollection <Product> GetAllNonDeletedEntities()
        {
            using (ShopDataBaseContext EntityContext = new ShopDataBaseContext())
            {
                List <Product> NonDeletedProducts = new List <Product>();
                foreach (var Product in GetAllEntities())
                {
                    if (Product.IsActive == 0)
                    {
                        NonDeletedProducts.Add(Product);
                    }
                }

                return(NonDeletedProducts);
            }
        }
Esempio n. 22
0
 public GenericRepository(ShopDataBaseContext context)
 {
     _entities = context.Set <T>();
 }
Esempio n. 23
0
 public ConsultantRepository(ShopDataBaseContext context) : base(context)
 {
     _context = context;
 }
Esempio n. 24
0
 public ShopRepository(ShopDataBaseContext context) : base(context)
 {
     _context = context;
 }
Esempio n. 25
0
 public UnitOfWorkEFCore(ShopDataBaseContext con)
 {
     context = con;
 }
Esempio n. 26
0
 public Service(IUnitOfWork uow, ILogger <Service> _loger, ShopDataBaseContext con)
 {
     unitOfWork  = uow;
     logger      = _loger;
     shopContext = con;
 }