Esempio n. 1
0
        public void Model_GenerateCreateTableSql_permanent_table()
        {
            var _          = new SampleDb().SampleModel._;
            var sqlBuilder = new IndentedStringBuilder();

            _.GenerateCreateTableSql(sqlBuilder, MySqlVersion.LowestSupported, false);
            var expectedSql =
                @"CREATE TABLE `SampleModel` (
    `Id` INT NOT NULL AUTO_INCREMENT COMMENT 'Id Description',
    `Name` VARCHAR(500) NULL DEFAULT('DEFAULT NAME') COMMENT 'Name Description',
    `Unique1` INT NULL COMMENT 'Unique1 Description',
    `Unique2` INT NULL COMMENT 'Unique2 Description',

    CONSTRAINT `PK_SampleModel` PRIMARY KEY (`Id`),
    CONSTRAINT `UQ_Temp` UNIQUE (`Unique1`, `Unique2` DESC),
    CONSTRAINT `CK_Temp` CHECK (`Name` IS NOT NULL),
    CONSTRAINT `FK_SampleModel_SampleModel_FkRef` FOREIGN KEY (`Unique1`)
        REFERENCES `SampleModel` (`Id`)
        ON DELETE NO ACTION
        ON UPDATE NO ACTION,
    INDEX `IX_SampleModel_Name` (`Name`)
) COMMENT 'Sample Model Description.';
";

            Assert.AreEqual(expectedSql, sqlBuilder.ToString());
        }
