Beispiel #1
0
        static void Main(string[] args)
        {
            using (var context = new eShopContext())
            {
                #region pagingtest
                var produktService = new ListProduktService(context);
                var produkter      = produktService.SortFilterPage(new SortFilterPageOptions
                {
                    OrderByOptions = OrderByOptions.Navn,
                    FilterBy       = ProduktFilterBy.Navn,
                    FilterValue    = "A",

                    PageNum  = 2,
                    PageSize = 3
                }).ToList();

                foreach (ProduktListDto produkt in produkter)
                {
                    Console.WriteLine("\nproduktnavn: {0} \nproduktpris: {1}",
                                      produkt.ProduktNavn,
                                      produkt.Pris
                                      );
                }
                #endregion
            }
        }
Beispiel #2
0
        public void TestMethod1()
        {
            // ARRANGE: Create option object with InMemoryDatabase
            var options = new DbContextOptionsBuilder <eShopContext>()
                          .UseInMemoryDatabase(databaseName: "Add_writes_to_database")
                          .Options;

            // ACT: Run the test against one instance of the context
            //using (var context = new eShopContext(options))
            //{
            //    var service = new eShopService(context);
            //    service.OpretKategori("unittest2");
            //}

            // ASSERT: Use a separate instance of the context to verify correct data was saved to database
            using (var context = new eShopContext(options))
            {
                Assert.AreEqual("unittest2", context.Kategorier.Single().KategoriNavn);
            }
        }
Beispiel #3
0
 public EFRepository(eShopContext eShopContext)
 {
     _eShopContext = eShopContext;
 }
Beispiel #4
0
 public ListProduktService(eShopContext context)
 {
     _context = context;
 }
Beispiel #5
0
 public OrdersRepository(eShopContext context)
 {
     this.context = context;
 }
Beispiel #6
0
 public FornecedorsController(eShopContext context)
 {
     _context = context;
 }
Beispiel #7
0
 public UserRepository(eShopContext context)
 {
     this.context = context;
 }
Beispiel #8
0
 public eShopService(eShopContext context)
 {
     //context.Database.EnsureCreated();
     _context = context;
 }
Beispiel #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IMemoryCache cache, eShopContext db)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseMiniProfiler();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }
            if (!db.Database.CanConnect())
            {
                db.Database.EnsureCreated();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();
            app.UseSession();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapRazorPages();
            });
        }
 public CategoryRepository(eShopContext eShopContext) : base(eShopContext)
 {
 }
Beispiel #11
0
 public BaseService(eShopContext db)
 {
     _db = db;
 }
Beispiel #12
0
 public ProductsRepository(eShopContext context)
 {
     this.context = context;
 }
Beispiel #13
0
 public static void Initialize(eShopContext context)
 {
     /* context.Database.EnsureCreated();
      * bool temp = false;
      * if (!context.Categories.Any())
      * {
      *   temp = true;
      *   context.Categories.AddRange(new List<Category>
      *   {
      *       new Category
      *       {
      *           Id = 1,
      *           Name = "Áo Nam",
      *           Description = "Thời Trang Nam"
      *
      *       },
      *       new Category
      *       {
      *           Id = 2,
      *           Name = "Áo Nữ",
      *           Description = "Thời Trang Nữ"
      *       }
      *   }) ;
      * }
      *
      * if(!context.Products.Any())
      * {
      *   temp = true;
      *   context.Products.AddRange(new List<Product> {
      *       new Product
      *       {
      *           Id = 1,
      *           Category_Id = 1,
      *           Name = "Áo sơ mi nam trắng Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },
      *       new Product
      *       {
      *           Id = 2,
      *           Category_Id = 1,
      *           Name = "Áo sơ mi nam Den Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },
      *       new Product
      *       {
      *           Id = 3,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ trắng Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },
      *       new Product
      *       {
      *           Id = 4,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       }
      *       ,new Product
      *       {
      *           Id = 5,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },
      *       new Product
      *       {
      *           Id = 6,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },
      *       new Product
      *       {
      *           Id = 7,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },
      *       new Product
      *       {
      *           Id = 8,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },new Product
      *       {
      *           Id = 9,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },new Product
      *       {
      *           Id = 10,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },new Product
      *       {
      *           Id = 11,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },new Product
      *       {
      *           Id = 12,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },new Product
      *       {
      *           Id = 13,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       },new Product
      *       {
      *           Id = 14,
      *           Category_Id = 2,
      *           Name = "Áo sơ mi nữ đen Việt Tiến",
      *           DateCreated = DateTime.Now,
      *           OriginalPrice = 100000,
      *           Price = 200000,
      *           Stock = 0,
      *           ViewCount = 0,
      *           IsFeatured = true,
      *           Image = ""
      *       }
      *
      *
      *   }) ;
      * }
      * if(temp)
      * {
      *   context.SaveChanges();
      * }*/
 }
Beispiel #14
0
 public TBProdutoesController(eShopContext context)
 {
     _context = context;
 }
Beispiel #15
0
 public CategoryRepository(eShopContext eShopContext)
 {
     this.eShopContext = eShopContext;
 }
Beispiel #16
0
 public ProductRepository(eShopContext eShopContext) : base(eShopContext)
 {
 }
Beispiel #17
0
 public TBCategoriasController(eShopContext context)
 {
     _context = context;
 }