public int InsertUser(string email, string FullName, string mobileno)
        {
            UserMaster um = new UserMaster();

            um.EmailId  = email;
            um.FullName = FullName;
            um.MobileNo = mobileno;
            db.UserMaster.Add(um);
            db.SaveChanges();
            return(um.Id);
        }
Esempio n. 2
0
        public void LoadMethod(int authorsCount, string bookPath)
        {
            Random random = new Random();

            foreach (var item in Directory.GetFiles(bookPath))
            {
                //bookCount++;
                string pathBook = "/img/Books/" + Path.GetFileName(item);
                float  price    = random.Next(10, 70);
                int    discount = random.Next(10, 50);
                int    quantity = random.Next(30, 100);
                int    isNew    = random.Next(0, 2);
                bool   isnew    = Convert.ToBoolean(isNew);
                int    authors  = random.Next(1, authorsCount - 1);
                Book   book     = new Book
                {
                    Image       = pathBook,
                    Description = "This is a book witten by Author a couple of books like lorem At vero eos et accusamus et iusto odio " +
                                  "dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias " +
                                  "excepturi sint occaecati cupiditate non provident" +
                                  " similique sunt in culpa qui officia deserunt mollitia animi, " +
                                  "id est laborum et dolorum fuga.Et harum quidem rerum facilis est et expedita distinctio. ",
                    Title              = "Book Title",
                    Price              = price,
                    Discount           = discount,
                    Quantity           = quantity,
                    PriceAfterDiscount = (price - (price * discount) / 100),
                    IsThisNew          = isnew,
                    InStock            = 70,
                    AuthorId           = authors
                };
                context.Books.Add(book);
            }
            context.SaveChanges();
        }
Esempio n. 3
0
        public static void Seed(IApplicationBuilder applicationBuilder)
        {
            TestAppContext context =
                applicationBuilder.ApplicationServices.GetRequiredService <TestAppContext>();


            if (!context.Books.Any())
            {
                context.AddRange
                    (new Book
                {
                    Image    = @"C:\Users\Jerzy\source\repos\TestApplication\BookStore.Web\wwwroot\img\Books\3OVAxVVhAeE.jpg",
                    Price    = 50,
                    Discount = 0,
                    Quantity = 14
                }, new Book
                {
                    Image    = @"C:\Users\Jerzy\source\repos\TestApplication\BookStore.Web\wwwroot\img\Books\f8sNEYR1GS4.jpg",
                    Price    = 40,
                    Discount = 0,
                    Quantity = 14
                }, new Book
                {
                    Image    = @"C:\Users\Jerzy\source\repos\TestApplication\BookStore.Web\wwwroot\img\Books\fB4Cro5nwCg.jpg",
                    Price    = 60,
                    Discount = 0,
                    Quantity = 14
                }, new Book
                {
                    Image    = @"C:\Users\Jerzy\source\repos\TestApplication\BookStore.Web\wwwroot\img\Books\HdbMcallbt0.jpg",
                    Price    = 60,
                    Discount = 0,
                    Quantity = 14
                }, new Book
                {
                    Image    = @"C:\Users\Jerzy\source\repos\TestApplication\BookStore.Web\wwwroot\img\Books\HVJ4YAWOApk.jpg",
                    Price    = 14,
                    Discount = 0,
                    Quantity = 14
                }


                    );
            }

            context.SaveChanges();
        }
        public void GetHardwares_ShouldReturnAllHardwares()
        {
            var context = new TestAppContext();

            context.Hardwares.Add(new Hardware {
                Id = 1, IdHardwareType = 2, Description = "Demo name1", PurchasePrice = 5, IdPhoto = null, SerialNumber = "Abc123"
            });
            context.Hardwares.Add(new Hardware {
                Id = 2, IdHardwareType = 2, Description = "Demo name2", PurchasePrice = 5, IdPhoto = null, SerialNumber = "Abc123"
            });
            context.Hardwares.Add(new Hardware {
                Id = 3, IdHardwareType = 2, Description = "Demo name3", PurchasePrice = 5, IdPhoto = null, SerialNumber = "Abc123"
            });
            context.SaveChanges();

            var controller = new HardwaresController(new HardwareRepository(context));
            var result     = controller.GetHardwares();

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Count());
        }
Esempio n. 5
0
        public void LoadMethod(string authorsPath)
        {
            foreach (var item in Directory.GetFiles(authorsPath))
            {
                authorsCount++;
                string pathBook = "/img/authors/" + Path.GetFileName(item);

                Author author = new Author
                {
                    Image = pathBook,
                    Bio   = "This is a book witten by Author a couple of books like lorem At vero eos et accusamus et iusto odio " +
                            "dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias " +
                            "excepturi sint occaecati cupiditate non provident" +
                            " similique sunt in culpa qui officia deserunt mollitia animi, " +
                            "id est laborum et dolorum fuga.Et harum quidem rerum facilis est et expedita distinctio. ",
                    Name = "Author name"
                };
                context.Authors.Add(author);
            }
            context.SaveChanges();
        }
Esempio n. 6
0
        public void Setup()
        {
            logger           = new Mock <ILogger <ProductController> >();
            repositoryLogger = new Mock <ILogger <Repository> >();
            mapper           = new MapperConfiguration(cfg =>
            {
                cfg.AddMaps(typeof(Repository).Assembly);
            }).CreateMapper();

            var builder = new DbContextOptionsBuilder <TestAppContext>();
            var options = builder.UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;

            context = new TestAppContext(options);
            // Seed with test values
            context.Brands.Add(new Brand()
            {
                BrandId = 1, Name = "US"
            });
            context.Products.Add(new Product()
            {
                ProductId = 1, Name = "Test product", BrandId = 1, IsActive = true, Term = "monthly"
            });
            context.Products.Add(new Product()
            {
                ProductId = 2, Name = "Test product", BrandId = 1, IsActive = true, Term = "monthly"
            });
            context.Offers.Add(new Offer()
            {
                OfferId = 1, NumberOfTerms = 10, Description = "Test offer", Price = 1.0M, ProductId = 1
            });
            context.Customers.Add(new Customer()
            {
                CustomerId = 1, EmailAddress = "*****@*****.**", FirstName = "fn", LastName = "ln"
            });
            context.Orders.Add(new Order()
            {
                OrderId = 1, OfferId = 1, CustomerId = 1, StartDate = DateTime.Now, EndDate = DateTime.Now.AddMonths(5)
            });
            context.SaveChanges();
        }
Esempio n. 7
0
 public void Commit()
 {
     _context.SaveChanges();
     _logger.LogDebug("Transaction's commited");
 }