protected override void Up(MigrationBuilder migrationBuilder) { var optionsBuilder = new DbContextOptionsBuilder<LancetContext>(); var options = optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=lancet_db;Username=postgres;Password=340571578;Integrated Security=false;").Options; using (LancetContext context = new LancetContext(options)) { var metaType = context.MetaTypes.Find(Types.User.Id); context.MetaTypes.Remove(metaType); metaType = context.MetaTypes.Find(Types.Admin.Id); context.MetaTypes.Remove(metaType); var metaObject = new MetaObject() { Id = Objects.Admin.Id, Title = "Admin", Name = "admin", MetaTypeId = Types.Role.Id, CreateDate = DateTime.Now.ToUniversalTime() }; context.MetaObjects.Add(metaObject); metaObject = new MetaObject() { Id = Objects.User.Id, Title = "User", Name = "user", MetaTypeId = Types.Role.Id, CreateDate = DateTime.Now.ToUniversalTime() }; context.MetaObjects.Add(metaObject); context.SaveChanges(); } }
protected override void Up(MigrationBuilder migrationBuilder) { var optionsBuilder = new DbContextOptionsBuilder <LancetContext>(); var options = optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=lancet_db;Username=postgres;Password=340571578;Integrated Security=false;").Options; using (LancetContext context = new LancetContext(options)) { /// Тип Объект - Аккаунт context.MetaTypes.Add(new MetaType() { Id = Types.Account.Id, Title = "account", Name = "Account" }); /// Тип Объект - Группа context.MetaTypes.Add(new MetaType() { Id = Types.Group.Id, Title = "group", Name = "Group" }); /// Тип Объект - Страница context.MetaTypes.Add(new MetaType() { Id = Types.Page.Id, Title = "page", Name = "Page" }); /// Тип Связь - Роль context.MetaTypes.Add(new MetaType() { Id = Types.Role.Id, Title = "role", Name = "Role" }); /// Тип Роль - Админ context.MetaTypes.Add(new MetaType() { Id = Types.Admin.Id, Title = "admin", Name = "Admin" }); /// Тип Роль - Юзер context.MetaTypes.Add(new MetaType() { Id = Types.User.Id, Title = "user", Name = "User" }); context.SaveChanges(); } }
public MetaTypeRepository(LancetContext _LancetContext) : base(_LancetContext) { }
protected override void Up(MigrationBuilder migrationBuilder) { var optionsBuilder = new DbContextOptionsBuilder <LancetContext>(); var options = optionsBuilder.UseNpgsql("Host=localhost;Port=5432;Database=lancet_db;Username=postgres;Password=340571578;Integrated Security=false;").Options; var createDate = DateTime.Now.ToUniversalTime(); using (LancetContext context = new LancetContext(options)) { //Тестовая страница var metaObject = new MetaObject() { Id = Guid.NewGuid(), Title = "Test Page", Name = "testpage", MetaTypeId = Types.Page.Id, CreateDate = createDate, Content = "<h1>Test header</h1>" }; context.MetaObjects.Add(metaObject); //Связь страницы с ролью var relation = new Relation() { Id = Guid.NewGuid(), CreateDate = createDate }; context.Relations.Add(relation); var objectRelation = new ObjectRelation() { Id = Guid.NewGuid(), MetaTypeId = Types.Role.Id, RelationId = relation.Id, MetaObjectId = metaObject.Id }; context.ObjectRelations.Add(objectRelation); objectRelation = new ObjectRelation() { Id = Guid.NewGuid(), MetaTypeId = Types.Role.Id, RelationId = relation.Id, MetaObjectId = Objects.User.Id }; context.ObjectRelations.Add(objectRelation); //Связь аккаунта с ролью relation = new Relation() { Id = Guid.NewGuid(), CreateDate = createDate }; context.Relations.Add(relation); var account = context.MetaObjects.Find(Guid.Parse("b0e56288-e7be-4ceb-a64a-c5a6f1023738")); objectRelation = new ObjectRelation() { Id = Guid.NewGuid(), MetaTypeId = Types.Role.Id, RelationId = relation.Id, MetaObjectId = account.Id }; context.ObjectRelations.Add(objectRelation); objectRelation = new ObjectRelation() { Id = Guid.NewGuid(), MetaTypeId = Types.Role.Id, RelationId = relation.Id, MetaObjectId = Objects.User.Id }; context.ObjectRelations.Add(objectRelation); context.SaveChanges(); } }
public MetaObjectRepository(LancetContext _LancetContext) : base(_LancetContext) { }
public UnitOfWork(LancetContext LancetContext) { _LancetContext = LancetContext; }
public UserRepository(LancetContext _LancetContext) : base(_LancetContext) { }
public GenericRepository(LancetContext context) { _dbContext = context; dbSet = _dbContext.Set <TEntity>(); }
public ObjectRelationRepository(LancetContext _LancetContext) : base(_LancetContext) { }