Esempio n. 2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime lifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            app.UseAiplugsFunctions <JObject>();

            lifetime.ApplicationStopped.Register(() => SampleDb.CloseAndDispose());
        }
        public ActionResult Delete(int id)
        {
            SampleDb        sampleDb         = new SampleDb();
            DemotblEmployee selectedEmployee = sampleDb.DemotblEmployees.FirstOrDefault(x => x.Id == id);

            return(View(selectedEmployee));
        }
        public ActionResult Create(DemotblEmployee emp)
        {
            SampleDb sampleDb = new SampleDb();

            sampleDb.DemotblEmployees.Add(emp);
            sampleDb.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public async Task Export()
        {
            byte[] response = await SampleDb.ExportProductsToExcel(new Query()
            {
                Filter = $@"{grid0.Query.Filter}", OrderBy = $"{grid0.Query.OrderBy}", Expand = "", Select = "Id,ProductName,ProductPrice,ProductPicture"
            }, $"Products");

            await JSRuntime.InvokeAsync <object>("saveAsFile", $"MyFile.xlsx", Convert.ToBase64String(response));
        }
        public ActionResult Delete(DemotblEmployee demoemp)
        {
            SampleDb        sampleDb         = new SampleDb();
            DemotblEmployee selectedEmployee = sampleDb.DemotblEmployees.FirstOrDefault(x => x.Id == demoemp.Id);

            sampleDb.DemotblEmployees.Remove(selectedEmployee);
            sampleDb.SaveChanges();

            return(RedirectToAction("Index"));
        }
            public ToggleController(SampleDb context)
                : base("toggle", "Toggle test controller")
            {
                _context = context;

                if (controller == null)
                {
                    controller = new TestController(_context);
                }
            }
        protected async System.Threading.Tasks.Task Load()
        {
            if (string.IsNullOrEmpty(search))
            {
                search = "";
            }

            var sampleDbGetProductsResult = await SampleDb.GetProducts(new Query()
            {
                Filter = $@"i => i.ProductName.Contains(@0)", FilterParameters = new object[] { search }
            });

            getProductsResult = sampleDbGetProductsResult;
        }
        protected async System.Threading.Tasks.Task Form0Submit(ExportOperations.Models.SampleDb.Product args)
        {
            try
            {
                var sampleDbCreateProductResult = await SampleDb.CreateProduct(product);

                DialogService.Close(product);
            }
            catch (System.Exception sampleDbCreateProductException)
            {
                NotificationService.Notify(new NotificationMessage()
                {
                    Severity = NotificationSeverity.Error, Summary = $"Error", Detail = $"Unable to create new Product!"
                });
            }
        }
Esempio n. 10
0
        private static void Main(string[] args)
        {
            var console = new ClientConsole();

            Effort.Provider.EffortProviderConfiguration.RegisterProvider();
            var connection = DbConnectionFactory.CreateTransient();

            using (var context = new SampleDb(connection, "geo"))
            {
                console.WriteLine("Welcome to EF Test Console, type help to check available commands",
                                  OutputLevel.Information, null);

                context.Products.AddRange(new[]
                {
                    new Product {
                        Name = "CocaCola"
                    },
                    new Product {
                        Name = "Pepsi"
                    },
                    new Product {
                        Name = "Starbucks"
                    },
                    new Product {
                        Name = "Donut"
                    }
                });

                context.SaveChanges();

                var ct = new System.Threading.CancellationToken();
                Task.Run(() => { SingletonSampleJob.Instance.RunBackgroundWork(ct); }, ct);

                var command = new RootCommand(console);

                command.RegisterCommand(new FillOrderCommand(context));
                command.RegisterCommand(new EditOrder(context));
                command.RegisterCommand(new QueryAuditTrail(context));
                command.RegisterCommand(new QueryOrder(context));
                command.RegisterCommand(new ToggleController(context));
                command.RegisterCommand(new JobController(context));

                var commandEngine = new CommandEngine(command);

                commandEngine.Run(args);
            }
        }
Esempio n. 11
0
        public ActionResult Edit(DemotblEmployee demoemp)
        {
            SampleDb sampleDb = new SampleDb();

            //DemotblEmployee selectedEmployee = sampleDb.DemotblEmployees.FirstOrDefault(x => x.Id == demoemp.Id);
            //selectedEmployee.FullName = demoemp.FullName;
            //selectedEmployee.Gender = demoemp.Gender;
            //selectedEmployee.Age = demoemp.Age;
            //selectedEmployee.EmailAddress = demoemp.EmailAddress;
            //selectedEmployee.HireDate = demoemp.HireDate;
            //selectedEmployee.Salary= demoemp.Salary;
            //selectedEmployee.PersonalWebSite = demoemp.PersonalWebSite;

            sampleDb.Entry(demoemp).State = System.Data.Entity.EntityState.Modified;
            sampleDb.SaveChanges();
            return(RedirectToAction("Index"));
        }
        protected async System.Threading.Tasks.Task GridDeleteButtonClick(MouseEventArgs args, dynamic data)
        {
            try
            {
                if (await DialogService.Confirm("Are you sure you want to delete this record?") == true)
                {
                    var sampleDbDeleteProductResult = await SampleDb.DeleteProduct(data.Id);

                    if (sampleDbDeleteProductResult != null)
                    {
                        await grid0.Reload();
                    }
                }
            }
            catch (System.Exception sampleDbDeleteProductException)
            {
                NotificationService.Notify(new NotificationMessage()
                {
                    Severity = NotificationSeverity.Error, Summary = $"Error", Detail = $"Unable to delete Product"
                });
            }
        }
 public SampleRepository(SampleDb db)
 {
     _db = db;
 }
Esempio n. 14
0
 public JobController(SampleDb context)
     : base("job", "Check Job")
 {
     _context = context;
 }
Esempio n. 15
0
 public FillOrderCommand(SampleDb context)
     : base("fillorder", "Add some orders to database")
 {
     _context = context;
 }
Esempio n. 16
0
 public EditOrder(SampleDb context)
     : base("edit", "Edit last Order entry")
 {
     _context = context;
 }
Esempio n. 17
0
 public QueryAuditTrail(SampleDb context)
     : base("audit", "Check last AuditTrail entry")
 {
     _context = context;
 }
Esempio n. 18
0
 public QueryOrder(SampleDb context)
     : base("order", "Check last Order")
 {
     _context = context;
 }
Esempio n. 19
0
        // GET: Home
        public ActionResult Index()
        {
            SampleDb sampleDb = new SampleDb();

            return(View(sampleDb.DemotblEmployees.ToList()));
        }
        protected async System.Threading.Tasks.Task Load()
        {
            var sampleDbGetProductByIdResult = await SampleDb.GetProductById(Id);

            product = sampleDbGetProductByIdResult;
        }