public void Initialize()
        {
            Context = new ReleaseContext(GlobalValues.UnitTestReinitializableConnectionString);

            reflector = new DbContextReflector(Context, GlobalValues.ReleaseContextModelsNamespace, GlobalValues.ReleaseContextModelsAssembly);
            comparer  = new EntityComparerByKeys();
        }
        public void Initialize()
        {
            //Reinitialize the database with test data
            System.Data.Entity.Database.SetInitializer(new RecordLabel.Data.Models.Configurations.DropCreateAndSeedInitializer <ReleaseContext>());

            Context = new ReleaseContext(GlobalValues.UnitTestReinitializableConnectionString);
        }
        public EntityBaseController(ReleaseContext dbContext, Func <ReleaseContext, DbSet <TModel> > entitySet) : base(dbContext)
        {
            this.entitySet     = entitySet(DbContext.Context);
            ModelOrderBy       = init => init.OrderBy(item => item.Id);
            ListModelQuery     = initQuery => initQuery;
            CompleteModelQuery = initQuery => ListModelQuery(initQuery);

            ItemsPerPage = Settings.ListItemBatchSize;
        }
        public HttpResponseMessage Delete(int id)
        {
            if (id == 0)
            {
                throw new IndexOutOfRangeException();
            }

            ReleaseContext db = new ReleaseContext();

            ImageHelper.DeleteImage(db, db.Images.Single(img => img.Id == id));
            db.SaveChanges();

            return(new HttpResponseMessage(System.Net.HttpStatusCode.OK));
        }
Exemple #5
0
        public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            object model = base.BindModel(controllerContext, bindingContext);

            ReleaseContext      dbContext = ((IHasDbContext <ReleaseContext>)controllerContext.Controller).DbContext;
            NameValueCollection form      = controllerContext.HttpContext.Request.Form;

            if (form.AllKeys.Contains("ReleaseIds"))
            {
                int[] ids = form.GetValues("ReleaseIds").Select(item => int.Parse(item)).ToArray();
                ((Artist)model).Releases = dbContext.Releases.Where(item => ids.Contains(item.Id)).ToArray();
            }

            return(model);
        }
 public BaseWithImagesController(ReleaseContext dbContext, Func <ReleaseContext, DbSet <TModel> > entitySet) : base(dbContext, entitySet)
 {
     ListModelQuery = initQuery => initQuery.Include(entity => entity.Images); //.Collection ?
 }
Exemple #7
0
 public BaseController(ReleaseContext dbContext)
 {
     DbContext     = new ContextWrapper <ReleaseContext>(dbContext);
     IndexViewName = "List";
     EditViewName  = "Edit";
 }
Exemple #8
0
 public HomeController(ReleaseContext context)
 {
     _context = context;
 }
 public BaseWithAttributesController(ReleaseContext dbContext, Func <ReleaseContext, DbSet <TModel> > entitySet) : base(dbContext, entitySet)
 {
 }
 public ReleaseChangesMerger(ReleaseContext dbContext, string modelsNamespace, string modelAssemblyName)
     : base(dbContext, modelsNamespace, modelAssemblyName)
 {
 }
Exemple #11
0
 /// <summary>
 /// Deletes image from the database
 /// </summary>
 public static void DeleteImage(ReleaseContext dbContext, Image image)
 {
     image.Delete(dbContext);
 }
Exemple #12
0
 public Repository()
 {
     // TODO: DI
     context = new ReleaseContext("MainConnectionString");
 }
Exemple #13
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, ReleaseContext context)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see http://go.microsoft.com/fwlink/?LinkID=532715

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

            DbInitializer.Initialize(context);
        }
 public ReleaseNotesController(ReleaseContext context)
 {
     _context = context;
 }
Exemple #15
0
 public void Init()
 {
     dbContext = new ReleaseContext();
     reflector = new DbContextReflector(dbContext, "RecordLabel.TheContext", "TheContext");
 }
Exemple #16
0
 public MetadataController(ReleaseContext dbContext, Func <ReleaseContext, DbSet <TModel> > entitySet) : base(dbContext, entitySet)
 {
     ItemsPerPage = int.MaxValue;
 }