Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            DefaultServices.RegisterDefaultServices();
            Console.WriteLine("Ef Template Service Tester");
            Console.WriteLine("-------------------------");
            Console.WriteLine("Q)\t Select CustomerOrders");
            Console.WriteLine("I)\t Insert Employee");
            Console.WriteLine("E)\t Exit");
            Console.Write("Select option >>");

            string command = Console.ReadLine();

            while (command.ToUpper() != "E")
            {
                Console.WriteLine("");
                try {
                    HandleOptions(command);
                }
                catch (Exception ex) {
                    ex = ex.GetBaseException();

                    string errorMessage = "ExceptionMessage: " + ex.Message;
                    string stackTrace   = ex.StackTrace;
                    Console.WriteLine(errorMessage);
                    Console.WriteLine("StackTrace: {0}", stackTrace);
                }
                if (command.ToUpper() != "L")
                {
                    Console.WriteLine("Select option >>");
                }
                command = Console.ReadLine();
            }
        }
Ejemplo n.º 2
0
        public void CustomTest()
        {
            DefaultServices.RegisterDefaultServices();
            CustomerRepository    customers    = northWindUnitOfWork.CustomerRepository;
            OrderRepository       orders       = northWindUnitOfWork.OrderRepository;
            OrderDetailRepository orderDetails = northWindUnitOfWork.OrderDetailRepository;
            ProductRepository     products     = northWindUnitOfWork.ProductRepository;

            EmployeeRepository employeeRepository = northWindUnitOfWork.EmployeeRepository;

            employeeRepository.Add(new Employee {
                FirstName = "Emrah", LastName = "Dinçadam"
            });
            employeeRepository.Add(new Employee {
                FirstName = "Türenç", LastName = "Engin"
            });

            var employe = employeeRepository.Table().ToList();

            Assert.AreEqual(employe.Count(), 2);

            var testQuery = from c in customers.Table()
                            join o in orders.Table() on c.CustomerId equals o.CustomerId
                            join od in orderDetails.Table() on o.OrderId equals od.OrderId
                            join p in products.Table() on od.ProductId equals p.ProductId
                            //where c.CustomerType == CustomerType.Individual
                            orderby o.OrderId descending
                            orderby c.CompanyName ascending
                            select new CustomerOrderDetailDto()
            {
                OrderId      = o.OrderId,
                ProductId    = p.ProductId,
                ProductName  = p.ProductName,
                UnitPrice    = od.UnitPrice,
                Quantity     = od.Quantity,
                Discount     = od.Discount,
                CompanyName  = c.CompanyName,
                ContactName  = c.ContactName,
                Phone        = c.Phone,
                OrderDate    = o.OrderDate,
                RequiredDate = o.RequiredDate,
                ShippedDate  = o.ShippedDate
            };
            List <CustomerOrderDetailDto> customerOrderDetails = testQuery.Top(1000).NoLock().ToList();

            Assert.AreEqual(customerOrderDetails.Count(), 0);
        }
Ejemplo n.º 3
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     services.AddTransient <INorthWindTransactionalUnitOfWork, NorthWindUnitOfWork>();
     services.AddTransient <IDmsTransactionalUnitOfWork, DmsUnitOfWork>();
     services.AddResponseCompression(options =>
     {
         options.Providers.Add <GzipCompressionProvider>();
         options.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(new[] { "image/svg+xml" });
         //todo:turenc-->https://docs.microsoft.com/en-us/aspnet/core/performance/response-compression?tabs=aspnetcore2x
     });
     services.Configure <GzipCompressionProviderOptions>(options =>
     {
         options.Level = CompressionLevel.Fastest;
     });
     DefaultServices.RegisterDefaultServices();
     //services.AddAuthorization()
 }
Ejemplo n.º 4
0
        public void BllTest()
        {
            DefaultServices.RegisterDefaultServices();
            EmployeeTransactions employeeTransactions = new EmployeeTransactions(northWindUnitOfWork);
            EmployeeRequest      employeeRequest      = new EmployeeRequest()
            {
                EmployeeDto = new EmployeeDto()
                {
                    EmployeeId      = 0,
                    LastName        = "Emrah",
                    FirstName       = "Dinçadam",
                    Title           = "Emrah Dinçadam",
                    TitleOfCourtesy = "ED",
                    BirthDate       = new DateTime(1986, 07, 14),
                    HireDate        = new DateTime(2018, 01, 15),
                    Address         = "Sanayi Mahallesi, Teknopark Bulvarı 1/3C Kurtköy - Pendik",
                    City            = "İstanbul",
                    Region          = "Anadolu",
                    PostalCode      = "34906",
                    Country         = "Türkiye",
                    HomePhone       = "+90 216 664 20 00",
                    Extension       = "",
                    Photo           = null,
                    Notes           = "Developer",
                    ReportsTo       = null,
                    PhotoPath       = ""
                }
            };

            EmployeeResponse response = TransactionProcessor <NorthWindContext> .Execute
                                        (
                employeeTransactions.InsertEmployee,
                employeeRequest,
                northWindUnitOfWork
                                        );

            OrderOperations orderOperations     = new OrderOperations(northWindUnitOfWork);
            var             customerOrderDetail = orderOperations.GetCustomerOrderDetails(new CustomerOrderDetailRequest()
            {
                CustomerId = 1
            });
        }
