예제 #1
0
        /*
         * private static void buildAuth(DbModelBuilder modelBuilder)
         * {
         *  modelBuilder.Entity<AspNetUser>()
         *      .HasMany(e => e.Roles)
         *      .WithRequired(e => e.User)
         *      .HasForeignKey(e => e.UserId);
         *
         *  modelBuilder.Entity<AspNetUser>()
         *      .HasMany(e => e.Claims)
         *      .WithRequired(e => e.User)
         *      .HasForeignKey(e => e.UserId);
         *
         *  modelBuilder.Entity<AspNetUser>()
         *      .HasMany(e => e.Logins)
         *      .WithRequired(e => e.User)
         *      .HasForeignKey(e => e.UserId);
         *
         *  modelBuilder.Entity<AspNetRole>()
         *      .HasKey(e=>e.Id)
         *      .HasMany(e => e.Users)
         *      .WithRequired(e => e.Role)
         *      .HasForeignKey(e => e.RoleId);
         *
         *  modelBuilder.Entity<AspNetUserClaim>()
         *      .HasKey(e => e.Id);
         *
         *  //suspect chances of the oauth provider keys overlapping is pretty remote
         *  modelBuilder.Entity<AspNetUserLogin>()
         *      .HasKey(e => new { e.LoginProvider, e.ProviderKey, e.UserId});
         *
         *  modelBuilder.Entity<AspNetUserRole>()
         *      .HasKey(e => new { e.RoleId, e.UserId });
         *
         * }
         *
         *
         * private SanitizeStringProperties _sanitizeHtml { get; set; }
         * private SanitizeStringProperties SanitizeHtml
         * {
         *  get { return _sanitizeHtml ?? (_sanitizeHtml = new SanitizeStringProperties()); }
         * }
         */

        public override Task <int> SaveChangesAsync()
        {
            BeforeSave();

            try
            {
                return(base.SaveChangesAsync());
            }
            catch (DbEntityValidationException e)
            {
                var de = new DetailedEntityValidationException(e);
                throw de;
            }
        }
예제 #2
0
        public override int SaveChanges()
        {
            //not sanitizing for the time being - at that point we will need a wysywig editor
            //SanitizeHtml.ForEntities(ChangeTracker);
            BeforeSave();

            try
            {
                return(base.SaveChanges());
            }
            catch (DbEntityValidationException e)
            {
                var de = new DetailedEntityValidationException(e);
                throw de;
            }
        }