Exemplo n.º 1
0
 public static IEnumerable <BudgetCategory> GetAll()
 {
     using (var context = new CCDPlannerDBContext())
     {
         IEnumerable <BudgetCategory> categories = context.BudgetCategories.Where(x => x.ParentCategory == null).ToList();
         categories = Traverse(categories);
         return(categories);
     }
 }
Exemplo 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,
            CCDPlannerDBContext dbContext,
            DbIdentityInitializer dbIdentityInitializer
            )
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(b => b.AllowAnyOrigin()
                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .AllowCredentials()
                        );

            // Set up custom content types -associating file extension to MIME type
            var provider = new FileExtensionContentTypeProvider();

            // Add new mappings
            provider.Mappings[".woff"] = "application/font-woff";

            app.UseStaticFiles(new StaticFileOptions()
            {
                ContentTypeProvider = provider
            });

            // Identity
            app.UseAuthentication();

            app.Use(async(context, next) =>
            {
                await next();

                if (context.Response.StatusCode == 404 &&
                    !Path.HasExtension(context.Request.Path.Value) &&
                    !context.Request.Path.Value.StartsWith("api"))
                {
                    string actualpath = "/index.html";

                    context.Request.Path        = actualpath;
                    context.Response.StatusCode = 200;
                    await next();
                }
            });

            app.UseDefaultFiles();
            app.UseStaticFiles();
            app.UseMvc();

            DbInitializer.Initialize(dbContext);
            dbIdentityInitializer.Seed().Wait();
        }
Exemplo n.º 3
0
        private static IEnumerable <BudgetCategory> Traverse(IEnumerable <BudgetCategory> categories)
        {
            using (var context = new CCDPlannerDBContext())
            {
                foreach (var category in categories)
                {
                    var subCategories = context.BudgetCategories.Where(x => x.ParentCategoryId == category.BudgetCategoryId).ToList();
                    category.ChildrenCategories = subCategories;
                    category.ChildrenCategories = Traverse(category.ChildrenCategories).ToList();
                }

                return(categories);
            }
        }
Exemplo n.º 4
0
 protected override BudgetCategory UpdateEntity(CCDPlannerDBContext entityContext, BudgetCategory entity)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 protected override BudgetCategory GetEntity(CCDPlannerDBContext entityContext, Guid id)
 {
     return(GetEntities(entityContext).Where(c => c.BudgetCategoryId == id).FirstOrDefault());
 }
Exemplo n.º 6
0
        protected override IEnumerable <BudgetCategory> GetEntities(CCDPlannerDBContext entityContext)
        {
            IEnumerable <BudgetCategory> categories = entityContext.BudgetCategories;

            return(categories.Where(c => c.ParentCategoryId == null));
        }
Exemplo n.º 7
0
 protected override BudgetCategory AddEntity(CCDPlannerDBContext entityContext, BudgetCategory entity)
 {
     return(entityContext.BudgetCategories.Add(entity).Entity);
 }