Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                              FDDataContext fdDataContext)
        {
            loggerFactory.AddNLog();
            app.UseCors("corsPolicy");

            //throw new System.Exception("test error");

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseDeveloperExceptionPage();
                //app.UseExceptionHandler("/error");
                //app.UseHsts();
            }

            //app.AddCors(options =>
            //{
            //    options.AddPolicy("CorsPolicy",
            //        builder => builder.AllowAnyOrigin()
            //        .AllowAnyMethod()
            //        .AllowAnyHeader()
            //        .AllowCredentials());
            //});

            fdDataContext.EnsureSeedDataForContext();
            app.UseStatusCodePages();

            AutoMapper.Mapper.Initialize(cfg =>
            {
                cfg.CreateMap <Entities.Account, Models.AccountWithoutFormsDto>();
                cfg.CreateMap <Entities.Account, Models.AccountDto>();
                cfg.CreateMap <Models.AccountForCreateDto, Entities.Account>();
                cfg.CreateMap <Models.AccountForUpdateDto, Entities.Account>();
                cfg.CreateMap <Entities.Account, Models.AccountForUpdateDto>();
                cfg.CreateMap <Entities.Form, Models.FormDto>();
                cfg.CreateMap <Models.FormForCreationDto, Entities.Form>();
                cfg.CreateMap <Models.FormForUpdateDto, Entities.Form>();
                cfg.CreateMap <Entities.Form, Models.FormForUpdateDto>();
                cfg.CreateMap <Entities.Column, Models.ColumnDto>();
                cfg.CreateMap <Models.ColumnForCreationDto, Entities.Column>();
                cfg.CreateMap <Models.ColumnForUpdateDto, Entities.Column>();
                cfg.CreateMap <Entities.Column, Models.ColumnForUpdateDto>();
            });

            //app.UseHttpsRedirection();
            app.UseMvc();
        }
Esempio n. 2
0
 public FormRepository(FDDataContext context)
 {
     _context = context;
 }
Esempio n. 3
0
 public AccountRepository(FDDataContext context)
 {
     _context = context;
 }
Esempio n. 4
0
        public static void EnsureSeedDataForContext(this FDDataContext context)
        {
            if (context.Accounts.Any())
            {
                return;
            }

            // init seed data
            var accounts = new List <Account>()
            {
                new Account()
                {
                    Title       = "New York City",
                    Description = "The one with that big park.",
                    Forms       = new List <Form>()
                    {
                        new Form()
                        {
                            Title       = "Central Park",
                            Description = "The most visited urban park in the United States."
                        },
                        new Form()
                        {
                            Title       = "Empire State Building",
                            Description = "A 102-story skyscraper located in Midtown Manhattan."
                        },
                    }
                },
                new Account()
                {
                    Title       = "Antwerp",
                    Description = "The one with the cathedral that was never really finished.",
                    Forms       = new List <Form>()
                    {
                        new Form()
                        {
                            Title       = "Cathedral",
                            Description = "A Gothic style cathedral, conceived by architects Jan and Pieter Appelmans."
                        },
                        new Form()
                        {
                            Title       = "Antwerp Central Station",
                            Description = "The the finest example of railway architecture in Belgium."
                        },
                    }
                },
                new Account()
                {
                    Title       = "Paris",
                    Description = "The one with that big tower.",
                    Forms       = new List <Form>()
                    {
                        new Form()
                        {
                            Title       = "Eiffel Tower",
                            Description = "A wrought iron lattice tower on the Champ de Mars, named after engineer Gustave Eiffel."
                        },
                        new Form()
                        {
                            Title       = "The Louvre",
                            Description = "The world's largest museum."
                        },
                    }
                }
            };

            context.Accounts.AddRange(accounts);
            context.SaveChanges();
        }