Ejemplo n.º 5
0
        public void ServiceTest()
        {
            DefaultServices.RegisterDefaultServices();
            EmployeeController employeeController = new EmployeeController(northWindUnitOfWork);
            EmployeeRequest    employeeRequest    = new EmployeeRequest()
            {
                EmployeeDto = new EmployeeDto()
                {
                    EmployeeId      = 0,
                    LastName        = "Türenç",
                    FirstName       = "Engin",
                    Title           = "Türenç Engin",
                    TitleOfCourtesy = "TE",
                    BirthDate       = new DateTime(1986, 07, 14),
                    HireDate        = new DateTime(2018, 01, 15),
                    Address         = "Sanayi Mahallesi, Teknopark Bulvarı 1/3C Kurtköy - Pendik",
                    City            = "İstanbul",
                    Region          = "Anadolu",
                    PostalCode      = "34906",
                    Country         = "Türkiye",
                    HomePhone       = "+90 216 664 20 00",
                    Extension       = "",
                    Photo           = null,
                    Notes           = "Developer",
                    ReportsTo       = null,
                    PhotoPath       = ""
                }
            };

            IActionResult result = employeeController.InsertEmpoloyee(employeeRequest);

            if (result is JsonResult)
            {
                JsonResult jsonResult = (JsonResult)result;
                if (jsonResult.Value is EmployeeResponse)
                {
                    EmployeeResponse employeeResponse = (EmployeeResponse)jsonResult.Value;
                }
            }
        }
Ejemplo n.º 6
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors();
            services.AddDbContext <DataContext>(x => x.UseInMemoryDatabase("TestDb"));
            services.AddMvc();
            services.AddAutoMapper();
            DefaultServices.RegisterDefaultServices();
            // configure strongly typed settings objects
            var appSettingsSection = Configuration.GetSection("AppSettings");

            services.Configure <AppSettings>(appSettingsSection);

            // configure jwt authentication
            var appSettings = appSettingsSection.Get <AppSettings>();
            var key         = Encoding.ASCII.GetBytes(appSettings.Secret);

            services.AddAuthentication(x =>
            {
                x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
                x.DefaultChallengeScheme    = JwtBearerDefaults.AuthenticationScheme;
            })
            .AddJwtBearer(x =>
            {
                x.RequireHttpsMetadata      = false;
                x.SaveToken                 = true;
                x.TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuerSigningKey = true,
                    IssuerSigningKey         = new SymmetricSecurityKey(key),
                    ValidateIssuer           = false,
                    ValidateAudience         = false
                };
            });

            // configure DI for application services
            services.AddScoped <IUserService, UserService>();
        }
Ejemplo n.º 7
0
        public void ProductDbOperationsOperations()
        {
            DefaultServices.RegisterDefaultServices();
            ProductCatalogContext ctx = new ProductCatalogContext();
            var     result            = ctx.Product.Where(p => p.Code == "Product1").ToList();
            Product product1          = CommonTestData.GetTestData();
            var     addProductResult1 = ctx.Product.Add(product1);

            ctx.SaveChanges();
            var getProductResult1 = ctx.Product.Where(p => p.Code == product1.Code).ToList().FirstOrDefault();

            Assert.AreEqual(getProductResult1.Name, product1.Name);
            getProductResult1.Name = "ProductNameNew";
            ctx.Product.Update(getProductResult1);
            ctx.SaveChanges();
            var getProductResult2 = ctx.Product.Where(p => p.Code == product1.Code).ToList().FirstOrDefault();

            Assert.AreEqual(getProductResult2.Name, "ProductNameNew");
            ctx.Product.Remove(getProductResult2);
            ctx.SaveChanges();
            var finalProductResult = ctx.Product.Find(getProductResult2.Id);

            Assert.AreEqual(finalProductResult, null);
        }
Ejemplo n.º 8
0
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc();
     DefaultServices.RegisterDefaultServices();
 }