public ICollection <Category> GetAllEntities() { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { return(EntityContext.Categories.ToList()); } }
public ICollection <Product> GetAllEntities() { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { return(EntityContext.Products.ToList()); } }
public ICollection <Order> GetAllEntities() { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { return(EntityContext.Orders.ToList()); } }
public void InsertEntity(Order entity) { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { EntityContext.Orders.Add(entity); EntityContext.SaveChanges(); } }
public void InsertEntity(Product entity) { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { EntityContext.Products.Add(entity); EntityContext.SaveChanges(); } }
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(); } }
public void ModifyEntity(Order entity) { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { EntityContext.Orders.Attach(entity); EntityContext.Entry(entity).State = EntityState.Modified; EntityContext.SaveChanges(); } }
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(); } }
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(); } }
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(); } }
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(); } }
// 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(); } }
public Product GetEntity(long EntityId) { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { foreach (var Product in GetAllEntities()) { if (Product.ProductId == EntityId) { return(Product); } } return(null); } }
public Category GetEntity(long EntityId) { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { foreach (var Category in GetAllEntities()) { if (Category.CategoryId == EntityId) { return(Category); } } return(null); } }
public Order GetEntity(long EntityId) { using (ShopDataBaseContext EntityContext = new ShopDataBaseContext()) { foreach (var Order in GetAllEntities()) { if (Order.OrderId == EntityId) { return(Order); } } return(null); } }
// 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); } }
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); } }
// 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); } }
// 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); } }
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); } }
public GenericRepository(ShopDataBaseContext context) { _entities = context.Set <T>(); }
public ConsultantRepository(ShopDataBaseContext context) : base(context) { _context = context; }
public ShopRepository(ShopDataBaseContext context) : base(context) { _context = context; }
public UnitOfWorkEFCore(ShopDataBaseContext con) { context = con; }
public Service(IUnitOfWork uow, ILogger <Service> _loger, ShopDataBaseContext con) { unitOfWork = uow; logger = _loger; shopContext = con; }