public void AddProduct(Products product) { using (var customerContext = new CustomerAppContext()) { customerContext.Add(product); customerContext.SaveChanges(); } }
public List <Customers> LoginCustomer(Customers customer) { using (var customerContext = new CustomerAppContext()) { var result = customerContext.Customers.Where(cust => cust.Email == customer.Email && cust.Password == customer.Password).ToList(); return(result); } }
public UnitOfWork() { context = new CustomerAppContext(); context.Database.EnsureCreated(); // Auto DB Table Creation CustomerRepository = new CustomerRepository(context); OrderRepository = new OrderRepository(context); AddressRepository = new AddressRepository(context); }
private CustomerAppContext context; //this represents the context of database public UnitOfWork() { context = new CustomerAppContext(); //context.Database.EnsureCreated(); ---- UNCOMMENT WHEN CONNECTING WITH DATABASE CustomerRepository = new CustomerRepository(context); OrderRepository = new OrderRepository(context); AddressRepository = new AddressRepository(context); }
public List <Products> AllProduct(Products product) { using (var customerContext = new CustomerAppContext()) { var data = customerContext.Products.Select(x => x).ToList(); return(data); } }
public void UpdateCustomer(Customers customer) { using (var customerContext = new CustomerAppContext()) { customerContext.Customers.Update(customer); customerContext.SaveChanges(); } }
public UnitOfWork() { _context = new CustomerAppContext(); _context.Database.EnsureCreated(); CustomerRepository = new CustomerRepository(_context); OrderRepository = new OrderRepository(_context); AddressRepository = new AddressRepository(_context); }
public void FilterProduct(Products product) { using (var customerContext = new CustomerAppContext()) { var pr = customerContext.Database.ExecuteSqlCommand("spFilterProduct @Status", new SqlParameter("@Status", product.ProductStatus) ); } }
public void SearchProduct(Products product) { using (var customerContext = new CustomerAppContext()) { var pr = customerContext.Database.ExecuteSqlCommand("spSearchProduct @Product", new SqlParameter("@Product", product.ProductCode) ); } }
public void AddCustomer(Customers customer) { using (var customerContext = new CustomerAppContext()) { Random rand = new Random(); customer.CustomerNumber = rand.Next(); customerContext.Customers.Add(customer); customerContext.SaveChanges(); } }
public void DeleteCustomer(int customerid) { using (var customerContext = new CustomerAppContext()) { Customers customer = new Customers(); customer.CustomerId = customerid; customerContext.Customers.Remove(customer); customerContext.SaveChanges(); } }
public void DeleteProduct(int productid) { using (var customerContext = new CustomerAppContext()) { Products product = new Products(); product.ProductId = productid; customerContext.Remove(product.ProductId); customerContext.SaveChanges(); } }
private static ICustomerRepository GetSQLLiteRepo() { var options = new DbContextOptionsBuilder <CustomerAppContext>(); options.UseSqlite("Data Source=customerApp.db"); var context = new CustomerAppContext(options.Options); DBInitializer.SeedDB(context); ICustomerRepository custRepoSQLLite = new CustomerApp.Infrastructure.SQLData.Repositories.CustomerRepository(context); return(custRepoSQLLite); }
public IActionResult GetById(int CustomerId) { using (var customerContext = new CustomerAppContext()) { Customers customer = new Customers(); var result = customerContext.Customers.Where(x => x.CustomerId == customer.CustomerId); if (result != null) { return(Ok(result)); } else { return(Ok("Not Found")); } } }
public UnitOfWork(DbOptions opt) { DbContextOptions <CustomerAppContext> options; if (opt.Environment == "Development" && String.IsNullOrEmpty(opt.ConnectionString)) { options = new DbContextOptionsBuilder <CustomerAppContext>() .UseInMemoryDatabase("TheDB") .Options; } else { options = new DbContextOptionsBuilder <CustomerAppContext>() .UseSqlServer(opt.ConnectionString) .Options; } context = new CustomerAppContext(options); }
public CustomerRepository(CustomerAppContext context) { _context = context; }
public UnitOfWork() { context = new CustomerAppContext(); CustomerRepository = new CustomerRepositoryEFMemory(context); OrderRepository = new OrderRepository(context); }
public ProductRepository(CustomerAppContext ctx) { _ctx = ctx; }
public OrderRepository(CustomerAppContext ctx) { _ctx = ctx; }
public FineTypeRepository(CustomerAppContext context) { _context = context; }
public AddressRepository(CustomerAppContext context) { _context = context; }
public OrderRepository(CustomerAppContext context) { this.context = context; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, CustomerAppContext context) { if (env.IsDevelopment()) { context.Database.EnsureCreated(); // Automatic DB Creation app.UseDeveloperExceptionPage(); var facade = new BLLFacade(); var address = facade.AddressService.Create( new AddressBO() { City = "Kolding", Street = "SesamStrasse", Number = "22A" }); var address2 = facade.AddressService.Create( new AddressBO() { City = "BingoCity", Street = "DingoDoiok", Number = "2e2" }); var address3 = facade.AddressService.Create( new AddressBO() { City = "Hurly Smurf", Street = "Trainstiik", Number = "44d" }); var cust = facade.CustomerService.Create( new CustomerBO() { FirstName = "Lars", LastName = "Bilde", AddressIds = new List <int>() { address.Id, address3.Id }, }); facade.CustomerService.Create( new CustomerBO() { FirstName = "Ole", LastName = "Eriksen", AddressIds = new List <int>() { address.Id, address2.Id } }); for (int i = 0; i < 5; i++) { facade.OrderService.Create( new OrderBO() { DeliveryDate = DateTime.Now.AddMonths(1), OrderDate = DateTime.Now.AddMonths(-1), CustomerId = cust.Id }); } } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
public UserRepository(CustomerAppContext context) { db = context; }