diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Adds.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Adds.cs deleted file mode 100644 index aaaea54..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Adds.cs +++ /dev/null @@ -1,8 +0,0 @@ - public class Adds - { - - public static int Add(int x, int y) -{ - return x+y; -} - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts index 190dd88..2b26472 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app-routing.module.ts @@ -4,15 +4,13 @@ import { MsalGuard } from "@azure/msal-angular"; import { HomeComponent } from "./components/home/home.component"; import { ProfileComponent } from "./components/profile/profile.component"; import { UserComponent } from "./components/users/users.component"; -import { utCreateComponent } from "./components/utCreate/utCreate.component"; -import { utExecuteComponent } from "./components/utExecute/utExecute.component"; -import { utTreeViewTestComponent } from "./components/utTreeViewTest/utTreeViewTest.component"; import { RoleGuard } from "./shared/guards/role.guard"; +import { UnitTestsComponent } from "./components/unit-tests/unit-tests.component"; const routes: Routes = [ { path: "", pathMatch: "full", redirectTo: "/unittests" }, { path: "profile", component: ProfileComponent, canActivate: [MsalGuard] }, - { path: "unittests", component: utTreeViewTestComponent, canActivate: [MsalGuard] }, + { path: "unittests", component: UnitTestsComponent, canActivate: [MsalGuard] }, ]; @NgModule({ diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts index 1a0e5d1..412e655 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/app.module.ts @@ -64,19 +64,14 @@ import { LayoutService } from "./shared/services/layout.service"; import { DxTreeListModule } from "devextreme-angular"; import { RoleGuard } from "./shared/guards/role.guard"; import { Router } from "@angular/router"; -import { utCreateComponent } from "./components/utCreate/utCreate.component"; -import { utExecuteComponent } from "./components/utExecute/utExecute.component"; -import { UnitTestService } from "./shared/services/UnitTest.service"; -import { UserStoryService } from "./shared/services/UserStory.service"; -import { utTreeViewTestComponent } from "./components/utTreeViewTest/utTreeViewTest.component"; +import { UnitTestService } from "./shared/services/unit-test.service"; +import { UserStoryService } from "./shared/services/user-story.service"; import { WorkspaceService } from "./shared/services/workspace.service"; -import { TabularModelService } from "./shared/services/TabularModel.service"; -import { StructurService } from "./shared/services/structur.service"; +import { TabularModelService } from "./shared/services/tabular-model.service"; import { DxoHideEventModule } from "devextreme-angular/ui/nested"; -import { HistoryService } from "./shared/services/history.service"; import { SideNavigationMenuComponent } from "./components/side-navigation-menu/side-navigation-menu.component"; - - +import { UnitTestsComponent } from "./components/unit-tests/unit-tests.component"; +import { GetFirstElementPipe } from "./shared/pipes/get-first-element.pipe"; export function initializeAppConfig(appConfig: AppConfig, router: Router) { return () => appConfig.load(); @@ -88,10 +83,9 @@ export function initializeAppConfig(appConfig: AppConfig, router: Router) { HomeComponent, ProfileComponent, UserComponent, - utCreateComponent, - utExecuteComponent, - utTreeViewTestComponent, - SideNavigationMenuComponent + UnitTestsComponent, + SideNavigationMenuComponent, + GetFirstElementPipe ], imports: [ BrowserModule.withServerTransition({ appId: "ng-cli-universal" }), @@ -162,8 +156,6 @@ export function initializeAppConfig(appConfig: AppConfig, router: Router) { UserStoryService, WorkspaceService, TabularModelService, - StructurService, - HistoryService, ], bootstrap: [AppComponent, MsalRedirectComponent], }) diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html index 30ae345..5951139 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.html @@ -20,10 +20,18 @@
-

First Name: {{user?.Firstname}}

-

Last Name: {{user?.Lastname}}

-

Email: {{user?.Email}}

-

Azure AD Id: {{user?.MsId}}

-

Roles: {{roles}}

+

First Name: {{ user?.Firstname }}

+

Last Name: {{ user?.Lastname }}

+

Email: {{ user?.Email }}

+

Azure AD Id: {{ user?.MsId }}

+

Roles: {{ roles }}

+
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts index 7dbb48c..630a5d7 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/profile/profile.component.ts @@ -9,6 +9,7 @@ import { import { Subject } from "rxjs"; import { filter, takeUntil } from "rxjs/operators"; import { User } from "src/app/shared/models/user.model"; +import { LayoutService, NotificationType } from "src/app/shared/services/layout.service"; import { ODataService } from "src/app/shared/services/odata.service"; import { UserService } from "src/app/shared/services/user.service"; @@ -23,8 +24,9 @@ export class ProfileComponent implements OnInit { roles: string; constructor( - private userService: UserService - ) {} + private userService: UserService, + private layoutService: LayoutService + ) { } ngOnInit(): void { this.getUserInformation(); @@ -33,9 +35,9 @@ export class ProfileComponent implements OnInit { }); } - private getUserInformation(){ + private getUserInformation() { this.isLoggedIn = this.userService.isLogggedIn; - if(this.isLoggedIn){ + if (this.isLoggedIn) { this.user = this.userService.currentDbUserWithTenant; this.roles = this.userService.currentUserRoles?.join(", "); } @@ -48,4 +50,9 @@ export class ProfileComponent implements OnInit { async logout() { await this.userService.logout(); } + + public onClickResetGridSettings(e): void { + localStorage.removeItem("atPowerBiUnitTestPortal_UnitTests_TreeListState"); + this.layoutService.notify({ message: "The grid settings have been successfully reset.", type: NotificationType.Success }); + } } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.css new file mode 100644 index 0000000..a645a87 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.css @@ -0,0 +1,15 @@ +::ng-deep .dx-treelist-search-panel { + margin: 0 !important; +} + +::ng-deep .hide-checkbox .dx-select-checkbox{ + display: none; +} + +::ng-deep .hide-checkbox .dx-treelist-icon-container{ + padding-right: 0px; +} + +::ng-deep dx-select-box { + margin-bottom: 15px; +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.html new file mode 100644 index 0000000..659ed08 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.html @@ -0,0 +1,119 @@ +

Unit Tests

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ {{ data.value }} + error durring + execution +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + Workspace: + + + Tabular Model: + + + + + \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.ts new file mode 100644 index 0000000..d4c5fcc --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/unit-tests/unit-tests.component.ts @@ -0,0 +1,530 @@ +import { Component, OnInit, ViewChild } from "@angular/core"; +import { DxDataGridComponent, DxTreeListComponent } from "devextreme-angular"; +import CustomStore from "devextreme/data/custom_store"; +import DataSource from "devextreme/data/data_source"; +import { ClickEvent } from "devextreme/ui/button"; +import { ToolbarPreparingEvent } from "devextreme/ui/tree_list"; +import { UserStory } from "src/app/shared/models/user-story.model"; +import { UnitTestService } from "src/app/shared/services/unit-test.service"; +import { confirm } from 'devextreme/ui/dialog'; +import { + LayoutParameter, + LayoutService, + NotificationType, +} from "src/app/shared/services/layout.service"; +import { UserStoryService } from "src/app/shared/services/user-story.service"; +import { WorkspaceService } from "src/app/shared/services/workspace.service"; +import { UnitTest } from "src/app/shared/models/unit-test.model"; +import ODataContext from "devextreme/data/odata/context"; +import { TabularModelService } from "src/app/shared/services/tabular-model.service"; + +@Component({ + selector: "app-unit-tests", + templateUrl: "./unit-tests.component.html", + styleUrls: ["./unit-tests.component.css"], +}) +export class UnitTestsComponent implements OnInit { + public dataSourceWorkspaces: DataSource; + public dataSourceWorkspacesOdata: DataSource; + public dataSourceTabularModels: DataSource; + @ViewChild(DxTreeListComponent, { static: false }) + treeList: DxDataGridComponent; + + public isVisibleEditUnitTest: boolean = false; + public isVisibleEditUserStory: boolean = false; + public isVisibleCopyUserStory: boolean = false; + public popupTitle: string = ""; + + public userStoryToEdit: UserStory = {}; + public unitTestToEdit: UnitTest = {}; + public copyUserStoryConfig: { workspaceId?: number, tabularModelId?: number, userStoryId?: number, tabularModelToExclude?: number } = {}; + + public resultTypeItems: string[] = ["String", "Float", "Date", "Percentage"]; + public dateTimeFormatItems: string[] = ["UTC", "CET"]; + public floatSeparatorItems: string[] = ["Use Seperators", "Dont use Sperators"]; + public decimalPlacesItems: string[] = ["1", "2", "3", "4", "5"]; + + constructor( + private unitTestService: UnitTestService, + private userStoryService: UserStoryService, + private workspaceService: WorkspaceService, + private tabularModelService: TabularModelService, + private layoutService: LayoutService + ) { + this.onClickExecuteUnitTests = this.onClickExecuteUnitTests.bind(this); + this.onClickAddUserStory = this.onClickAddUserStory.bind(this); + this.onClickEditUserStory = this.onClickEditUserStory.bind(this); + this.onClickDeleteUserStory = this.onClickDeleteUserStory.bind(this); + this.onClickAddUnitTest = this.onClickAddUnitTest.bind(this); + this.onClickEditUnitTest = this.onClickEditUnitTest.bind(this); + this.onClickDeleteUnitTest = this.onClickDeleteUnitTest.bind(this); + this.onClickCopyUserStory = this.onClickCopyUserStory.bind(this); + + this.dataSourceWorkspaces = new DataSource({ + store: new CustomStore({ + key: "UniqueIdentifier", + load: async (loadOptions) => { + if (loadOptions.expand == null) + loadOptions.expand = new Array(); + loadOptions.expand.push("TabularModels"); + loadOptions.expand.push("TabularModels.UserStories"); + loadOptions.expand.push("TabularModels.UserStories.UnitTests"); + loadOptions.expand.push("TabularModels.UserStories.UnitTests.TestRuns($top=1;$orderby=TimeStamp desc)"); + return (this.workspaceService.getStore().load(loadOptions)).then((data) => { + data.forEach(e => { + delete Object.assign(e, { ["items"]: e["TabularModels"] })["TabularModels"] + e["type"] = "Workspace"; + e["parentId"] = 0; + e["items"]?.forEach(ee => { + delete Object.assign(ee, { ["items"]: ee["UserStories"] })["UserStories"] + ee["type"] = "Tabular Model"; + ee["parentId"] = e["UniqueIdentifier"]; + ee["items"]?.forEach(eee => { + delete Object.assign(eee, { ["items"]: eee["UnitTests"] })["UnitTests"] + eee["type"] = "User Story"; + eee["parentId"] = ee["UniqueIdentifier"]; + eee["items"]?.forEach(eeee => { + eeee["type"] = "Unit Test"; + eeee["parentId"] = eee["UniqueIdentifier"]; + }) + }) + }) + }); + }); + } + }) + }); + + this.dataSourceWorkspacesOdata = new DataSource({ + store: this.workspaceService.getStore(), + sort: [{ selector: "Name", desc: false }] + }); + } + + ngOnInit(): void { } + + public onClickPullWorkspaces(e: ClickEvent): void { + this.layoutService.change(LayoutParameter.ShowLoading, true); + this.workspaceService + .pullWorkspaces() + .then(() => { + this.treeList.instance.refresh(); + this.layoutService.notify({ + message: "Workspaces pulled successfully", + type: NotificationType.Success, + }); + }) + .catch((error: Error) => this.layoutService.notify({ + message: error.message ? `Can not pull workspaces: ${error.message}` : "Error while pulling workspaces", + type: NotificationType.Error, + })) + .finally(() => + this.layoutService.change(LayoutParameter.ShowLoading, false) + ); + } + + public onToolbarPreparingTreeList(e: ToolbarPreparingEvent): void { + let toolbarItems = e.toolbarOptions.items; + + toolbarItems.unshift({ + widget: "dxButton", + options: { + icon: "refresh", + stylingMode: "contained", + type: "normal", + hint: "Refresh Applications", + onClick: this.onClickRefresh.bind(this), + }, + location: "after", + }); + + toolbarItems.unshift({ + widget: "dxButton", + options: { + icon: "clear", + stylingMode: "contained", + type: "normal", + hint: "Clear Selection", + onClick: this.onClickClearSelection.bind(this), + }, + location: "after", + }); + + toolbarItems.unshift({ + widget: "dxButton", + options: { + icon: "trash", + stylingMode: "contained", + type: "danger", + hint: "Delete Unit Tests", + text: "Delete Unit Tests", + onClick: this.onClickDeleteMultipleUnitTests.bind(this), + }, + location: "after", + }); + + toolbarItems.unshift({ + widget: "dxButton", + options: { + icon: "runner", + stylingMode: "contained", + type: "success", + hint: "Execute Unit Tests", + text: "Execute Unit Tests", + onClick: this.onClickExecuteMultipleUnitTests.bind(this), + }, + location: "after", + }); + + toolbarItems.unshift({ + widget: "dxButton", + options: { + icon: "download", + text: "Pull Workspaces", + stylingMode: "contained", + type: "normal", + onClick: this.onClickPullWorkspaces.bind(this), + }, + location: "before", + }); + } + + public onCellPreparedTreeList(e: any): void { + if (e.rowType === "data" && e.row.data.type == "Unit Test" && e.column.dataField === "TestRuns[0].Result") { + e.cellElement.style.color = e.row.data?.TestRuns[0]?.WasPassed ? "green" : "red"; + } + } + + public onRowDbClickTreeList(e: any): void { + if (e.rowType === "data" && e.data.type == "Unit Test") { + this.openEditUnitTestPopup(e.data); + } + else if (e.rowType == "data" && e.data.type == "User Story") { + this.openEditUserStoryPopup(e.data); + } + } + + public onRowPreparedTreeList(e: any): void { + if (e.rowType == "data" && e.data.type != "Unit Test" || e.rowType == "header") { + e.rowElement.classList.add("hide-checkbox"); + } + } + + public onClickCopyUserStory(e: any): void { + this.copyUserStoryConfig = {}; + this.copyUserStoryConfig.tabularModelToExclude = e.row.data.TabularModel; + this.copyUserStoryConfig.userStoryId = e.row.data.Id; + this.isVisibleCopyUserStory = true; + } + + public onClickSaveCopyUserStory(e: any): void { + this.layoutService.change(LayoutParameter.ShowLoading, true); + this.userStoryService.copyToOtherTabularModel(this.copyUserStoryConfig.userStoryId, this.copyUserStoryConfig.tabularModelId) + .then(() => { + this.layoutService.notify({ + type: NotificationType.Success, + message: "The user story was copied successfully." + }); + this.isVisibleCopyUserStory = false; + this.copyUserStoryConfig = {}; + this.treeList.instance.refresh(); + }) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The user story could not be copied.: ${error.message}` : "The user story could not be copied." + })) + .then(() => { this.layoutService.change(LayoutParameter.ShowLoading, false); }); + } + + public onValueChangeCopyUserStoryWorkspace(e: any): void { + this.copyUserStoryConfig.workspaceId = e.value.Id; + this.dataSourceTabularModels = new DataSource({ + store: this.tabularModelService.getStore(), + filter: [["Workspace", "=", e.value.Id], "and", ["Id", "<>", this.copyUserStoryConfig.tabularModelToExclude]], + sort: [{ selector: "Name", desc: false }], + }); + } + + public onValueChangeCopyUserStoryTabularModel(e: any): void { + this.copyUserStoryConfig.tabularModelId = e.value.Id; + } + + public onClickClearSelection(e: any): void { + this.treeList.instance.clearSelection(); + } + + public onClickExecuteMultipleUnitTests(e: any): void { + let data = this.treeList.instance.getSelectedRowsData(); + let unitTestIds = data.filter((e: any) => e.type == "Unit Test").map((e: any) => e.Id); + if (unitTestIds.length == 0) { + this.layoutService.notify({ + type: NotificationType.Info, + message: "No unit tests selected for execution." + }); + return; + } + this.executeUnitTest(unitTestIds); + } + + public onClickExecuteUnitTests(e: any): void { + let unitTestIdsToExecute = []; + if (e.row.data.type == "Unit Test") + unitTestIdsToExecute = [e.row.data.Id]; + else if (e.row.data.type == "User Story") + unitTestIdsToExecute = e.row.node.children.map((e: any) => e.data.Id); + else if (e.row.data.type == "Tabular Model") + unitTestIdsToExecute = e.row.node.children.flatMap((e: any) => e.children.map((ee: any) => ee.data.Id)); + else if (e.row.data.type == "Workspace") + unitTestIdsToExecute = e.row.node.children.flatMap((e: any) => e.children.flatMap((ee: any) => ee.children.map((eee: any) => eee.data.Id))); + + this.executeUnitTest(unitTestIdsToExecute); + } + + public onClickRefresh(e: ClickEvent): void { + this.treeList.instance.refresh(); + } + + public onClickAddUnitTest(e: any): void { + this.popupTitle = "Add Unit Test"; + this.unitTestToEdit = {}; + this.unitTestToEdit.UserStory = e.row.data.Id; + this.isVisibleEditUnitTest = true; + } + + public onClickEditUnitTest(e: any): void { + this.openEditUnitTestPopup(e.row.data); + } + + public onClickAddUserStory(e: any): void { + this.popupTitle = "Add User Story"; + this.userStoryToEdit = {}; + this.userStoryToEdit.TabularModel = e.row.data.Id; + this.isVisibleEditUserStory = true; + } + + public onClickEditUserStory(e: any): void { + this.openEditUserStoryPopup(e.row.data); + } + + public onClickDeleteUserStory(e: any): void { + let result = confirm("Are you sure you want to delete this user story (including all unit tests)?", "Delete User Story"); + result.then((dialogResult) => { + if (dialogResult) { + this.layoutService.change(LayoutParameter.ShowLoading, true); + this.userStoryService.remove(e.row.data.Id) + .then(() => this.layoutService.notify({ + type: NotificationType.Success, + message: "The user story was deleted successfully." + })) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The user story could not be deleted: ${error.message}` : "The user story could not be deleted." + })) + .then(() => { + this.treeList.instance.refresh(); + this.layoutService.change(LayoutParameter.ShowLoading, false); + }); + } + }); + } + + public onClickDeleteMultipleUnitTests(e: any): void { + let data = this.treeList.instance.getSelectedRowsData(); + let unitTestIds = data.filter((e: any) => e.type == "Unit Test").map((e: any) => e.Id); + if (unitTestIds.length == 0) { + this.layoutService.notify({ + type: NotificationType.Info, + message: "No unit tests selected for deletion." + }); + return; + } + + let result = confirm("Are you sure you want to delete these unit tests?", "Delete Unit Tests"); + result.then((dialogResult) => { + if (dialogResult) { + this.layoutService.change(LayoutParameter.ShowLoading, true); + let promises = []; + unitTestIds.forEach((e: any) => { + promises.push(this.unitTestService.remove(e)); + }); + Promise.all(promises) + .then(() => this.layoutService.notify({ + type: NotificationType.Success, + message: "The unit tests were deleted successfully." + })) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `One or more unit tests could not be deleted: ${error.message}` : "One or more unit tests could not be deleted" + })) + .then(() => { + this.treeList.instance.refresh(); + this.layoutService.change(LayoutParameter.ShowLoading, false); + }); + } + }); + } + + public onClickDeleteUnitTest(e: any): void { + let result = confirm("Are you sure you want to delete this unit test?", "Delete Unit Test"); + result.then((dialogResult) => { + if (dialogResult) { + this.layoutService.change(LayoutParameter.ShowLoading, true); + this.unitTestService.remove(e.row.data.Id) + .then(() => this.layoutService.notify({ + type: NotificationType.Success, + message: "The unit test was deleted successfully." + })) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The unit test could not be deleted: ${error.message}` : "The unit test could not be deleted." + })) + .then(() => { + this.treeList.instance.refresh(); + this.layoutService.change(LayoutParameter.ShowLoading, false); + }); + } + }); + } + + public onClickSaveUnitTest(e: ClickEvent): void { + let validation = e.validationGroup.validate(); + if (validation.isValid == true) { + this.layoutService.change(LayoutParameter.ShowLoading, true); + let editPromise; + if (this.unitTestToEdit.Id != null) { + editPromise = this.unitTestService.update(this.unitTestToEdit.Id, { Name: this.unitTestToEdit.Name, DAX: this.unitTestToEdit.DAX, ExpectedResult: this.unitTestToEdit.ExpectedResult, ResultType: this.unitTestToEdit.ResultType, DateTimeFormat: this.unitTestToEdit.DateTimeFormat, FloatSeparators: this.unitTestToEdit.FloatSeparators, DecimalPlaces: this.unitTestToEdit.DecimalPlaces }) + .then(() => { + this.layoutService.notify({ + type: NotificationType.Success, + message: "The unit test has been edited successfully." + }); + this.isVisibleEditUnitTest = false; + this.unitTestToEdit = {}; + this.treeList.instance.refresh(); + }) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The unit test could not be edited: ${error.message}` : "The unit test could not be edited." + })) + + } + else { + editPromise = this.unitTestService.add(this.unitTestToEdit) + .then(() => { + this.layoutService.notify({ + type: NotificationType.Success, + message: "The new uni test has been created successfully." + }); + this.isVisibleEditUnitTest = false; + this.unitTestToEdit = {}; + this.treeList.instance.refresh(); + }) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The new unit test could not be created: ${error.message}` : "The new unit test could not be created." + })) + } + + editPromise.then(() => { + this.layoutService.change(LayoutParameter.ShowLoading, false); + }); + } + } + + public onClickSaveUserStory(e: ClickEvent): void { + let validation = e.validationGroup.validate(); + if (validation.isValid == true) { + this.layoutService.change(LayoutParameter.ShowLoading, true); + let editPromise; + if (this.userStoryToEdit.Id != null) { + editPromise = this.userStoryService.update(this.userStoryToEdit.Id, { Name: this.userStoryToEdit.Name }) + .then(() => { + this.layoutService.notify({ + type: NotificationType.Success, + message: "The user story has been edited successfully." + }); + this.isVisibleEditUserStory = false; + this.userStoryToEdit = {}; + this.treeList.instance.refresh(); + }) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The user story could not be edited: ${error.message}` : "The user story could not be edited." + })) + } + else { + editPromise = this.userStoryService.add(this.userStoryToEdit) + .then(() => { + this.layoutService.notify({ + type: NotificationType.Success, + message: "The new user story has been created successfully." + }); + this.isVisibleEditUserStory = false; + this.userStoryToEdit = {}; + this.treeList.instance.refresh(); + }) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `The new user story could not be created: ${error.message}` : "The new user story could not be created." + })) + } + + editPromise.then(() => { + this.layoutService.change(LayoutParameter.ShowLoading, false); + }); + } + } + + public isWorkspaceRow(e: any): boolean { + if (e.row.rowType == "data" && e.row.data.type == "Workspace") + return true; + return false; + } + + public isUnitTestRow(e: any): boolean { + if (e.row.rowType == "data" && e.row.data.type == "Unit Test") + return true; + return false; + } + + public isUserStoryRow(e: any): boolean { + if (e.row.rowType == "data" && e.row.data.type == "User Story") + return true; + return false; + } + + public isTabularModelRow(e: any): boolean { + if (e.row.rowType == "data" && e.row.data.type == "Tabular Model") + return true; + return false; + } + + private openEditUnitTestPopup(unitTest: UnitTest): void { + this.popupTitle = "Edit Unit Test"; + this.unitTestToEdit = structuredClone(unitTest); + this.isVisibleEditUnitTest = true; + } + + private openEditUserStoryPopup(userStory: UserStory): void { + this.popupTitle = "Edit User Story"; + this.userStoryToEdit = structuredClone(userStory); + this.isVisibleEditUserStory = true; + } + + private executeUnitTest(ids: number[]): void { + this.layoutService.change(LayoutParameter.ShowLoading, true); + this.unitTestService.executeMultiple(ids) + .then(() => { + this.layoutService.notify({ + type: NotificationType.Success, + message: "Unit test(s) executed successfully." + }); + this.treeList.instance.refresh(); + }) + .catch((error: Error) => this.layoutService.notify({ + type: NotificationType.Error, + message: error?.message ? `Unit tests could not be executed: ${error.message}` : "Unit tests could not be executed." + })) + .then(() => { this.layoutService.change(LayoutParameter.ShowLoading, false); }); + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.css deleted file mode 100644 index 8b13789..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.css +++ /dev/null @@ -1 +0,0 @@ - diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.html deleted file mode 100644 index 733a4fc..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.ts deleted file mode 100644 index abde3ef..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utCreate/utCreate.component.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { Component, OnInit, ViewChild } from "@angular/core"; -import DataSource from "devextreme/data/data_source"; -import { UserService } from "src/app/shared/services/user.service"; -import { - LayoutParameter, - LayoutService, - NotificationType, -} from "src/app/shared/services/layout.service"; -import { AppConfig } from "src/app/shared/config/app.config"; -import { User } from "src/app/shared/models/user.model"; -import { environment } from "src/environments/environment"; -import { DxDataGridComponent, DxListComponent, DxPopupComponent } from "devextreme-angular"; -import { UnitTestService } from "src/app/shared/services/UnitTest.service"; -import { UnitTest } from "src/app/shared/models/UnitTest.model"; -import * as pbi from 'powerbi-client'; -import { ElementRef } from "@angular/core"; -import notify from "devextreme/ui/notify"; -import { UserStoryService } from "src/app/shared/services/UserStory.service"; -import { UserStory } from "src/app/shared/models/UserStory.model"; - - - - -@Component({ - selector: "app-utCreate", - templateUrl: "./utCreate.component.html", - //styleUrls: ["./utExecute.component.css"], -}) -export class utCreateComponent{ - dataSourceUserStory: DataSource; - currentSelectedUnitTest: UserStory; - @ViewChild(DxDataGridComponent, { static: false }) dataGrid: DxDataGridComponent; - - - constructor( - private UserStoryService: UserStoryService, - private layoutService: LayoutService, - ) { - this.dataSourceUserStory = new DataSource({ - store: this.UserStoryService.getStore(), - - }); - - } -} - diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.css deleted file mode 100644 index e69de29..0000000 diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.html deleted file mode 100644 index c85011c..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.html +++ /dev/null @@ -1,78 +0,0 @@ - - -

Hallo das ist auch ein Test

- - - - - - - - - - - - - - - - - -
- - - -
- -
- - -
- -
- - -
- -
-

Das Ergebnis lautet :{{ Ergebnis }}

-
- - - - - \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.ts deleted file mode 100644 index 3240f2d..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utExecute/utExecute.component.ts +++ /dev/null @@ -1,74 +0,0 @@ -import { Component, OnInit, ViewChild } from "@angular/core"; -import DataSource from "devextreme/data/data_source"; -import { UserService } from "src/app/shared/services/user.service"; -import { - LayoutParameter, - LayoutService, - NotificationType, -} from "src/app/shared/services/layout.service"; -import { AppConfig } from "src/app/shared/config/app.config"; -import { User } from "src/app/shared/models/user.model"; -import { environment } from "src/environments/environment"; -import { DxDataGridComponent, DxListComponent, DxPopupComponent } from "devextreme-angular"; -import { UnitTestService } from "src/app/shared/services/UnitTest.service"; -import { UnitTest } from "src/app/shared/models/UnitTest.model"; -import * as pbi from 'powerbi-client'; -import { ElementRef } from "@angular/core"; -import notify from "devextreme/ui/notify"; -import { Structur } from "src/app/shared/models/Structur.model"; -import { HttpClient } from "@angular/common/http"; - -@Component({ - selector: "app-utExecute", - templateUrl: "./utExecute.component.html", - //styleUrls: ["./utExecute.component.css"], -}) -export class utExecuteComponent{ - dataSourceUnitTest: DataSource; - currentSelectedUnitTest: UnitTest; - Ergebnis: string; - @ViewChild(DxDataGridComponent, { static: false }) dataGrid: DxDataGridComponent; - - - - constructor( - private UnitTestService: UnitTestService, - private layoutService: LayoutService, - ) { - this.dataSourceUnitTest = new DataSource({ - store: this.UnitTestService.getStore(), - - }); - - } - - - public executeUnitTest(){ - let UnitTestData: Structur[] = this.dataGrid.instance.getSelectedRowsData(); - - - //this.UnitTestService.executeUnitTest(UnitTestData[0]).subscribe(data => this.Ergebnis = data); - - if (UnitTestData.length == 0){ - return; - } - - this.UnitTestService.executeUnitTest(UnitTestData[0]); - - //this.Ergebnis = this.UnitTestService.executeUnitTest(UnitTestData[0]) - } - public LoadWorkspace(event){ - let UnitTestData: UnitTest[] = this.dataGrid.instance.getSelectedRowsData(); - - this.UnitTestService.LoadWorkspace(); - notify("Workspaces werden geladen", "success", 6000); - } - - public LoadDataset(event){ - let UnitTestData: UnitTest[] = this.dataGrid.instance.getSelectedRowsData(); - - this.UnitTestService.LoadDataset(); - notify("Datasets werden geladen", "success", 6000); - } - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.css b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.css deleted file mode 100644 index c0ed655..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.css +++ /dev/null @@ -1,30 +0,0 @@ -::ng-deep #form-container { - margin: 10px 10px 30px; -} - -::ng-deep .long-title h3 { - font-family: 'Segoe UI Light', 'Helvetica Neue Light', 'Segoe UI', 'Helvetica Neue', 'Trebuchet MS', Verdana; - font-weight: 200; - font-size: 28px; - text-align: center; - margin-bottom: 20px; -} - -::ng-deep .dax-column{ - max-width: 200px; -} - -::ng-deep .hide-checkbox .dx-select-checkbox{ - display: none; -} - -::ng-deep .hide-checkbox .dx-treelist-icon-container{ - padding-right: 0px; -} - -.popup-content { - padding: 20px; - text-align: center; - } - - \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.html deleted file mode 100644 index d01124d..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.html +++ /dev/null @@ -1,593 +0,0 @@ -

Übersicht

- - - - - -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - -
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-

UnitTests hinzufügen

-
-
- - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - -
-
-

UnitTests Bearbeiten

-
-
- - - - - - - - - - - - - - - - - - - - - - - - -
-
-
- - -
-
-

UserStory hinzufügen

-
-
- - - - - - - - - - -
-
-
- - -
-
-

UserStory bearbeiten

-
-
- - - - - - - - - - -
-
-
- - -
- -
-

Testläufe

-
-
- - - - - - - - - - - - - - -
-
-
- -
- - - - - - - - -
- -
-

Wähle ein TabularModel aus in das kopiert werden soll:

-
-
- - - - - - - - - - - - - - - - - - - -
-
-
- -
diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.ts deleted file mode 100644 index b2f4567..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/components/utTreeViewTest/utTreeViewTest.component.ts +++ /dev/null @@ -1,551 +0,0 @@ -import { Component, OnInit, ViewChild } from "@angular/core"; -import {LayoutParameter, LayoutService, NotificationType,} from "src/app/shared/services/layout.service"; -import notify from "devextreme/ui/notify"; -import { WorkspaceService } from "src/app/shared/services/workspace.service"; -import { Workspace } from "src/app/shared/models/workspace.model"; -import { UnitTestService } from "src/app/shared/services/UnitTest.service"; -import { UnitTest } from "src/app/shared/models/UnitTest.model"; -import { StructurService } from "src/app/shared/services/structur.service"; -import { Structur } from "src/app/shared/models/Structur.model"; -import { UserStoryService } from "src/app/shared/services/UserStory.service"; -import { UserStory } from "src/app/shared/models/UserStory.model"; -import { TabularModel } from "src/app/shared/models/TabularModel.model"; -import { DxTreeListComponent } from "devextreme-angular"; -import { TestRuns } from "src/app/shared/models/TestRuns.model"; -import { TestRunStructur } from "src/app/shared/models/TestRunStructur.model"; -import { TabularModelStructure } from "src/app/shared/models/TabularModelStructure"; - - -@Component({ - selector: "app-TreeViewTest", - templateUrl: "./utTreeViewTest.component.html", - styleUrls: ["./utTreeViewTest.component.css"], - }) - export class utTreeViewTestComponent{ - public structures: Structur[]; - public TestRunsStructures: TestRunStructur[]; - public TabularModelStructures: TabularModelStructure[]; - - public unitTestToEdit: UnitTest; - public unitTestToDelete: UnitTest; - public userStoryToEdit: UserStory; - public userStoryToCopy: UserStory; - - public isPopupVisibleUTEdit: boolean = false; - public isPopupVisibleUT: boolean = false; - public isPopupVisibleUS: boolean = false; - public isPopupVisibleTR: boolean = false; - public isPopupVisibleTB: boolean = false; - public isPopupVisibleUSedit: boolean = false; - public isPopupVisibleDelete: boolean = false; - public searchText: string = ''; // Property to hold the search text - - - public ResultTypes: string[] = ["String", "Float","Date","Percentage"]; - public DateTimeFormats: string[] = ["UTC","CET"]; - public DateTimeFormats2: string[] = ["Long", "Short"]; - public Seperators: string[] = ["Use Seperators", "Dont use Sperators"]; - public decimal: string[]=["1","2","3","4","5"]; - public header: string = "Testläufe"; - public IsTypeString: boolean = false; - public IsTypeDate: boolean = false; - public IsTypeFloat: boolean = false; - - @ViewChild(DxTreeListComponent, { static: false }) treeList: DxTreeListComponent; - - constructor( - private StructurService: StructurService, - private WorkspaceService: WorkspaceService, - private UnitTestService: UnitTestService, - private UserStoryService: UserStoryService, - private LayoutService: LayoutService) - { - this.loadData(); - // this.loadDataForPopUp(); - this.showUnitTestEdit = this.showUnitTestEdit.bind(this); - this.showUserStoryEdit = this.showUserStoryEdit.bind(this); - this.checkType = this.checkType.bind(this); - this.deleteUnitTest = this.deleteUnitTest.bind(this); - this.showUnitTest = this.showUnitTest.bind(this); - this.showUserStory = this.showUserStory.bind(this); - this.executeUnitTestsForRow = this.executeUnitTestsForRow.bind(this); - this.editUserStory = this.editUserStory.bind(this); - this.togglePopupDelete = this.togglePopupDelete.bind(this); - this.showDelete = this.showDelete.bind(this); - this.deleteWorkspace = this.deleteWorkspace.bind(this); - this.loadDataForPopUp = this.loadDataForPopUp.bind(this); - this.loadDataForPopUpTabModel = this.loadDataForPopUpTabModel.bind(this); - this.showTestRuns = this.showTestRuns.bind(this); - this.showTabModel = this.showTabModel.bind(this); - this.showTestRunsLocal = this.showTestRunsLocal.bind(this); - this.onClickCopyUserStory = this.onClickCopyUserStory.bind(this); - - } - - public loadData(): void { - this.LayoutService.change(LayoutParameter.ShowLoading, true); - this.WorkspaceService.getWorkspaces().then((Workspaces: Workspace[])=>{ - this.StructurService.getStructure(Workspaces).then((Structur) => { - this.structures = Structur; - this.LayoutService.change(LayoutParameter.ShowLoading, false); - }) - }); - } - - public loadDataForPopUp(): void{ - this.StructurService.getRuns().then((TestRuns: TestRuns[]) => { - this.StructurService.GetTestRunStructure(TestRuns).then((TRstructure) => { - this.TestRunsStructures = TRstructure; - }) - }) - } - - public loadDataForPopUpTabModel(): void{ - this.WorkspaceService.getWorkspaces().then((Workspaces: Workspace[]) => { - this.StructurService.GetTabModelStructure(Workspaces).then((TBstructure) => { - this.TabularModelStructures = TBstructure; - }) - }) - - } - - public onClickCopyUserStory(e: any): void{ - - - const userStoryId = this.userStoryToCopy.Id; - const targetTabularModelId = e.row.data.Id; - const targetWorkspaceId = e.row.data.Workspace; - - this.UserStoryService.copyToOtherTabularModel(userStoryId, targetTabularModelId, targetWorkspaceId) - .then(() => { - notify("UserStory wurde kopiert", "success", 2000); - // Fügen Sie hier die gewünschten Aktualisierungen oder Benachrichtigungen hinzu - }) - .catch((error) => { - console.error("Fehler beim Kopieren der UserStory", error); - // Hier können Sie Fehlerbehandlung oder Benachrichtigungen hinzufügen - }); - this.isPopupVisibleTB = false; - } - - public showTabModel(e: any) - { - this.loadDataForPopUpTabModel(); - this.userStoryToCopy = new UserStory(); - this.userStoryToCopy.Id = e.row.data.Id; - this.isPopupVisibleTB = true; - - } - - public showTestRuns() - { - this.loadDataForPopUp(); - - this.isPopupVisibleTR = true; - } - - public showTestRunsLocal(e: any):void - { - this.header = "Testläufe von "+e.row.data.Typ + ": "+e.row.data.Name; - this.StructurService.GetTestRunStructureForWorkspace(e.row.data.Name).then((TRstructure) => { - this.TestRunsStructures = TRstructure; - }); - this.isPopupVisibleTR = true; - } - - - public showUnitTestEdit(e: any): void{ - let unitTestStructure: Structur; - if(e.row == undefined){ - if(e.data.Typ != "UnitTest") // disable double click for non-UnitTest rows - return; - unitTestStructure = e.data; - } - else - unitTestStructure = e.row.data; - - let unitTest: UnitTest = { - Id: unitTestStructure.Id, - Name: unitTestStructure.Name, - ExpectedResult: unitTestStructure.ExpectedResult, - LastResult: unitTestStructure.LastResult, - Timestamp: unitTestStructure.Timestamp, - UserStory: unitTestStructure.UserStory, - DAX: unitTestStructure.DAX - }; - console.log("this.toggle", this); - this.togglePopupUTEdit(unitTest); - - } - - public showUserStoryEdit(e: any): void - { - let userStory: UserStory = { - Id: e.row.data.Id, - Beschreibung: e.row.data.Name, - TabularModel: e.row.node.parent.data.Id - }; - - this.togglePopupUSEdit(userStory); - } - - public showUnitTest(e: any): void{ - let userStoryId: number = e.row.data.Id; - this.togglePopupUT(userStoryId); - } - - public showUserStory(e: any): void{ - let tabularModelId: number = e.row.data.Id; - this.togglePopupUS(tabularModelId); - } - - public showDelete(e: any) - { - let unitTestStructure: Structur; - if(e.row == undefined){ - if(e.data.Typ != "UnitTest") // disable double click for non-UnitTest rows - return; - unitTestStructure = e.data; - } - else - unitTestStructure = e.row.data; - - - this.unitTestToDelete = { - Id: unitTestStructure.Id, - Name: unitTestStructure.Name, - ExpectedResult: unitTestStructure.ExpectedResult, - LastResult: unitTestStructure.LastResult, - Timestamp: unitTestStructure.Timestamp, - UserStory: unitTestStructure.UserStory, - DAX: unitTestStructure.DAX - }; - let unitTestX: UnitTest; - unitTestX = this.unitTestToDelete; - console.log("this.toggle", this); - this.togglePopupDelete(unitTestX); - } - - public onCellPrepared(e) { - if(e.rowType === "data" && e.column.dataField === "LastResult") { - e.cellElement.style.color = e.data.ExpectedResult == e.data.LastResult ? "green" : "red"; - } - } - public onRowPrepared(e: any): void{ - if (e.rowType == "data" && e.data.Typ != "UnitTest" || e.rowType == "header") { - e.rowElement.classList.add("hide-checkbox"); - } - } - - public addUserStory(e){ - this.UserStoryService.getStore().insert(this.userStoryToEdit).then(()=> { - notify("UserStory '" + this.userStoryToEdit.Beschreibung + "' wurde hinzugefügt", "success", 2000); - this.loadData(); - this.togglePopupUS(); - }) - } - - public addUnitTest(e){ - this.UnitTestService.getStore().insert(this.unitTestToEdit).then(()=> { - notify("UnitTest '" + this.unitTestToEdit.Name + "' wurde hinzugefügt", "success", 2000); - this.loadData(); - this.togglePopupUT(); - }) - } - - public editUnitTest(e){ - this.UnitTestService.getStore().update(this.unitTestToEdit.Id, this.unitTestToEdit).then(()=> { - notify("UnitTest '" + this.unitTestToEdit.Name + "' wurde bearbeitet", "success", 2000); - this.loadData(); - this.togglePopupUTEdit(); - }) - } - - public editUserStory(e){ - this.UserStoryService.getStore().update(this.userStoryToEdit.Id, this.userStoryToEdit).then(()=> { - notify("UserStory '" + this.userStoryToEdit.Beschreibung + "' wurde bearbeitet", "success", 2000); - this.loadData(); - this.togglePopupUSEdit(); - }) - } - - confirmDelete(answer: string, e: any): void { - this.isPopupVisibleDelete = false; // Close the popup - if (answer === 'yes') { - this.deleteUnitTest(e); - } - } - - public deleteUnitTest(e: any){ - let id: number = e.Id; - let name: string = e.Name; - - //this.isPopupVisibleDelete = true - - - this.UnitTestService.getStore().remove(id).then(()=> { - notify("UnitTest '" + name + "' wurde gelöscht", "success", 2000); - this.loadData(); - }); - } - - public deleteWorkspace(e: any){ - let id: number = e.row.data.Id; - let name: string = e.row.data.Name; - - this.WorkspaceService.getStore().remove(id).then(()=> { - notify("Workspace '" + name + "' wurde gelöscht", "success", 2000); - this.loadData(); - }); - } - - public deleteUnitTestsForSelection(e: any): void { - this.LayoutService.change(LayoutParameter.ShowLoading, true); - let results: void[] = new Array(); - let selectedRowsData: any[] = this.treeList.instance.getSelectedRowsData(); - - if(selectedRowsData.length == 0) - notify("No unit tests were selected", "error", 2000) - else - selectedRowsData.forEach(r => - { this.UnitTestService.getStore().remove(r.Id).then(()=> { - notify("UnitTest '" + r.Name + "' wurde gelöscht", "success", 2000); - this.loadData(); - }); - }); - } - - public LoadWorkspace(event){ - this.UnitTestService.LoadWorkspace(); - notify("Workspaces werden geladen", "success", 6000); - } - - public executeUnitTestsForRow(e: any): void { - this.LayoutService.change(LayoutParameter.ShowLoading, true); - let rowData: Structur = e.row.data; - delete (rowData as any).id; - this.executeUnitTests(rowData).then((values) => { - notify("All selected unit tests have been executed!", "success", 2000); - this.LayoutService.change(LayoutParameter.ShowLoading, false); - this.loadData(); - }); - } - - public isWorkspaceRow(e: any): boolean{ - if(e.row.rowType == "data" && e.row.data.Typ == "Workspace") - return true; - return false; - } - - public isUnitTestRow(e: any): boolean{ - if(e.row.rowType == "data" && e.row.data.Typ == "UnitTest") - return true; - return false; - } - - public isUserStoryRow(e: any): boolean{ - if(e.row.rowType == "data" && e.row.data.Typ == "UserStory") - return true; - return false; - } - - public isTabularModelRow(e: any): boolean{ - if(e.row.rowType == "data" && e.row.data.Typ == "TabularModel") - return true; - return false; - } - - public executeUnitTestsForSelection(e: any): void { - this.LayoutService.change(LayoutParameter.ShowLoading, true); - let results: Promise[] = new Array(); - let selectedRowsData: Structur[] = this.treeList.instance.getSelectedRowsData(); - - if(selectedRowsData.length == 0) - notify("No unit tests were selected", "error", 2000) - else - selectedRowsData.forEach(r => - { - delete (r as any).id; - results.push(this.executeUnitTests(r)); - }); - - Promise.all(results).then((values) => { - notify("All selected unit tests have been executed!", "success", 2000); - this.LayoutService.change(LayoutParameter.ShowLoading, false); - this.loadData(); - }); - } - - private togglePopupUT(userStoryId: number = undefined): void { - this.isPopupVisibleUT = !this.isPopupVisibleUT; - if(this.isPopupVisibleUT == true && userStoryId != undefined){ - this.unitTestToEdit = new UnitTest(); - this.unitTestToEdit.UserStory = userStoryId; - } - } - - private togglePopupUS(tabularModelId: number = undefined): void { - this.isPopupVisibleUS = !this.isPopupVisibleUS; - if(this.isPopupVisibleUS == true && tabularModelId != undefined){ - this.userStoryToEdit = new UserStory(); - this.userStoryToEdit.TabularModel = tabularModelId; - } - } - - private togglePopupUTEdit(unitTest: UnitTest = undefined): void { - this.isPopupVisibleUTEdit = !this.isPopupVisibleUTEdit; - if(this.isPopupVisibleUTEdit == true && unitTest != undefined){ - this.unitTestToEdit = unitTest; - } - } - - private togglePopupUSEdit(userStory: UserStory = undefined): void { - this.isPopupVisibleUSedit = !this.isPopupVisibleUSedit; - if(this.isPopupVisibleUSedit == true && userStory != undefined){ - this.userStoryToEdit = userStory; - } - } - - public togglePopupDelete(unitTest: UnitTest = undefined): void { - this.isPopupVisibleDelete = !this.isPopupVisibleDelete; - if(this.isPopupVisibleDelete == true && unitTest != undefined){ - this.unitTestToDelete = unitTest; - } - } - - - public checkType(type: any){ - if(type.value == 'String') - { - this.IsTypeString = true; - this.IsTypeFloat = false; - this.IsTypeDate = false; - } - - if(type.value == 'Float') - { - this.IsTypeFloat = true; - this.IsTypeString = false; - this.IsTypeDate = false; - } - - if(type.value == 'Date') - { - this.IsTypeDate = true; - this.IsTypeFloat = false; - this.IsTypeString = false; - } - } - - private executeUnitTests(structur: Structur): Promise{ - let results: Promise[] = new Array(); - - if(structur.Typ == "Workspace") - results = this.executeUnitTestsOfWorkspace(this.structures.find(s => s.Id == structur.Id)); - else if(structur.Typ == "TabularModel") - results = this.executeUnitTestsOfTabularModel(this.structures.find(s => s.WorkspacePbId == structur.WorkspacePbId).items.find(s => s.Typ == "TabularModel" && s.Id == structur.Id)); - else if (structur.Typ == "UserStory") - results.push(this.executeUnitTestsOfUserStory(this.structures.find(s => s.WorkspacePbId == structur.WorkspacePbId).items.find(s => s.items.find(u => u.Id == structur.Id) != undefined).items.find(s => s.Typ == "UserStory" && s.Id == structur.Id))); - else if (structur.Typ == "UnitTest") - results.push(this.UnitTestService.executeUnitTest(structur)); - - return Promise.all(results); - } - - private executeUnitTestsOfUserStory(userstory: any): Promise{ - return new Promise((resolve)=> { - let results: Promise[] = new Array(); - let Result : string; - let Count : number; - let i : number - i = 0; - Result = "True"; - - userstory.items.forEach((unitTest: UnitTest) => { - results.push(this.UnitTestService.executeUnitTest(unitTest as Structur).then(() => - { - if(this.UnitTestService.wasUnitTestSuccessful == false) - Result = "False" - })); - i++; - Count = i; - - }) - - Promise.all(results).then(() => { - this.UnitTestService.SaveTestRun(Result, "UserStory", Count, userstory.Name); - - resolve(); - }); - }) - } - - private executeUnitTestsOfTabularModel(tabularModel: any): Promise[]{ - let results: Promise[] = new Array(); - let Result : string; - let Count : number; - let i : number - i = 0; - Result = "True"; - - tabularModel.items.forEach((userStory: any) => { - userStory.items.forEach((unitTest: UnitTest) => - { - results = results.concat(this.UnitTestService.executeUnitTest(unitTest as Structur).then(() => - { - if(this.UnitTestService.wasUnitTestSuccessful == false) - Result = "False" - } - - )); - i++ - Count = i - - }) - - }) - - Promise.all(results).then(() => { - this.UnitTestService.SaveTestRun(Result, "TabularModel" , Count, tabularModel.Name); - }); - - return results; - } - - private executeUnitTestsOfWorkspace(workspace: any): Promise[]{ - let results: Promise[] = new Array(); - let Result : string; - let Count : number; - let i : number - let Histories : History[]; - i = 0; - Result = "True"; - - workspace.items.forEach((tabularModel: any) => { - tabularModel.items.forEach((userStory: any) => { - userStory.items.forEach((unitTest: UnitTest) => - { - results = results.concat(this.UnitTestService.executeUnitTest(unitTest as Structur).then(() => - { - if(this.UnitTestService.wasUnitTestSuccessful == false) - Result = "False" - - } - - )); - i++ - Count = i - - - }) - - }) - }) - - Promise.all(results).then(() => { - this.UnitTestService.SaveTestRun(Result, "Workspace" , Count, workspace.Name); - }); - - return results; - } - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/History.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/History.model.ts deleted file mode 100644 index 0d71fc4..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/History.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { TestRuns } from "./TestRuns.model"; -import { UnitTest } from "./UnitTest.model"; - -export class History -{ - public Id?: number; - public TimeStamp?: string; - public Result?: string; - public LastRun?: string; - public ExpectedRun: string; - public UnitTest: number; - - public UnitTestNavigation?: UnitTest; - public TestRunNavigation?: TestRuns; - -} - - - \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/ResultType.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/ResultType.ts deleted file mode 100644 index 379cff5..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/ResultType.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { UnitTest } from "./UnitTest.model"; - -export class ResultType -{ - Name?: string; - - - UnitTests?: UnitTest[]; -} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/Structur.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/Structur.model.ts deleted file mode 100644 index eea3ee6..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/Structur.model.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { UserStory } from "./UserStory.model"; - -export class Structur { - Typ?: string; - - Name?: string; - - WorkspacePbId?: string; - - DatasetPbId?: string; - - ExpectedResult?: string; - - DAX?: string; - - Timestamp?: string; - - LastResult?: string; - - Id?: number; - - UserStory?: number; - - UserStoryNavigation?: UserStory; - - items?: Structur[]; -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModelStructure.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModelStructure.ts deleted file mode 100644 index be44b96..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModelStructure.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { TestRunStructur } from "./TestRunStructur.model"; -import { UserStory } from "./UserStory.model"; -import { Workspace } from "./workspace.model"; - -export interface TabularModelStructure { - DatasetPbId?: string; - Workspace?: number; - Name?: string; - Id?: number; - - items?: TestRunStructur[]; - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRunStructur.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRunStructur.model.ts deleted file mode 100644 index 895f5c1..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRunStructur.model.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { UserStory } from "./UserStory.model"; - -export class TestRunStructur { - public TimeStamp?: string; - public Result?: string; - public Workspace?: string; - public TabularModel?: string; - public UserStory?: string; - public Count?: number; - public Type?: string; - public Name?: string; - - items?: TestRunStructur[]; -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRuns.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRuns.model.ts deleted file mode 100644 index 88af9fc..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TestRuns.model.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UnitTest } from "./UnitTest.model"; -import { History } from "./History.model"; - -export class TestRuns -{ - public id?: number; - public TimeStamp?: string; - public Result?: string; - public Workspace?: string; - public TabularModel?: string; - public UserStory?: string; - public Count?: number; - public Type?: string; - public Name?: string; - - public HistoriesRun?: History[]; - - -} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTest.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTest.model.ts deleted file mode 100644 index b3a2622..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTest.model.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { UserStory } from "./UserStory.model"; -import { History } from "./History.model"; -import { ResultType } from "./ResultType"; - -export class UnitTest -{ - public Id?: number; - - public Name?: string; - public ExpectedResult?: string; - public LastResult?: string; - public Timestamp?: string; - public UserStory?: number; - public DAX?: string; - public ResultType?: string; - public DateTimeFormat?: string; - public DecimalPlaces?: string; - public FloatSeparators?: string; - - UserStoryNavigation?: UserStory; - ResultTypeNavigation?: ResultType; - Histories?: History[]; - } - \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTestExecutionResult.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTestExecutionResult.ts deleted file mode 100644 index 3f38732..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UnitTestExecutionResult.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface UnitTestExecutionResult{ - unitTestSucceeded: boolean; - unitTestExecuted: boolean; -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UserStory.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UserStory.model.ts deleted file mode 100644 index db0b4aa..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/UserStory.model.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { TabularModel } from "./TabularModel.model"; -import { UnitTest } from "./UnitTest.model"; - -export class UserStory -{ - Id?: number; - Beschreibung?: string; - TabularModel?: number; - - TabularModelNavigation?: TabularModel; - UnitTests?: UnitTest[]; -} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/odatastringresponse.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/odatastringresponse.ts deleted file mode 100644 index 8b06e6d..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/odatastringresponse.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface OdataStringResponse -{ - value: string; -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModel.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/tabular-model.model.ts similarity index 68% rename from at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModel.model.ts rename to at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/tabular-model.model.ts index 47dd071..ee07070 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/TabularModel.model.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/tabular-model.model.ts @@ -1,12 +1,12 @@ -import { UserStory } from "./UserStory.model"; +import { UserStory } from "./user-story.model"; import { Workspace } from "./workspace.model"; export interface TabularModel { Id?: number; - DatasetPbId?: string; + UniqueIdentifier?: string; + MsId?: string; Workspace?: number; Name?: string; - - WorkspaceNavigation?: Workspace; UserStories?: UserStory[]; + WorkspaceNavigation?: Workspace; } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run-collection.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run-collection.model.ts new file mode 100644 index 0000000..08cf751 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run-collection.model.ts @@ -0,0 +1,15 @@ +import { User } from "oidc-client"; +import { TestRun } from "./test-run.model"; + +export interface TestRunCollection { + Id?: number; + TimeStamp?: string; + WasPassed?: boolean; + CreatedBy?: number | null; + CreatedOn?: string | null; + ModifiedBy?: number | null; + ModifiedOn?: string | null; + CreatedByNavigation?: User; + ModifiedByNavigation?: User; + TestRuns?: TestRun[]; +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run.model.ts new file mode 100644 index 0000000..91a4572 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/test-run.model.ts @@ -0,0 +1,23 @@ +import { User } from "oidc-client"; +import { UnitTest } from "./unit-test.model"; +import { TestRunCollection } from "./test-run-collection.model"; + +export interface TestRun { + Id?: number; + TimeStamp?: string; + ExecutedSuccessfully?: boolean; + JsonResponse?: string; + WasPassed?: boolean; + Result?: string; + ExpectedResult?: string; + UnitTest?: number; + TestRunCollection?: number; + CreatedBy?: number | null; + CreatedOn?: string | null; + ModifiedBy?: number | null; + ModifiedOn?: string | null; + CreatedByNavigation?: User; + ModifiedByNavigation?: User; + UnitTestNavigation?: UnitTest; + TestRunCollectionNavigation?: TestRunCollection; +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/unit-test.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/unit-test.model.ts new file mode 100644 index 0000000..9a108f3 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/unit-test.model.ts @@ -0,0 +1,24 @@ +import { User } from "oidc-client"; +import { TestRun } from "./test-run.model"; +import { UserStory } from "./user-story.model"; + +export interface UnitTest { + Id?: number; + UniqueIdentifier?: string; + Name?: string; + ExpectedResult?: string; + UserStory?: number; + DAX?: string; + ResultType?: string; + DateTimeFormat?: string; + DecimalPlaces?: string; + FloatSeparators?: string; + CreatedBy?: number | null; + CreatedOn?: string | null; + ModifiedBy?: number | null; + ModifiedOn?: string | null; + CreatedByNavigation?: User; + ModifiedByNavigation?: User; + TestRuns?: TestRun[]; + UserStoryNavigation?: UserStory; +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/user-story.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/user-story.model.ts new file mode 100644 index 0000000..bbb915b --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/user-story.model.ts @@ -0,0 +1,18 @@ +import { User } from "oidc-client"; +import { UnitTest } from "./unit-test.model"; +import { TabularModel } from "./tabular-model.model"; + +export interface UserStory { + Id?: number; + UniqueIdentifier?: string; + Name?: string; + TabularModel?: number; + CreatedBy?: number | null; + CreatedOn?: string | null; + ModifiedBy?: number | null; + ModifiedOn?: string | null; + CreatedByNavigation?: User; + ModifiedByNavigation?: User; + UnitTests?: UnitTest[]; + TabularModelNavigation?: TabularModel; +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts index fac3f7c..63bddfe 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/models/workspace.model.ts @@ -1,11 +1,12 @@ -import { TabularModel } from "./TabularModel.model"; +import { TabularModel } from "./tabular-model.model"; +import { Tenant } from "./tenant.model"; -export interface Workspace{ - - Name?: string; +export interface Workspace { Id?: number; - WorkspacePbId?: string; - + Name?: string; + MsId?: string; + UniqueIdentifier?: string; + Tenant?: number | null; + TenantNavigation?: Tenant; TabularModels?: TabularModel[]; - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/pipes/get-first-element.pipe.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/pipes/get-first-element.pipe.ts new file mode 100644 index 0000000..9ca706e --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/pipes/get-first-element.pipe.ts @@ -0,0 +1,13 @@ +import { Pipe, PipeTransform } from '@angular/core'; +import { LogService } from '../services/log.service'; + +@Pipe({ + name: 'getFirstElement' +}) +export class GetFirstElementPipe implements PipeTransform { + constructor(private logService: LogService) {} + + transform(array: any[]): any { + return array?.length > 0 ? array[0] : null; + } +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UnitTest.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UnitTest.service.ts deleted file mode 100644 index 683a6bb..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UnitTest.service.ts +++ /dev/null @@ -1,110 +0,0 @@ -import { HttpClient } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import ODataStore from "devextreme/data/odata/store"; -import { AppConfig } from "../config/app.config"; -import { ODataService } from "./odata.service"; -import { UserService } from "./user.service"; -import { LayoutService } from "./layout.service"; -import { UnitTest } from "src/app/shared/models/UnitTest.model"; -import ODataContext from "devextreme/data/odata/context"; -import { map } from "rxjs/operators"; -import { Structur } from "../models/Structur.model"; -import {OdataStringResponse} from "../models/odatastringresponse"; -import notify from "devextreme/ui/notify"; -import { UnitTestExecutionResult } from "../models/UnitTestExecutionResult"; - -@Injectable() -export class UnitTestService { - respons: boolean; - wasUnitTestSuccessful: boolean = false; - constructor( - private odataService: ODataService, - //private UnitTestService: UnitTestService, - private http: HttpClient, - - - ) { } - - getStore(): ODataStore { - return this.odataService.context["UnitTests"]; - } - //executeUnitTest(unitTestToExecute: UnitTest) { - - //var urlToCall = AppConfig.settings.api.url + "/UnitTests/Execute"; - - // this.http.post(urlToCall, unitTestToExecute) - // .subscribe( - // result => { - // console.log(result); - //},error => {console.log(error)} - //) - - //} - -// Structur / UnitTest - executeUnitTest(unitTestToExecute: Structur): Promise{ - return new Promise((resolve)=> { - - let request = this.http - .post(`${AppConfig.settings.api.url}/UnitTests/Execute`, unitTestToExecute) - .subscribe( - response => { - - resolve(); - if(response.unitTestExecuted == true){ - - if(response.unitTestSucceeded == true){ - /* e.rowElement.style.backgroundcolor = "green";*/ - //notify("UnitTest: " + unitTestToExecute.Name + " war erfolgreich!" + " Erwartetes Ergebnis: " + unitTestToExecute.ExpectedResult + " Letztes Ergebnis: " + unitTestToExecute.LastResult, "success", 6000); - this.wasUnitTestSuccessful = true; - } - else{ - /*e.rowElement.style.backgroundcolor = "red"; - return response.unitTestSucceeded*/ - //notify("UnitTest: " + unitTestToExecute.Name + " nicht bestanden!" + " Erwartetes Ergebnis: " + unitTestToExecute.ExpectedResult + " Letztes Ergebnis: " + unitTestToExecute.LastResult, "info", 6000); - } - } - else{ - notify("UnitTest: " + unitTestToExecute.Name + " konnte nicht ausgeführt werden", "error", 3000); - } - - }, - error => { - notify(error.message, "error", 3000); - } - - ); - - }); - - //return this.odataService.context["UnitTests/Execute"]; - } - - LoadWorkspace(){ - let request = this.http - .post(`${AppConfig.settings.api.url}/UnitTests/LoadWorkspace`, null) - .subscribe(() => {console.log("OK")}); - } - - LoadDataset(){ - let request = this.http - .post(`${AppConfig.settings.api.url}/UnitTests/LoadDataset`, null) - .subscribe(() => {console.log("OK")}); - } - - SaveTestRun(result : string, type : string, count : number, Name : String){ - let body = { - result : result, - type : type, - count : count - } - - let request = this.http - .post(`${AppConfig.settings.api.url}/UnitTests/SaveTestRun`, { - Result : result, Type : type, Count : count, Name: Name, - }) - .subscribe(() => {console.log("OK")}); - } - - -} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/crud-base.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/crud-base.service.ts new file mode 100644 index 0000000..1901b3f --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/crud-base.service.ts @@ -0,0 +1,20 @@ +import { HttpClient } from "@angular/common/http"; +import ODataStore from "devextreme/data/odata/store"; +import { ODataService } from "./odata.service"; + + +export abstract class CrudBaseService { + abstract getStore(): ODataStore; + + public add (newRecord: Model): Promise { + return this.getStore().insert(newRecord); + } + + public remove (id: number): Promise { + return this.getStore().remove(id); + } + + public update (id: number, changes: Model): Promise { + return this.getStore().update(id, changes); + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/history.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/history.service.ts deleted file mode 100644 index fff6b3b..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/history.service.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { HttpClient } from "@angular/common/http"; -import { Injectable } from "@angular/core"; -import ODataStore from "devextreme/data/odata/store"; -import { AppConfig } from "../config/app.config"; -import { ODataService } from "./odata.service"; -import { UserService } from "./user.service"; -import { LayoutService } from "./layout.service"; -import { UnitTest } from "src/app/shared/models/UnitTest.model"; -import ODataContext from "devextreme/data/odata/context"; -import { map } from "rxjs/operators"; -import { History } from "../models/History.model"; -@Injectable() -export class HistoryService { - - constructor( - private odataService: ODataService, - //private UserStoryService: UserStoryService, - private http: HttpClient, - - ) { } - - getStore(): ODataStore { - return this.odataService.context["History"]; - } - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts index 4aed051..46ed04e 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/odata.service.ts @@ -10,7 +10,6 @@ export class ODataService { context: ODataContext; constructor(private router: Router, private logService: LogService) { this.context = new ODataContext({ - beforeSend: (e) => {}, url: AppConfig.settings.api.url, version: 4, errorHandler: (error) => { @@ -44,7 +43,10 @@ export class ODataService { key: "Id", keyType: "Int32", }, - + ResultTypes: { + key: "Id", + keyType: "Int32", + } }, }); } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/structur.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/structur.service.ts deleted file mode 100644 index 0dc64c1..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/structur.service.ts +++ /dev/null @@ -1,319 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Test } from 'tslint'; -import { Structur } from '../models/Structur.model'; -import { UnitTest } from '../models/UnitTest.model'; -import { Workspace } from '../models/workspace.model'; -import ODataContext from "devextreme/data/odata/context"; -import { AppConfig } from '../config/app.config'; -import { HttpClient } from "@angular/common/http"; -import { ODataService } from './odata.service'; -import { TestRuns } from '../models/TestRuns.model'; -import { TestRunStructur } from '../models/TestRunStructur.model'; -import { TabularModelService } from './TabularModel.service'; -import { History } from '../models/History.model'; -import { UnitTestService } from './UnitTest.service'; -import HierarchicalCollectionWidget from 'devextreme/ui/hierarchical_collection/ui.hierarchical_collection_widget'; -import { TabularModel } from '../models/TabularModel.model'; -import { TabularModelStructure } from '../models/TabularModelStructure'; -var structures: Structur[]; - -@Injectable() -export class StructurService { - - constructor( - private odataService: ODataService, - //private UserStoryService: UserStoryService, - private http: HttpClient, - private UnitTestService: UnitTestService, - - - ) { } - - - LoadWorkspace() { - let request = this.http - .post(`${AppConfig.settings.api.url}/UnitTests/LW`, null) - .subscribe(() => { console.log("OK") }); - - } - - getWorkspaces2(): Promise { - return new Promise((resolve, reject) => { - let request = this.http - .post(`${AppConfig.settings.api.url}/Workspaces/FilterWorkspace`, null) - .subscribe( - response => { - resolve(response["value"]); - } - ); - - }); - - } - - getRuns(): Promise { - return new Promise((resolve, reject) => { - let request = this.http - .get(`${AppConfig.settings.api.url}/TestRuns?$expand=HistoriesRun($expand=UnitTestNavigation)`) - .subscribe( - response => { - resolve(response["value"]); - } - ); - - }); - - } - - getTabModels(): Promise { - return new Promise((resolve, reject) => { - let request = this.http - .get(`${AppConfig.settings.api.url}/TabularModels`) - .subscribe( - response => { - resolve(response["value"]); - } - ); - - }); - - } - - - GetTabModelStructure(Workspaces: Workspace[]): Promise{ - return new Promise((resolve, reject) => { - var TBstructures: TabularModelStructure[] = []; - - - this.getWorkspaces2().then((filter) => { - Workspaces.forEach(Workspace => { - if (filter.some(p => p.WorkspacePbId === Workspace.WorkspacePbId.valueOf())) { - - - - Workspace.TabularModels.forEach(TabularModel => { - var structureTabularModel: TabularModelStructure = { - Name: TabularModel.Name, - DatasetPbId: TabularModel.DatasetPbId, - Workspace: TabularModel.Workspace, - Id: TabularModel.Id, - - items: [], - - - }; - TBstructures.push(structureTabularModel); - }) - - - - - } - - }); - resolve(TBstructures); - }); - - - }); - } - - - - getStructure(Workspaces: Workspace[]): Promise { - return new Promise((resolve, reject) => { - var structures: Structur[] = []; - - this.getWorkspaces2().then((filter) => { - Workspaces.forEach(Workspace => { - if (filter.some(p => p.WorkspacePbId === Workspace.WorkspacePbId.valueOf())) { - - var structureWorkspace: Structur = { - Typ: "Workspace", - Name: Workspace.Name, - WorkspacePbId: Workspace.WorkspacePbId, - DatasetPbId: null, - ExpectedResult: "", - DAX: "", - Timestamp: null, - LastResult: "", - Id: Workspace.Id, - UserStory: null, - UserStoryNavigation: null, - items: [] - }; - - Workspace.TabularModels.forEach(TabularModel => { - var structureTabularModel: Structur = { - Typ: "TabularModel", - Name: TabularModel.Name, - WorkspacePbId: Workspace.WorkspacePbId, - DatasetPbId: TabularModel.DatasetPbId, - ExpectedResult: "", - DAX: "", - Timestamp: null, - LastResult: "", - Id: TabularModel.Id, - UserStory: null, - UserStoryNavigation: null, - items: [] - }; - - TabularModel.UserStories.forEach(UserStory => { - var structureUserStory: Structur = { - Typ: "UserStory", - Name: UserStory.Beschreibung, - WorkspacePbId: Workspace.WorkspacePbId, - DatasetPbId: TabularModel.DatasetPbId, - ExpectedResult: "", - DAX: "", - Timestamp: null, - LastResult: "", - Id: UserStory.Id, - UserStory: null, - UserStoryNavigation: null, - items: [] - }; - - UserStory.UnitTests.forEach(UnitTest => { - var structureUnitTest: Structur = { - Typ: "UnitTest", - Name: UnitTest.Name, - WorkspacePbId: Workspace.WorkspacePbId, - DatasetPbId: TabularModel.DatasetPbId, - ExpectedResult: UnitTest.ExpectedResult, - DAX: UnitTest.DAX, - Timestamp: UnitTest.Timestamp, - LastResult: UnitTest.LastResult, - Id: UnitTest.Id, - UserStory: UnitTest.UserStory, - UserStoryNavigation: UnitTest.UserStoryNavigation, - items: [] - }; - structureUserStory.items.push(structureUnitTest) - }) - structureTabularModel.items.push(structureUserStory) - }) - structureWorkspace.items.push(structureTabularModel); - }) - structures.push(structureWorkspace); - } - }); - resolve(structures); - }); - }); - } - - GetTestRunStructure(TestRuns: TestRuns[]): Promise{ - return new Promise((resolve, reject) => { - var TRstructures: TestRunStructur[] = []; - var TRname; - var HistoryName - var HistoryKey - - this.getRuns().then(() => { - TestRuns.forEach(TestRun => { - - if(TestRun.Workspace != null) - TRname = TestRun.Workspace; - - if(TestRun.TabularModel != null) - TRname = TestRun.TabularModel; - - if(TestRun.UserStory != null) - TRname = TestRun.UserStory; - - var structureTestRuns: TestRunStructur = { - Type: TestRun.Type, - TimeStamp: TestRun.TimeStamp, - Result: TestRun.Result, - Workspace: TestRun.Workspace, - TabularModel: TestRun.TabularModel, - UserStory: TestRun.UserStory, - Name: TRname, - items: [], - - - }; - - TestRun.HistoriesRun.forEach(History => { - - //HistoryKey = this.UnitTestService.getStore().keyOf(History['UnitTest']) - - /*this.UnitTestService.getStore().byKey(History.UnitTest).then((unitTest) => { - HistoryName = unitTest.Name; - })*/ - //HistoryName = History.UnitTest.Name; - - var StructureHitory: TestRunStructur ={ - TimeStamp: History.TimeStamp, - Result: History.Result, - Name: History.UnitTestNavigation.Name, - Type: "/", - items: [], - Workspace: "", - TabularModel: "", - UserStory:"" - } - structureTestRuns.items.push(StructureHitory) - }) - TRstructures.push(structureTestRuns); - - }); - resolve(TRstructures); - }); - - - }); - } - - GetTestRunStructureForWorkspace(workspaceName: string): Promise { - return new Promise((resolve, reject) => { - var TRstructures: TestRunStructur[] = []; - var TRname; - var HistoryName; - var HistoryKey; - - this.getRuns().then((TestRuns) => { - const filteredTestRuns = TestRuns.filter((TestRun) => { - // Hier kannst du die Bedingung anpassen, um nach einem bestimmten Workspace zu filtern. - return TestRun.Workspace === workspaceName || TestRun.TabularModel === workspaceName || TestRun.UserStory === workspaceName; - }); - - filteredTestRuns.forEach((TestRun) => { - if (TestRun.Workspace != null) TRname = TestRun.Workspace; - if (TestRun.TabularModel != null) TRname = TestRun.TabularModel; - if (TestRun.UserStory != null) TRname = TestRun.UserStory; - - var structureTestRuns: TestRunStructur = { - Type: TestRun.Type, - TimeStamp: TestRun.TimeStamp, - Result: TestRun.Result, - Workspace: TestRun.Workspace, - TabularModel: TestRun.TabularModel, - UserStory: TestRun.UserStory, - Name: TRname, - items: [], - }; - - TestRun.HistoriesRun.forEach((History) => { - var StructureHistory: TestRunStructur = { - TimeStamp: History.TimeStamp, - Result: History.Result, - Name: History.UnitTestNavigation.Name, - Type: "/", - items: [], - Workspace: "", - TabularModel: "", - UserStory: "", - }; - structureTestRuns.items.push(StructureHistory); - }); - TRstructures.push(structureTestRuns); - }); - resolve(TRstructures); - }); - }); -} - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/TabularModel.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/tabular-model.service.ts similarity index 99% rename from at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/TabularModel.service.ts rename to at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/tabular-model.service.ts index 806ff03..0a7e6fe 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/TabularModel.service.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/tabular-model.service.ts @@ -15,5 +15,4 @@ export class TabularModelService { getStore(): ODataStore { return this.odataService.context["TabularModels"]; } - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/unit-test.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/unit-test.service.ts new file mode 100644 index 0000000..576e734 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/unit-test.service.ts @@ -0,0 +1,37 @@ +import { HttpClient } from "@angular/common/http"; +import { Injectable } from "@angular/core"; +import ODataStore from "devextreme/data/odata/store"; +import { AppConfig } from "../config/app.config"; +import { ODataService } from "./odata.service"; +import { UserService } from "./user.service"; +import { LayoutService } from "./layout.service"; +import { UnitTest } from "src/app/shared/models/unit-test.model"; +import { CrudBaseService } from "src/app/shared/services/crud-base.service"; +import ODataContext from "devextreme/data/odata/context"; +import { map } from "rxjs/operators"; +import notify from "devextreme/ui/notify"; + +@Injectable() +export class UnitTestService extends CrudBaseService { + constructor( + private odataService: ODataService, + private http: HttpClient + ) { + super(); + } + + getStore(): ODataStore { + return this.odataService.context["UnitTests"]; + } + + public executeMultiple(ids: number[]): Promise { + return new Promise((resolve, reject) => { + let request = this.http + .post(`${AppConfig.settings.api.url}/UnitTests/Execute`, { unitTestIds: ids }) + .subscribe({ + next: () => resolve(), + error: (error: any) => reject(error?.error?.error) + }); + }); + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UserStory.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/user-story.service.ts similarity index 63% rename from at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UserStory.service.ts rename to at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/user-story.service.ts index 4978009..ee00c32 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/UserStory.service.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/user-story.service.ts @@ -5,36 +5,34 @@ import { AppConfig } from "../config/app.config"; import { ODataService } from "./odata.service"; import { UserService } from "./user.service"; import { LayoutService } from "./layout.service"; -import { UnitTest } from "src/app/shared/models/UnitTest.model"; +import { UnitTest } from "src/app/shared/models/unit-test.model"; import ODataContext from "devextreme/data/odata/context"; import { map } from "rxjs/operators"; -import { UserStory } from "../models/UserStory.model"; +import { UserStory } from "../models/user-story.model"; +import { CrudBaseService } from "./crud-base.service"; @Injectable() -export class UserStoryService { +export class UserStoryService extends CrudBaseService{ constructor( private odataService: ODataService, - //private UserStoryService: UserStoryService, private http: HttpClient, + ) { + super(); + } - ) { } - - getStore(): ODataStore { + public getStore(): ODataStore { return this.odataService.context["UserStories"]; } - public copyToOtherTabularModel(userStoryId: number, targetTabularModelId: number, targetWorkspaceId: number): Promise { + public copyToOtherTabularModel(userStoryId: number, targetTabularModelId: number): Promise { return new Promise((resolve, reject) => { let request = this.http - .post(`${AppConfig.settings.api.url}/UserStories(${userStoryId})/Copy2`, { - targetTabularModelId1: targetTabularModelId, - targetWorkspaceId1: targetWorkspaceId, - userStoryId1: userStoryId, - + .post(`${AppConfig.settings.api.url}/UserStories(${userStoryId})/Copy`, { + targetTabularModelId: targetTabularModelId }) .subscribe({ next: (data) => resolve(), - error: (error) => reject(error), + error: (error) => reject(error?.error?.error), }); }); } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts index f3f6995..412f335 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/app/shared/services/workspace.service.ts @@ -8,58 +8,27 @@ import { LayoutService } from "./layout.service"; import ODataContext from "devextreme/data/odata/context"; import { map } from "rxjs/operators"; import { Workspace } from "../models/workspace.model"; -import { UserStoryService } from "./UserStory.service"; +import { UserStoryService } from "./user-story.service"; @Injectable() export class WorkspaceService { - constructor( private odataService: ODataService, private userStoryService: UserStoryService, - private http: HttpClient, - - ) { } - - getStore(): ODataStore { - return this.odataService.context["Workspaces"] - } - getStore2(){ - let request = this.http - .post(`${AppConfig.settings.api.url}/Workspaces/FilterWorkspace`, null) - .subscribe( - response => { - return response; - }, - ); - } + private http: HttpClient + ) {} - getStore3(): ODataStore { - return this.odataService.context["Workspaces/FilterWorkspace"] + public getStore(): ODataStore { + return this.odataService.context["Workspaces"]; } - getWorkspaces(): Promise { - return new Promise((resolve, reject)=>{ - this.getStore().load({expand: ["TabularModels.UserStories.UnitTests"]}).then((data)=>{ - resolve(data as Workspace[]); - }).catch((error)=>{ - reject(error); - }) - }); - - } - - getWorkspaces2(): Promise { - return new Promise((resolve, reject)=>{ + public pullWorkspaces(): Promise { + return new Promise((resolve, reject) => { let request = this.http - .post(`${AppConfig.settings.api.url}/Workspaces/FilterWorkspace`, null) - .subscribe( - response => { - resolve(response["value"]); - }, - ); + .post(`${AppConfig.settings.api.url}/Workspaces/Pull`, {}) + .subscribe({ + next: () => resolve(), + error: () => reject () + }); }); - } - - - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html index 17c6baa..08d65a3 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/ClientApp/src/index.html @@ -2,7 +2,7 @@ - Power BI Uni Test Portal - applied technologies GmbH + Power BI Unit Test Portal - applied technologies GmbH diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs index 8ca5684..8268582 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/BaseController.cs @@ -18,14 +18,15 @@ public abstract class BaseController : ODataController protected Guid msIdTenantCurrentUser; protected Guid msIdCurrentUser; - protected IHttpContextAccessor HttpContextAccessor; + protected IHttpContextAccessor httpContextAccessor; - public BaseController(PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor) + public BaseController(PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) { dbContext = portalDbContext; this.downstreamWebApi = downstreamWebApi; - this.HttpContextAccessor = httpContextAccessor; + this.httpContextAccessor = httpContextAccessor; + this.logger = logger; this.msIdTenantCurrentUser = Guid.Parse(httpContextAccessor.HttpContext.User.FindFirst(ClaimConstants.TenantId).Value); this.msIdCurrentUser = Guid.Parse(httpContextAccessor.HttpContext.User.FindFirst(ClaimConstants.ObjectId).Value); this.dbContext.MsIdCurrentUser = this.msIdCurrentUser; diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/HistoriesController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/HistoriesController.cs deleted file mode 100644 index 1883b4e..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/HistoriesController.cs +++ /dev/null @@ -1,41 +0,0 @@ -using at.PowerBIUnitTest.Portal.Data.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.OData; -using Microsoft.AspNetCore.OData.Query; -using Microsoft.AspNetCore.OData.Extensions; -using Microsoft.Identity.Web; -using System.Linq; -using Microsoft.Extensions.Logging; -using System; -using Microsoft.AspNetCore.OData.Routing; -using System.Threading.Tasks; -using Microsoft.Extensions.Configuration; -using Microsoft.AspNetCore.OData.Formatter; -using Microsoft.AspNet.OData.Routing; -using Newtonsoft.Json; - -namespace at.PowerBIUnitTest.Portal.Controllers -{ - - public class HistoriesController : BaseController - - { - private readonly IConfiguration configuration; - private readonly ILogger logger; - - public HistoriesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) - { - this.configuration = configuration; - this.logger = logger; - } - [EnableQuery] - public IQueryable Get() - { - logger.LogDebug($"Begin & End: HistoriesController Get()"); - return base.dbContext.Histories; - } - } - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs index ca7fb53..260bd1f 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TabularModelsController.cs @@ -19,35 +19,24 @@ namespace at.PowerBIUnitTest.Portal.Controllers { - public class TabularModelsController : BaseController { - private readonly IConfiguration configuration; - private readonly ILogger logger; - public TabularModelsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + public TabularModelsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) { - this.configuration = configuration; - this.logger = logger; } - - [EnableQuery(MaxExpansionDepth = 4)] - [AllowAnonymous] - public IQueryable Get() + [EnableQuery] + public IQueryable Get([FromODataUri] int key) { - try - { - logger.LogDebug($"Begin & End: TabularModelsController Get()"); - return base.dbContext.TabularModels; - } - catch(Exception ex) - { - logger.LogError(ex, "An error occured while performig GET(TabModel)"); - throw; - } - } + logger.LogDebug($"Begin & End: TabularModelsController Get(key: {key})"); + return base.dbContext.TabularModels.Where(e => e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); + } + [EnableQuery] + public IQueryable Get() + { + logger.LogDebug($"Begin & End: TabularModelsController Get()"); + return base.dbContext.TabularModels.Where(e => e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); + } } - - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs index 790877b..84bb495 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TenantsController.cs @@ -1,24 +1,27 @@ using at.PowerBIUnitTest.Portal.Data.Models; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.OData.Query; using Microsoft.Identity.Web; using System.Linq; using Microsoft.Extensions.Logging; using at.PowerBIUnitTest.Portal.Services; +using Microsoft.AspNet.OData; namespace at.PowerBIUnitTest.Portal.Controllers { - [Authorize] public class TenantsController : BaseController { - private readonly ILogger logger; - public TenantsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + public TenantsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) { - this.logger = logger; } - // GET: odata/Tenants + [EnableQuery] + public IQueryable Get([FromODataUri] int key) + { + logger.LogDebug($"Begin & End: TenantsController Get(key: {key})"); + return base.dbContext.Tenants.Where(e => e.MsId == this.msIdTenantCurrentUser && e.Id == key); + } + [EnableQuery] public IQueryable Get() { diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunCollectionsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunCollectionsController.cs new file mode 100644 index 0000000..7a34874 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunCollectionsController.cs @@ -0,0 +1,31 @@ +using System.Linq; +using at.PowerBIUnitTest.Portal.Data.Models; +using Microsoft.AspNet.OData; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; +using Microsoft.Identity.Web; + +namespace at.PowerBIUnitTest.Portal.Controllers +{ + public class TestRunCollectionsController : BaseController + { + public TestRunCollectionsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) + { + } + + [EnableQuery] + public IQueryable Get([FromODataUri] int key) + { + logger.LogDebug($"Begin & End: TestRunCollectionsController Get(key: {key})"); + return base.dbContext.TestRunCollections.Where(e => e.TestRuns.Count > 0 && e.TestRuns.First().UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); + } + + [EnableQuery] + public IQueryable Get() + { + logger.LogDebug($"Begin & End: TestRunCollectionsController Get()"); + return base.dbContext.TestRunCollections.Where(e => e.TestRuns.Count > 0 && e.TestRuns.First().UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs index a0afd5b..a1634a7 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/TestRunsController.cs @@ -1,29 +1,31 @@ -using at.PowerBIUnitTest.Portal.Data.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.OData.Query; -using Microsoft.Identity.Web; using System.Linq; +using at.PowerBIUnitTest.Portal.Data.Models; +using Microsoft.AspNet.OData; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; -using at.PowerBIUnitTest.Portal.Services; +using Microsoft.Identity.Web; namespace at.PowerBIUnitTest.Portal.Controllers { public class TestRunsController : BaseController { - private readonly ILogger logger; - public TestRunsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + public TestRunsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) + { + } + + [EnableQuery] + public IQueryable Get([FromODataUri] int key) { - this.logger = logger; + logger.LogDebug($"Begin & End: TestRunsController Get(key: {key})"); + return base.dbContext.TestRuns.Where(e => e.UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); } - // GET: odata/TestRuns [EnableQuery] - [AllowAnonymous] - public IQueryable Get() + public IQueryable Get() { - logger.LogDebug($"Begin & End: TestRunssController Get()"); - return base.dbContext.TestRuns; + logger.LogDebug($"Begin & End: TestRunsController Get()"); + return base.dbContext.TestRuns.Where(e => e.UnitTestNavigation.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); } } -} +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs index 149ce93..12a39e3 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UnitTestsController.cs @@ -15,11 +15,13 @@ using Microsoft.AspNetCore.OData.Formatter; using Microsoft.AspNet.OData.Routing; using Newtonsoft.Json; -using at.PowerBIUnitTest.Portal.Services; using Microsoft.AspNetCore.OData.Deltas; using Microsoft.AspNetCore.Routing; using System.Collections.Generic; using Newtonsoft.Json.Linq; +using Microsoft.EntityFrameworkCore; +using Microsoft.OData; +using at.PowerBIUnitTest.Portal.Services; namespace at.PowerBIUnitTest.Portal.Controllers { @@ -27,514 +29,111 @@ namespace at.PowerBIUnitTest.Portal.Controllers [Authorize] public class UnitTestsController : BaseController { - private readonly IConfiguration configuration; - private IHttpContextAccessor _httpContextAccessor; - private readonly ILogger logger; - private static List HistoriesForTestRun = new List(); - public UnitTestsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + public UnitTestsController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) { - this.configuration = configuration; - _httpContextAccessor = httpContextAccessor; - this.logger = logger; + } - // GET: odata/UnitTests - [EnableQuery] - public IQueryable Get() + [EnableQuery(MaxExpansionDepth = 4)] + public IQueryable Get([FromODataUri] int key) { - try - { - logger.LogDebug($"Begin & End: UnitTestsController Get()"); - return base.dbContext.UnitTests; - } - catch (Exception ex) - { - logger.LogError(ex, "An error occured while performing GET"); - throw; - } + logger.LogDebug($"Begin & End: UnitTestsController Get(key: {key})"); + return base.dbContext.UnitTests.Where(e => e.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); } - // Add odata/UnitTests - [HttpPost] - public UnitTest Post([FromBody] UnitTest unitTest) + [EnableQuery(MaxExpansionDepth = 4)] + public IQueryable Get() { - try - { - logger.LogDebug($"Begin & End: UnitTestsController Post()"); - var newUnitTest = base.dbContext.Add(unitTest); - base.dbContext.SaveChanges(); - - return newUnitTest.Entity; - } - catch (Exception ex) - { - logger.LogError(ex, "An error occured while performing POST"); - throw; - - } + logger.LogDebug($"Begin & End: UnitTestsController Get()"); + return base.dbContext.UnitTests.Where(e => e.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); } - [AllowAnonymous] [HttpPost] - public async Task SaveTestRun(ODataActionParameters parmeters) + public async Task Post([FromBody] UnitTest unitTest) { - var newTestRun = new TestRuns(); - newTestRun.Count = Convert.ToInt32(parmeters["Count"]); - newTestRun.Result = parmeters["Result"].ToString(); - newTestRun.TimeStamp = DateTime.Now.ToString(); - - - if(parmeters["Type"].ToString() == "Workspace") - { - newTestRun.Type = parmeters["Type"].ToString(); - newTestRun.Workspace = parmeters["Name"].ToString(); - } - if(parmeters["Type"].ToString() == "TabularModel") - { - newTestRun.Type = parmeters["Type"].ToString(); - newTestRun.TabularModel = parmeters["Name"].ToString(); - } - if(parmeters["Type"].ToString() == "UserStory") - { - newTestRun.Type = parmeters["Type"].ToString(); - newTestRun.UserStory = parmeters["Name"].ToString(); - } + logger.LogDebug($"Begin: UnitTestsController Post(unitTest Name: {unitTest.Name})"); - base.dbContext.Add(newTestRun); - base.dbContext.SaveChanges(); - //var Zähler = base.dbContext.Histories.Where(p => p.TimeStamp == newTestRun.TimeStamp).Count(); - /*for(int i = 0; i <= Zähler; i++) + if (!ModelState.IsValid) { - var newHistory = new History(); - newHistory = base.dbContext.Histories.Where(p => p.TimeStamp == newTestRun.TimeStamp).Where(p => p.TestRun == null).FirstOrDefault(); - newHistory.TestRun = newTestRun.Id; - base.dbContext.Update(newHistory); - base.dbContext.SaveChanges(); - }*/ - - foreach(var History in HistoriesForTestRun) - { - var newHistory = new History(); - newHistory = base.dbContext.Histories.Where(p => p.Id == History.Id).FirstOrDefault(); - newHistory.TestRun = newTestRun.Id; - base.dbContext.Update(newHistory); - base.dbContext.SaveChanges(); - + return BadRequest(ModelState); } - HistoriesForTestRun.Clear(); - if(base.dbContext.TestRuns.Where(P => P.Id == newTestRun.Id).FirstOrDefault().HistoriesRun.All(p => p.Result == "True")) - { - newTestRun.Result = "True"; - } - else - newTestRun.Result = "False"; - base.dbContext.Update(newTestRun); - base.dbContext.SaveChanges(); - return Ok(); - - } + if ((await this.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == unitTest.UserStory && e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null) + return Forbid(); - // DELETE: odata/UnitTestsbase - [HttpDelete] - public async Task Delete([FromODataUri] int key) - { - try - { - logger.LogDebug($"Begin: UnitTestsController Delete()"); - var unitTest = await dbContext.UnitTests.FindAsync(key); + if (base.dbContext.UnitTests.Any(e => e.Name == unitTest.Name && e.UserStory == unitTest.UserStory)) + return BadRequest(new ODataError { ErrorCode = "400", Message = "Unit test with the same name already exists in the user story." }); - if (unitTest == null) - { - return NotFound(); - } + this.dbContext.UnitTests.Add(unitTest); + await this.dbContext.SaveChangesAsync(); - base.dbContext.Remove(unitTest); - base.dbContext.SaveChanges(); + logger.LogDebug($"End: UnitTestsController Post(unitTest Name: {unitTest.Name})"); - logger.LogDebug($"End: UnitTestsController Delete()"); - return Ok(); - } - catch (Exception ex) - { - logger.LogError(ex, "An error occured while performing DELETE"); - throw; - } + return Created(unitTest); } - //???? - public async Task Patch([FromODataUri] int key, Delta unitTest) - { - try - { - logger.LogDebug($"Begin: UnitTestsController Patch()"); - var unitTestToChange = await base.dbContext.UnitTests.FindAsync(key); - - if (unitTestToChange == null) - { - return NotFound(); - } - - unitTest.Patch(unitTestToChange); - base.dbContext.SaveChanges(); - - logger.LogDebug($"End: UnitTestsController Patch()"); - return Updated(unitTestToChange); - } - catch (Exception ex) - { - logger.LogError(ex, "An error occured while performing PATCH"); - throw; - } - } - - - //[ODataRoute("Execute")] - // public bool bxecute([FromBody] UnitTest unitTestToExecute) - // { - // if (!ModelState.IsValid) - // { - // var test = "model ungültig"; - // } - // var testResult = false; - // dbContext.Add(unitTestToExecute); - // //await dbContext.SaveChangesAsync(); - // //return Created(unitTestToExecute); - - - // Console.WriteLine($"Unittest {unitTestToExecute.Name} wird hier demnöchst ausgeführt."); - - // return testResult; - // } - - [AllowAnonymous] - [HttpPost] - public UnitTestExecutionResult Execute([FromBody] object unitTestObject, [FromServices] PowerBiService powerBiService) + [HttpDelete] + public async Task Delete([FromODataUri] int key) { - logger.LogDebug($"Begin: UnitTestController Execute()"); - try - { - logger.LogDebug("Executing UnitTest....."); - var unitTestExecutionResult = new UnitTestExecutionResult(); - - var structur = JsonConvert.DeserializeObject(unitTestObject.ToString()); - - var unitTestUpdate = JsonConvert.DeserializeObject(unitTestObject.ToString()); - - Console.WriteLine($"Unit Test {structur.Name} wird ausgeführt"); - - var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); - string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result; - Guid datasetId = new Guid(structur.DatasetPbId);//new Guid("1272907a-888e-446f-b89e-037cfaf3f8b5"); - //DatasetId Variable - History HistoryAdd = new History(); - - string jsonResponse; - if (powerBiService.QueryDataset(datasetId, structur.DAX, authToken, out jsonResponse)) - { - - - unitTestExecutionResult.UnitTestExecuted = true; - - dynamic TestRersultArray = JsonConvert.DeserializeObject(jsonResponse); - var TestResult = ((TestRersultArray.results[0].tables[0].rows[0] as JObject).First as JProperty).Value.ToString(); - - logger.LogDebug($"TestResult: {TestResult}"); - - - if (double.TryParse(TestResult, out double testResultDouble)) - { - TestResult = Math.Round(testResultDouble, 4).ToString(); - logger.LogDebug($"rounded TestResult: {TestResult}"); - } - - if (TestResult == structur.ExpectedResult) - { - unitTestExecutionResult.UnitTestSucceeded = true; - } - - else - { - unitTestExecutionResult.UnitTestSucceeded = false; - } - - logger.LogDebug($"unitTestExecutionResult: {unitTestExecutionResult}"); - - //unitTestUpdate.LastResult = TestResult; - UnitTest UnitTestNeu = base.dbContext.UnitTests.Where(p => p.Id == unitTestUpdate.Id).FirstOrDefault(); - UnitTestNeu.LastResult = TestResult; - - if(UnitTestNeu.ResultType == "Float") - { - float FloatResult; - FloatResult = float.Parse(TestResult); - //UnitTestNeu.LastResult = Math.Round(FloatResult, int.Parse(UnitTestNeu.DecimalPlaces)).ToString(); - + logger.LogDebug($"Begin: UnitTestsController Delete(key: {key}"); - float roundedValue = (float)Math.Round(FloatResult, int.Parse(UnitTestNeu.DecimalPlaces)); - float round = FloatResult - roundedValue; + var unitTest = await this.dbContext.UnitTests.FindAsync(key); - if (FloatResult - roundedValue >= 0.05) - { - roundedValue += (float)Math.Pow(0.1, int.Parse(UnitTestNeu.DecimalPlaces)); - } + if (unitTest == null) + return NotFound(); - UnitTestNeu.LastResult = roundedValue.ToString(); - UnitTestNeu.LastResult = Math.Round(roundedValue, int.Parse(UnitTestNeu.DecimalPlaces)).ToString(); + if (unitTest.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId != this.msIdTenantCurrentUser) + return Forbid(); + this.dbContext.UnitTests.Remove(unitTest); + await base.dbContext.SaveChangesAsync(); - if(UnitTestNeu.FloatSeparators == "Use Seperators") - { - //UnitTestNeu.LastResult.ToString("N"); - - double number = float.Parse(UnitTestNeu.LastResult); - UnitTestNeu.LastResult = number.ToString("N"); - } - } - - if(UnitTestNeu.ResultType == "Date") - { - DateTime DateResult; - if(UnitTestNeu.DateTimeFormat == "UTC") - { - DateResult = DateTime.Parse(TestResult).ToUniversalTime(); - UnitTestNeu.LastResult = DateResult.ToString(); - - - - } - - if(UnitTestNeu.DateTimeFormat == "CET") - { - DateResult = DateTime.Parse(TestResult).ToLocalTime(); - UnitTestNeu.LastResult = DateResult.ToString(); - } - - } - - if(UnitTestNeu.ResultType == "Percentage") - { - double number = float.Parse(TestResult); - UnitTestNeu.LastResult = number.ToString("#0.###%"); - - } - - - UnitTestNeu.Timestamp = DateTime.Now.ToString(); - - HistoryAdd.LastRun = UnitTestNeu.LastResult; - HistoryAdd.ExpectedRun = UnitTestNeu.ExpectedResult; - HistoryAdd.UnitTest = UnitTestNeu.Id; - HistoryAdd.Result = unitTestExecutionResult.UnitTestSucceeded.ToString(); - HistoryAdd.TimeStamp = UnitTestNeu.Timestamp; - HistoriesForTestRun.Add(HistoryAdd); - - - base.dbContext.Add(HistoryAdd); - base.dbContext.SaveChanges(); - - base.dbContext.Update(UnitTestNeu); - base.dbContext.SaveChanges(); - } - - //TODO - /* else if (powerBiService.QueryDataset(datasetId, structur.DAX, authToken, out jsonResponse)){ - unitTestExecutionResult.UnitTestExecuted = false; - Root2 TestValue; - TestValue = JsonConvert.DeserializeObject(jsonResponse); - - unitTestUpdate.LastResult = TestValue.results[0].tables[0].rows[0].ActualValue.ToString(); - UnitTest UnitTestNeu = new UnitTest(); - UnitTestNeu = base.dbContext.UnitTests.Where(p => p.Name == unitTestUpdate.Name).FirstOrDefault(); - UnitTestNeu.LastResult = unitTestUpdate.LastResult; - - DateTime Timestamp = new DateTime(); - Timestamp = DateTime.Now; - UnitTestNeu.Timestamp = Timestamp.ToString(); - - HistoryAdd.LastRun = UnitTestNeu.LastResult; - HistoryAdd.ExpectedRun = UnitTestNeu.ExpectedResult; - HistoryAdd.UnitTest = UnitTestNeu.Id; - HistoryAdd.TimeStamp = UnitTestNeu.Timestamp; - HistoryAdd.Result = "False"; - - base.dbContext.Add(HistoryAdd); - base.dbContext.SaveChanges(); - - - base.dbContext.Update(UnitTestNeu); - base.dbContext.SaveChanges(); - }*/ - - - - logger.LogDebug($"End: UnitTestController Execute(Return: {unitTestExecutionResult})"); - return unitTestExecutionResult; - } - catch (Exception ex) - { - logger.LogDebug(ex, "An error occured while Executing the UnitTest(Controller)"); - throw; - } + logger.LogDebug($"End: UnitTestsController Delete(key: {key}"); + return Ok(); } - [AllowAnonymous] - [HttpPost] - public async Task LoadWorkspace([FromServices] PowerBiService powerBiService, Root TestValue, Root3 TestDataset) + [HttpPatch] + public async Task Patch([FromODataUri] int key, Delta unitTest) { - try - { - logger.LogDebug($"Begin: UnitTestsController LoadWorkspaces()"); - logger.LogDebug("Sycing or Loading Workspaces"); - LW(powerBiService, out TestValue); - - int Zähler; - Zähler = TestValue.OdataCount; - for (int i = 0; i <= Zähler - 1; i++) - { - Workspace AddWorkspace = new Workspace(); - string Json2; - - - //using (var db = new PortalDbContext()) - - - var Test = TestValue.Values.ElementAt(i); - var TestWorkspace = base.dbContext.Workspaces.Where(p => p.WorkspacePbId == Test.id).FirstOrDefault(); - + logger.LogDebug($"Begin: UnitTestsController Patch(key: {key}, unitTest: {unitTest.GetChangedPropertyNames()}"); - if (TestWorkspace == null) - { - AddWorkspace.Name = TestValue.Values.ElementAt(i).name; - AddWorkspace.WorkspacePbId = TestValue.Values.ElementAt(i).id; + if ((await this.dbContext.UnitTests.FirstOrDefaultAsync(e => e.Id == key && e.UserStoryNavigation.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null) + return Forbid(); - base.dbContext.Add(AddWorkspace); - base.dbContext.SaveChanges(); - - } - - else if (TestWorkspace != null) - { - if (Test.name != TestWorkspace.Name) - { - TestWorkspace.Name = Test.name; - } - - base.dbContext.Update(TestWorkspace); - } - - LoadDataset(TestValue.Values.ElementAt(i).id, powerBiService, out TestDataset); - - int Zähler2; - Zähler2 = TestDataset.Values.Count - 1; - - if (Zähler2 >= 0) - { - for (int k = 0; k <= Zähler2; k++) - { - TabularModel AddTabModel = new TabularModel(); - - var DatasetTestId = TestDataset.Values.ElementAt(k).id; - var TestTabModel = base.dbContext.TabularModels.Where(p => p.DatasetPbId == DatasetTestId).FirstOrDefault(); - - if (TestTabModel == null) - { - AddWorkspace.WorkspacePbId = TestValue.Values.ElementAt(i).id; - AddTabModel.DatasetPbId = TestDataset.Values.ElementAt(k).id; - AddTabModel.Workspace = base.dbContext.Workspaces.Where(p => p.WorkspacePbId == AddWorkspace.WorkspacePbId).FirstOrDefault().Id; - AddTabModel.Name = TestDataset.Values.ElementAt(k).name; - - base.dbContext.Add(AddTabModel); - var test = base.dbContext.Workspaces.Where(e => e.Name == null); - base.dbContext.SaveChanges(); - } - - else if (TestTabModel != null) - { - AddWorkspace.WorkspacePbId = TestValue.Values.ElementAt(i).id; - if (TestDataset.Values.ElementAt(k).id != base.dbContext.TabularModels.Where(p => p.DatasetPbId == TestDataset.Values.ElementAt(k).id).FirstOrDefault().DatasetPbId) - { - TestTabModel.DatasetPbId = TestDataset.Values.ElementAt(k).id; - } - - //if(TestDataset.Values.ElementAt(k).name != base.dbContext.TabularModels.Where(p => p.Name == TestDataset.Values.ElementAt(k).name).FirstOrDefault().Name) - //TestTabModel.Name = TestDataset.Values.ElementAt(k).name; - - var tabularModel = base.dbContext.TabularModels.FirstOrDefault(p => p.Name == TestDataset.Values.ElementAt(k).name); - if (tabularModel != null && TestDataset.Values.ElementAt(k).name != null) - { - if (TestDataset.Values.ElementAt(k).name != tabularModel.Name) - { - TestTabModel.Name = TestDataset.Values.ElementAt(k).name; - } - } - else - { - - } - - - base.dbContext.Update(TestTabModel); - } - } - } - } - base.dbContext.SaveChanges(); - - logger.LogDebug($"End: UnitTestController LoadDataset()"); - - return Ok(); + if (!ModelState.IsValid) + { + return BadRequest(ModelState); } - catch (Exception ex) + var entity = await base.dbContext.UnitTests.FindAsync(key); + if (entity == null) { - logger.LogError(ex, "An error occured while Sycning or Loading Workspaces"); - throw; + return NotFound(); } - } - public Root3 LoadDataset(string DatasetPbId, [FromServices] PowerBiService powerBiService, out Root3 TestDataset) - { - logger.LogDebug($"Begin: UnitTestsController LoadDataset()"); - var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); - string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result; - string jsonResponse; + unitTest.Patch(entity); - if (powerBiService.LoadDataset(DatasetPbId, authToken, out jsonResponse)) - { - TestDataset = JsonConvert.DeserializeObject(jsonResponse); - } + if (base.dbContext.UnitTests.Any(e => e.Name == entity.Name && e.UserStory == entity.UserStory && e.Id != entity.Id)) + return BadRequest(new ODataError { ErrorCode = "400", Message = "Unit test with the same name already exists in the user story." }); - else - { - TestDataset = new Root3(); - } + await base.dbContext.SaveChangesAsync(); + + logger.LogDebug($"End: UnitTestsController Patch(key: {key}, unitTest: {unitTest.GetChangedPropertyNames()}"); - logger.LogDebug($"End: UnitTestsController LoadDataset()"); - return TestDataset; + return Updated(entity); } - public Root LW([FromServices] PowerBiService powerBiService, out Root TestValue) + [HttpPost] + public async Task Execute([FromBody] ODataActionParameters parmeters, [FromServices] UnitTestService unitTestService) { - logger.LogDebug($"Start: UnitTestsController LW()"); - - var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); - string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result; - string jsonResponse; - //Root TestValue; - - if (powerBiService.LoadWorkspace(authToken, out jsonResponse)) - { + logger.LogDebug($"Begin: UnitTestsController Execute()"); - TestValue = JsonConvert.DeserializeObject(jsonResponse); - } + var unitTestIds = parmeters["unitTestIds"] as IEnumerable; - else - { - TestValue = new Root(); - } + var accessToken = httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); + await unitTestService.ExecuteMultipe(msIdTenantCurrentUser, accessToken, unitTestIds); - logger.LogDebug($"End: UnitTestsController LW()"); - return TestValue; + logger.LogDebug($"End: UnitTestsController Execute()"); + return Ok(); } } } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs index 9913972..0232b0a 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UserStoriesController.cs @@ -18,6 +18,7 @@ using Microsoft.AspNetCore.OData.Deltas; using Microsoft.EntityFrameworkCore; using at.PowerBIUnitTest.Portal.Services; +using System.Collections.Generic; namespace at.PowerBIUnitTest.Portal.Controllers { @@ -25,163 +26,136 @@ namespace at.PowerBIUnitTest.Portal.Controllers [Authorize] public class UserStoriesController : BaseController { - private readonly IConfiguration configuration; - private readonly ILogger logger; - public UserStoriesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + public UserStoriesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) { - this.configuration = configuration; - this.logger = logger; } - + [EnableQuery] + public IQueryable Get([FromODataUri] int key) + { + logger.LogDebug($"Begin & End: UserStoriesController Get(key: {key})"); + return base.dbContext.UserStories.Where(e => e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); + } + [EnableQuery] public IQueryable Get() { logger.LogDebug($"Begin & End: UserStoriesController Get()"); - return base.dbContext.UserStories; + return base.dbContext.UserStories.Where(e => e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); } - // Add odata/UserStory [HttpPost] - public UserStory Post([FromBody] UserStory userStory) + public async Task Post([FromBody] UserStory userStory) { - try - { - logger.LogDebug($"Begin: UserStoriesController Post()"); - var newUserStory = base.dbContext.Add(userStory); - base.dbContext.SaveChanges(); - logger.LogDebug($"End: UserStoriesController Post()"); - return newUserStory.Entity; - } - catch(Exception ex) + logger.LogDebug($"Begin: UserStoriesController Post(unitTest Description: {userStory.Name})"); + + if (!ModelState.IsValid) { - logger.LogError(ex, "An error occured while adding a User Story"); - throw; + return BadRequest(ModelState); } - } - public async Task Patch([FromODataUri] int key, Delta userStory) - { - try - { - logger.LogDebug($"Begin: UnitTestsController Patch()"); - var userStoryToChange = await base.dbContext.UserStories.FindAsync(key); + if ((await this.dbContext.TabularModels.FirstOrDefaultAsync(e => e.Id == userStory.TabularModel && e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null) + return Forbid(); - if (userStoryToChange == null) - { - return NotFound(); - } + this.dbContext.UserStories.Add(userStory); + await this.dbContext.SaveChangesAsync(); - userStory.Patch(userStoryToChange); - base.dbContext.SaveChanges(); + logger.LogDebug($"End: UserStoriesController Post(unitTest Description: {userStory.Name})"); - logger.LogDebug($"End: UnitTestsController Patch()"); - return Updated(userStoryToChange); - } - catch (Exception ex) - { - logger.LogError(ex, "An error occured while performing PATCH"); - throw; - } + return Created(userStory); } - [HttpPost] - public async Task Copy ([FromODataUri] int key, ODataActionParameters parameters) + [HttpDelete] + public async Task Delete([FromODataUri] int key) { - logger.LogDebug($"Begin: UserStoriesController Copy(key: {key})"); - /* - var solution = await this.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == key && e.TabularModelNavigation.WorkspaceNavigation..DevelopmentEnvironmentNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); - if (solution == null) + logger.LogDebug($"Begin: UserStoriesController Delete(key: {key}"); + + var userStory = await this.dbContext.UserStories.FindAsync(key); + + if (userStory == null) + return NotFound(); + + if (userStory.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId != this.msIdTenantCurrentUser) return Forbid(); - if (solution.IsPatch()) - return BadRequest("Can't apply upgrade for patch solution"); + this.dbContext.UserStories.Remove(userStory); + await base.dbContext.SaveChangesAsync(); - int targetEnvironmentId = (int)parameters["targetEnvironmentId"]; - if (ImportExistsOnEnvironment(key, targetEnvironmentId) == false) - return BadRequest("Can't skip import before applying an upgrade"); + logger.LogDebug($"End: UserStoriesController Delete(key: {key}"); + return Ok(); + } - Data.Models.Action createdAction; + [HttpPatch] + public async Task Patch([FromODataUri] int key, Delta userStory) + { + logger.LogDebug($"Begin: UserStoriesController Patch(key: {key}, userStory: {userStory.GetChangedPropertyNames()}"); - try + if ((await this.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == key && e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser)) == null) + return Forbid(); + + if (!ModelState.IsValid) { - createdAction = await solutionService.AddApplyUpgradeAction(key, targetEnvironmentId, this.msIdCurrentUser); + return BadRequest(ModelState); } - catch (Exception e) + var entity = await base.dbContext.UserStories.FindAsync(key); + if (entity == null) { - return BadRequest(e.Message); + return NotFound(); } - logger.LogDebug($"End: SolutionsController ApplyUpgrade()"); - */ - - - return Ok(); - } -[HttpPost] -public async Task Copy2 ([FromODataUri] int key, ODataActionParameters parameters) -{ - try - { - int targetTabularModelId = (int)parameters["targetTabularModelId1"]; - int targetWorkspaceId = (int)parameters["targetWorkspaceId1"]; - int originalUserStoryId = (int)parameters["userStoryId1"]; + userStory.Patch(entity); + await base.dbContext.SaveChangesAsync(); - // 1. UserStory kopieren - var originalUserStory = await base.dbContext.UserStories - .Include(us => us.UnitTests) // Include, um die verknüpften UnitTests abzurufen - .FirstOrDefaultAsync(us => us.Id == originalUserStoryId); + logger.LogDebug($"End: UserStoriesController Patch(key: {key}, userStory: {userStory.GetChangedPropertyNames()}"); - if (originalUserStory == null) - { - return NotFound(); + return Updated(entity); } - var copiedUserStory = new UserStory + [HttpPost] + public async Task Copy([FromODataUri] int key, ODataActionParameters parameters) { - Beschreibung = originalUserStory.Beschreibung, - TabularModel = targetTabularModelId, - }; + logger.LogDebug($"Begin: UserStoriesController Copy(key: {key})"); - base.dbContext.UserStories.Add(copiedUserStory); - base.dbContext.SaveChanges(); + int targetTabularModelId = (int)parameters["targetTabularModelId"]; - // 2. UnitTests kopieren - foreach (var originalUnitTest in originalUserStory.UnitTests) - { - var copiedUnitTest = new UnitTest + var originalUserStory = await base.dbContext.UserStories.FirstOrDefaultAsync(e => e.Id == key && e.TabularModelNavigation.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); + var tabularModel = await base.dbContext.TabularModels.FirstOrDefaultAsync(e => e.Id == targetTabularModelId && e.WorkspaceNavigation.TenantNavigation.MsId == this.msIdTenantCurrentUser); + + if (originalUserStory == null || tabularModel == null) + { + return NotFound(); + } + + var copiedUserStory = new UserStory { - // Kopieren Sie alle erforderlichen Eigenschaften des UnitTests - // ... - - // Aktualisieren Sie die Beziehung zur kopierten UserStory - Name = originalUnitTest.Name, - DAX = originalUnitTest.DAX, - ExpectedResult = originalUnitTest.ExpectedResult, - ResultType = originalUnitTest.ResultType, - DateTimeFormat = originalUnitTest.DateTimeFormat, - DecimalPlaces = originalUnitTest.DecimalPlaces, - FloatSeparators = originalUnitTest.FloatSeparators, - Timestamp = originalUnitTest.Timestamp, - UserStory = copiedUserStory.Id, + Name = originalUserStory.Name, + TabularModel = targetTabularModelId, }; - dbContext.UnitTests.Add(copiedUnitTest); - } + var copiedUnitTests = new List(); - dbContext.SaveChanges(); + foreach (var originalUnitTest in originalUserStory.UnitTests) + { + var copiedUnitTest = new UnitTest + { + Name = originalUnitTest.Name, + DAX = originalUnitTest.DAX, + ExpectedResult = originalUnitTest.ExpectedResult, + ResultType = originalUnitTest.ResultType, + DateTimeFormat = originalUnitTest.DateTimeFormat, + DecimalPlaces = originalUnitTest.DecimalPlaces, + FloatSeparators = originalUnitTest.FloatSeparators, + }; + + copiedUnitTests.Add(copiedUnitTest); + } - logger.LogDebug($"End: UserStoriesController Copy()"); - return Ok(); - } - catch (Exception ex) - { - logger.LogError(ex, "An error occurred while copying UserStory"); - throw; - } -} + copiedUserStory.UnitTests = copiedUnitTests; + base.dbContext.UserStories.Add(copiedUserStory); + await dbContext.SaveChangesAsync(); + logger.LogDebug($"End: UserStoriesController Copy()"); + return Ok(); + } } - - } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs index 8b23959..0783692 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/UsersController.cs @@ -26,13 +26,15 @@ namespace at.PowerBIUnitTest.Portal.Controllers { public class UsersController : BaseController { + public UsersController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) + { + } - private readonly IConfiguration configuration; - private readonly ILogger logger; - public UsersController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + [EnableQuery] + public IQueryable Get([FromODataUri] int key) { - this.configuration = configuration; - this.logger = logger; + logger.LogDebug($"Begin & End: UsersController Get(key: {key})"); + return base.dbContext.Users.Where(e => e.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); } // GET: odata/Users @@ -64,6 +66,9 @@ public async Task Login([FromServices] IConfiguration configurati if (string.IsNullOrEmpty(currentUser.Firstname)) currentUser.Firstname = currentUser.Email; + if (string.IsNullOrEmpty(currentUser.Lastname)) + currentUser.Lastname = string.Empty; + Guid msIdTenantCurrentUser = Guid.Parse(this.HttpContext.User.FindFirst(ClaimConstants.TenantId).Value); //check if current user exists in database diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs index 87529cd..b8fa023 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Controllers/WorkspacesController.cs @@ -23,143 +23,35 @@ namespace at.PowerBIUnitTest.Portal.Controllers public class WorkspacesController : BaseController { - private readonly IConfiguration configuration; - - private IHttpContextAccessor _httpContextAccessor; - private readonly ILogger logger; - public WorkspacesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor) + public WorkspacesController(Data.Models.PortalDbContext portalDbContext, IDownstreamWebApi downstreamWebApi, IHttpContextAccessor httpContextAccessor, IConfiguration configuration, ILogger logger) : base(portalDbContext, downstreamWebApi, httpContextAccessor, logger) { - this.configuration = configuration; - _httpContextAccessor = httpContextAccessor; - this.logger = logger; } - [AllowAnonymous] - [HttpPost] [EnableQuery(MaxExpansionDepth = 4)] - public IQueryable FilterWorkspace([FromServices] PowerBiService powerBiService) + public IQueryable Get([FromODataUri] int key) { - logger.LogDebug($"Begin: WorkspaceController FilterWorkspace()"); - try - { - logger.LogDebug("Filtering Workspace...."); - var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); - string authToken = powerBiService.GetTokenOnBehalfOf(base.msIdTenantCurrentUser, accessToken).Result; - string jsonResponse; - Workspace[] abcd = new Workspace[0]; - //Root TestValue; - - if (powerBiService.LoadWorkspace(authToken, out jsonResponse)){ - Root TestValue = new Root(); - TestValue = JsonConvert.DeserializeObject(jsonResponse); - int Zähler; - Zähler = TestValue.OdataCount; - abcd = new Workspace[Zähler]; - - for (int i = 0; i <= Zähler - 1; i++){ - - Workspace Füller; - TabularModel[] FüllerTB; - - Füller = new Workspace(); - FüllerTB = new TabularModel[1]; - Root3 TestDataset = new Root3(); - - if(powerBiService.LoadDataset(TestValue.Values.ElementAt(i).id, authToken, out jsonResponse)){ - TestDataset = JsonConvert.DeserializeObject(jsonResponse); - int zähler2; - zähler2 = TestDataset.Values.Count(); - - FüllerTB = new TabularModel[zähler2]; - TabularModel FüllerTB2 = new TabularModel(); - for (int k = 0; k <= zähler2 - 1; k++){ - FüllerTB2.DatasetPbId = TestDataset.Values.ElementAt(k).id; - //FüllerTB2.Id = this.dbContext.TabularModels.Where(p => p.DatasetPbId == FüllerTB2.DatasetPbId).FirstOrDefault().Id; - - FüllerTB[k] = FüllerTB2; - } - } - - Füller.WorkspacePbId = TestValue.Values.ElementAt(i).id; - Füller.Name = TestValue.Values.ElementAt(i).name; - // Füller.Id = TestValue.Values.ElementAt(i).id; - Füller.TabularModels = FüllerTB; - abcd[i] = Füller; - } - - IQueryable qtest = abcd.AsQueryable(); - - return qtest; - } - - Workspace[] dings = new Workspace[1]; - - - - var workspaces = dings.AsQueryable(); - logger.LogDebug($"End: WorkspaceController FilterWorkspace(Return: {workspaces})"); - return workspaces; - - - } - catch(Exception ex) - { - logger.LogError(ex, "An error occured while performing FilterWorkspace"); - throw; - } + logger.LogDebug($"Begin & End: WorkspacesController Get(key: {key})"); + return base.dbContext.Workspaces.Where(e => e.TenantNavigation.MsId == this.msIdTenantCurrentUser && e.Id == key); } - [EnableQuery(MaxExpansionDepth = 4)] - public IQueryable Get([FromServices] PowerBiService powerBiService){ - /*var accessToken = _httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); - string authToken = powerBiService.GetTokenOnBehalfOf(accessToken).Result; - string jsonResponse; - - if(powerBiService.LoadWorkspace(authToken, out jsonResponse)) - { - Root TestValue = new Root(); - TestValue = JsonConvert.DeserializeObject(jsonResponse); - int Zähler2; - Zähler2 = TestValue.OdataCount; - - - Workspace[] Filter = new Workspace[Zähler2]; - //FilterWorkspace(powerBiService, out Filter); - string[] TestFilter = new string[0]; - - - return base.dbContext.Workspaces;*/ + public IQueryable Get() + { logger.LogDebug($"Begin & End: WorkspacesController Get()"); - - return base.dbContext.Workspaces; - + return base.dbContext.Workspaces.Where(e => e.TenantNavigation.MsId == this.msIdTenantCurrentUser); } - [HttpDelete] - public async Task Delete([FromODataUri] int key) - { - try - { - logger.LogDebug($"Begin: UnitTestsController Delete()"); - var workspace = await dbContext.Workspaces.FindAsync(key); - - if (workspace == null) - { - return NotFound(); - } + [HttpPost] + public async Task Pull([FromServices] WorkspaceService workspaceService, [FromServices] TabularModelService tabularModelService) + { + logger.LogDebug($"Begin: WorkspacesController Pull()"); - base.dbContext.Remove(workspace); - base.dbContext.SaveChanges(); + var accessToken = httpContextAccessor.HttpContext.Request.Headers["Authorization"].ToString().Replace("Bearer ", ""); + await workspaceService.PullWorkspacesFromPowerBi(msIdTenantCurrentUser, accessToken); + await tabularModelService.PullDatasetsFromPowerBi(msIdTenantCurrentUser, accessToken); - logger.LogDebug($"End: UnitTestsController Delete()"); - return Ok(); - } - catch (Exception ex) - { - logger.LogError(ex, "An error occured while performing DELETE"); - throw; - } + logger.LogDebug($"End: WorkspacesController Pull()"); + return Ok(); } } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.Designer.cs new file mode 100644 index 0000000..71c802d --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.Designer.cs @@ -0,0 +1,602 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240411151522_RemakeModel")] + partial class RemakeModel + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedRun") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("LastRun") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("LastRun"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.Property("TestRun") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRun"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DatasetPbId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Beschreibung") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Description"); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TenantNavigationId") + .HasColumnType("int"); + + b.Property("WorkspacePbId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.HasKey("Id"); + + b.HasIndex("TenantNavigationId"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", "TestRunCollectionNavigation") + .WithMany("TestRunsDummy") + .HasForeignKey("TestRun"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType") + .IsRequired(); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("TenantNavigationId"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + { + b.Navigation("TestRunsDummy"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.cs new file mode 100644 index 0000000..c7ad638 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151522_RemakeModel.cs @@ -0,0 +1,1209 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_UnitTest_ResultType_ResultType", + table: "UnitTest"); + + migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 1 WHERE ResultType = 'Date'"); + migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 2 WHERE ResultType = 'Float'"); + migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 3 WHERE ResultType = 'Percentage'"); + migrationBuilder.Sql("UPDATE UnitTest SET ResultType = 4 WHERE ResultType = 'String'"); + + migrationBuilder.DropForeignKey( + name: "FK_History_TestRuns_TestRun", + table: "History"); + + migrationBuilder.DropForeignKey( + name: "FK_History_UnitTest_UnitTest", + table: "History"); + + migrationBuilder.DropPrimaryKey( + name: "PK_ResultType", + table: "ResultType"); + + migrationBuilder.DropPrimaryKey( + name: "PK_TestRuns", + table: "TestRuns"); + + migrationBuilder.DropPrimaryKey( + name: "PK_History", + table: "History"); + + migrationBuilder.Sql("TRUNCATE TABLE History"); + migrationBuilder.Sql("TRUNCATE TABLE TestRuns"); + + migrationBuilder.DeleteData( + table: "ResultType", + keyColumn: "Name", + keyValue: "Date"); + + migrationBuilder.DeleteData( + table: "ResultType", + keyColumn: "Name", + keyValue: "Float"); + + migrationBuilder.DeleteData( + table: "ResultType", + keyColumn: "Name", + keyValue: "Percentage"); + + migrationBuilder.DeleteData( + table: "ResultType", + keyColumn: "Name", + keyValue: "String"); + + migrationBuilder.DropColumn( + name: "LastResult", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "LastRun", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "Count", + table: "TestRuns"); + + migrationBuilder.DropColumn( + name: "TabularModel", + table: "TestRuns"); + + migrationBuilder.DropColumn( + name: "Type", + table: "TestRuns"); + + migrationBuilder.DropColumn( + name: "UserStory", + table: "TestRuns"); + + migrationBuilder.DropColumn( + name: "Workspace", + table: "TestRuns"); + + migrationBuilder.RenameTable( + name: "TestRuns", + newName: "TestRunCollection"); + + migrationBuilder.RenameTable( + name: "History", + newName: "TestRun"); + + migrationBuilder.RenameColumn( + name: "WorkspacePbId", + table: "Workspace", + newName: "Ms Id"); + + migrationBuilder.RenameColumn( + name: "Beschreibung", + table: "UserStory", + newName: "Description"); + + migrationBuilder.RenameColumn( + name: "ExpectedResult", + table: "UnitTest", + newName: "Expected Result"); + + migrationBuilder.RenameColumn( + name: "DatasetPbId", + table: "TabularModel", + newName: "Ms Id"); + + migrationBuilder.RenameColumn( + name: "Result", + table: "TestRun", + newName: "WasPassed"); + + migrationBuilder.RenameColumn( + name: "ExpectedRun", + table: "TestRun", + newName: "Expected Result"); + + migrationBuilder.RenameIndex( + name: "IX_History_UnitTest", + table: "TestRun", + newName: "IX_TestRun_UnitTest"); + + migrationBuilder.RenameIndex( + name: "IX_History_TestRun", + table: "TestRun", + newName: "IX_TestRun_TestRun"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Workspace", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Ms Id", + table: "Workspace", + type: "uniqueidentifier", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AddColumn( + name: "TenantNavigationId", + table: "Workspace", + type: "int", + nullable: true); + + migrationBuilder.AlterColumn( + name: "Description", + table: "UserStory", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "UserStory", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CreatedOn", + table: "UserStory", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "ModifiedBy", + table: "UserStory", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ModifiedOn", + table: "UserStory", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AlterColumn( + name: "Lastname", + table: "User", + type: "nvarchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(100)", + oldUnicode: false, + oldMaxLength: 100, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Firstname", + table: "User", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Email", + table: "User", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "ResultType", + table: "UnitTest", + type: "int", + nullable: true, + defaultValue: 0, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Name", + table: "UnitTest", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "FloatSeparators", + table: "UnitTest", + type: "nvarchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DecimalPlaces", + table: "UnitTest", + type: "nvarchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DateTimeFormat", + table: "UnitTest", + type: "nvarchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Expected Result", + table: "UnitTest", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "UnitTest", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CreatedOn", + table: "UnitTest", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "ModifiedBy", + table: "UnitTest", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ModifiedOn", + table: "UnitTest", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Tenant", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(100)", + oldUnicode: false, + oldMaxLength: 100); + + migrationBuilder.AlterColumn( + name: "Name", + table: "TabularModel", + type: "nvarchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Ms Id", + table: "TabularModel", + type: "uniqueidentifier", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Name", + table: "ResultType", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AddColumn( + name: "Id", + table: "ResultType", + type: "int", + nullable: false, + defaultValue: 0) + .Annotation("SqlServer:Identity", "1, 1"); + + migrationBuilder.AlterColumn( + name: "TimeStamp", + table: "TestRunCollection", + type: "datetime2", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(max)", + oldUnicode: false); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "TestRunCollection", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CreatedOn", + table: "TestRunCollection", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "ModifiedBy", + table: "TestRunCollection", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ModifiedOn", + table: "TestRunCollection", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AlterColumn( + name: "TimeStamp", + table: "TestRun", + type: "datetime2", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(max)", + oldUnicode: false); + + migrationBuilder.AlterColumn( + name: "TestRun", + table: "TestRun", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "LastRun", + table: "TestRun", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "WasPassed", + table: "TestRun", + type: "bit", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Expected Result", + table: "TestRun", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + + migrationBuilder.AddColumn( + name: "CreatedBy", + table: "TestRun", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "CreatedOn", + table: "TestRun", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddColumn( + name: "ModifiedBy", + table: "TestRun", + type: "int", + nullable: true, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ModifiedOn", + table: "TestRun", + type: "datetime2", + nullable: true, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); + + migrationBuilder.AddPrimaryKey( + name: "PK_ResultType", + table: "ResultType", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_TestRunCollection", + table: "TestRunCollection", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_TestRun", + table: "TestRun", + column: "Id"); + + migrationBuilder.InsertData( + table: "ResultType", + columns: new[] { "Id", "Name" }, + values: new object[,] + { + { 1, "Date" }, + { 2, "Float" }, + { 3, "Percentage" }, + { 4, "String" } + }); + + migrationBuilder.CreateIndex( + name: "IX_Workspace_TenantNavigationId", + table: "Workspace", + column: "TenantNavigationId"); + + migrationBuilder.CreateIndex( + name: "IX_UserStory_CreatedBy", + table: "UserStory", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_UserStory_ModifiedBy", + table: "UserStory", + column: "ModifiedBy"); + + migrationBuilder.CreateIndex( + name: "IX_UnitTest_CreatedBy", + table: "UnitTest", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_UnitTest_ModifiedBy", + table: "UnitTest", + column: "ModifiedBy"); + + migrationBuilder.CreateIndex( + name: "IX_TestRunCollection_CreatedBy", + table: "TestRunCollection", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_TestRunCollection_ModifiedBy", + table: "TestRunCollection", + column: "ModifiedBy"); + + migrationBuilder.CreateIndex( + name: "IX_TestRun_CreatedBy", + table: "TestRun", + column: "CreatedBy"); + + migrationBuilder.CreateIndex( + name: "IX_TestRun_ModifiedBy", + table: "TestRun", + column: "ModifiedBy"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRun_Created_By", + table: "TestRun", + column: "CreatedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRun_Modified_By", + table: "TestRun", + column: "ModifiedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRun_TestRunCollection_TestRun", + table: "TestRun", + column: "TestRun", + principalTable: "TestRunCollection", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRun_UnitTest_UnitTest", + table: "TestRun", + column: "UnitTest", + principalTable: "UnitTest", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_TestRunCollection_Created_By", + table: "TestRunCollection", + column: "CreatedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRunCollection_Modified_By", + table: "TestRunCollection", + column: "ModifiedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UnitTest_Created_By", + table: "UnitTest", + column: "CreatedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UnitTest_Modified_By", + table: "UnitTest", + column: "ModifiedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UnitTest_ResultType_ResultType", + table: "UnitTest", + column: "ResultType", + principalTable: "ResultType", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UserStory_Created_By", + table: "UserStory", + column: "CreatedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_UserStory_Modified_By", + table: "UserStory", + column: "ModifiedBy", + principalTable: "User", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Workspace_Tenant_TenantNavigationId", + table: "Workspace", + column: "TenantNavigationId", + principalTable: "Tenant", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TestRun_Created_By", + table: "TestRun"); + + migrationBuilder.DropForeignKey( + name: "FK_TestRun_Modified_By", + table: "TestRun"); + + migrationBuilder.DropForeignKey( + name: "FK_TestRun_TestRunCollection_TestRun", + table: "TestRun"); + + migrationBuilder.DropForeignKey( + name: "FK_TestRun_UnitTest_UnitTest", + table: "TestRun"); + + migrationBuilder.DropForeignKey( + name: "FK_TestRunCollection_Created_By", + table: "TestRunCollection"); + + migrationBuilder.DropForeignKey( + name: "FK_TestRunCollection_Modified_By", + table: "TestRunCollection"); + + migrationBuilder.DropForeignKey( + name: "FK_UnitTest_Created_By", + table: "UnitTest"); + + migrationBuilder.DropForeignKey( + name: "FK_UnitTest_Modified_By", + table: "UnitTest"); + + migrationBuilder.DropForeignKey( + name: "FK_UnitTest_ResultType_ResultType", + table: "UnitTest"); + + migrationBuilder.DropForeignKey( + name: "FK_UserStory_Created_By", + table: "UserStory"); + + migrationBuilder.DropForeignKey( + name: "FK_UserStory_Modified_By", + table: "UserStory"); + + migrationBuilder.DropForeignKey( + name: "FK_Workspace_Tenant_TenantNavigationId", + table: "Workspace"); + + migrationBuilder.DropIndex( + name: "IX_Workspace_TenantNavigationId", + table: "Workspace"); + + migrationBuilder.DropIndex( + name: "IX_UserStory_CreatedBy", + table: "UserStory"); + + migrationBuilder.DropIndex( + name: "IX_UserStory_ModifiedBy", + table: "UserStory"); + + migrationBuilder.DropIndex( + name: "IX_UnitTest_CreatedBy", + table: "UnitTest"); + + migrationBuilder.DropIndex( + name: "IX_UnitTest_ModifiedBy", + table: "UnitTest"); + + migrationBuilder.DropPrimaryKey( + name: "PK_ResultType", + table: "ResultType"); + + migrationBuilder.DropPrimaryKey( + name: "PK_TestRunCollection", + table: "TestRunCollection"); + + migrationBuilder.DropIndex( + name: "IX_TestRunCollection_CreatedBy", + table: "TestRunCollection"); + + migrationBuilder.DropIndex( + name: "IX_TestRunCollection_ModifiedBy", + table: "TestRunCollection"); + + migrationBuilder.DropPrimaryKey( + name: "PK_TestRun", + table: "TestRun"); + + migrationBuilder.DropIndex( + name: "IX_TestRun_CreatedBy", + table: "TestRun"); + + migrationBuilder.DropIndex( + name: "IX_TestRun_ModifiedBy", + table: "TestRun"); + + migrationBuilder.DropColumn( + name: "TenantNavigationId", + table: "Workspace"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "UserStory"); + + migrationBuilder.DropColumn( + name: "CreatedOn", + table: "UserStory"); + + migrationBuilder.DropColumn( + name: "ModifiedBy", + table: "UserStory"); + + migrationBuilder.DropColumn( + name: "ModifiedOn", + table: "UserStory"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "CreatedOn", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "ModifiedBy", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "ModifiedOn", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "Id", + table: "ResultType"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "TestRunCollection"); + + migrationBuilder.DropColumn( + name: "CreatedOn", + table: "TestRunCollection"); + + migrationBuilder.DropColumn( + name: "ModifiedBy", + table: "TestRunCollection"); + + migrationBuilder.DropColumn( + name: "ModifiedOn", + table: "TestRunCollection"); + + migrationBuilder.DropColumn( + name: "CreatedBy", + table: "TestRun"); + + migrationBuilder.DropColumn( + name: "CreatedOn", + table: "TestRun"); + + migrationBuilder.DropColumn( + name: "ModifiedBy", + table: "TestRun"); + + migrationBuilder.DropColumn( + name: "ModifiedOn", + table: "TestRun"); + + migrationBuilder.RenameTable( + name: "TestRunCollection", + newName: "TestRuns"); + + migrationBuilder.RenameTable( + name: "TestRun", + newName: "History"); + + migrationBuilder.RenameColumn( + name: "Ms Id", + table: "Workspace", + newName: "WorkspacePbId"); + + migrationBuilder.RenameColumn( + name: "Description", + table: "UserStory", + newName: "Beschreibung"); + + migrationBuilder.RenameColumn( + name: "Expected Result", + table: "UnitTest", + newName: "ExpectedResult"); + + migrationBuilder.RenameColumn( + name: "Ms Id", + table: "TabularModel", + newName: "DatasetPbId"); + + migrationBuilder.RenameColumn( + name: "WasPassed", + table: "History", + newName: "Result"); + + migrationBuilder.RenameColumn( + name: "Expected Result", + table: "History", + newName: "ExpectedRun"); + + migrationBuilder.RenameIndex( + name: "IX_TestRun_UnitTest", + table: "History", + newName: "IX_History_UnitTest"); + + migrationBuilder.RenameIndex( + name: "IX_TestRun_TestRun", + table: "History", + newName: "IX_History_TestRun"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Workspace", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "WorkspacePbId", + table: "Workspace", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(Guid), + oldType: "uniqueidentifier"); + + migrationBuilder.AlterColumn( + name: "Beschreibung", + table: "UserStory", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Lastname", + table: "User", + type: "varchar(100)", + unicode: false, + maxLength: 100, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Firstname", + table: "User", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Email", + table: "User", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "ResultType", + table: "UnitTest", + type: "varchar(255)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "FloatSeparators", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DecimalPlaces", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DateTimeFormat", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ExpectedResult", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AddColumn( + name: "LastResult", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true); + + migrationBuilder.AddColumn( + name: "LastRun", + table: "UnitTest", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true, + defaultValue: "Error"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Tenant", + type: "varchar(100)", + unicode: false, + maxLength: 100, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100); + + migrationBuilder.AlterColumn( + name: "Name", + table: "TabularModel", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DatasetPbId", + table: "TabularModel", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(Guid), + oldType: "uniqueidentifier"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "ResultType", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "TimeStamp", + table: "TestRuns", + type: "varchar(max)", + unicode: false, + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AddColumn( + name: "Count", + table: "TestRuns", + type: "int", + unicode: false, + maxLength: 255, + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "TabularModel", + table: "TestRuns", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true); + + migrationBuilder.AddColumn( + name: "Type", + table: "TestRuns", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true); + + migrationBuilder.AddColumn( + name: "UserStory", + table: "TestRuns", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true); + + migrationBuilder.AddColumn( + name: "Workspace", + table: "TestRuns", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: true); + + migrationBuilder.AlterColumn( + name: "TimeStamp", + table: "History", + type: "varchar(max)", + unicode: false, + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "TestRun", + table: "History", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "LastRun", + table: "History", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AlterColumn( + name: "Result", + table: "History", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(bool), + oldType: "bit"); + + migrationBuilder.AlterColumn( + name: "ExpectedRun", + table: "History", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + + migrationBuilder.AddPrimaryKey( + name: "PK_ResultType", + table: "ResultType", + column: "Name"); + + migrationBuilder.AddPrimaryKey( + name: "PK_TestRuns", + table: "TestRuns", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_History", + table: "History", + column: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_History_TestRuns_TestRun", + table: "History", + column: "TestRun", + principalTable: "TestRuns", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_History_UnitTest_UnitTest", + table: "History", + column: "UnitTest", + principalTable: "UnitTest", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_UnitTest_ResultType_ResultType", + table: "UnitTest", + column: "ResultType", + principalTable: "ResultType", + principalColumn: "Name"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151602_RemakeModel2.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151602_RemakeModel2.Designer.cs new file mode 100644 index 0000000..d33d442 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151602_RemakeModel2.Designer.cs @@ -0,0 +1,602 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240411151602_RemakeModel2")] + partial class RemakeModel2 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedRun") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("LastRun") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.Property("TestRun") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRun"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("DatasetPbId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Beschreibung") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Description"); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TenantNavigationId") + .HasColumnType("int"); + + b.Property("WorkspacePbId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.HasKey("Id"); + + b.HasIndex("TenantNavigationId"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", "TestRunCollectionNavigation") + .WithMany("TestRunsDummy") + .HasForeignKey("TestRun"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType") + .IsRequired(); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("TenantNavigationId"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + { + b.Navigation("TestRunsDummy"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151602_RemakeModel2.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151602_RemakeModel2.cs new file mode 100644 index 0000000..bf76721 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151602_RemakeModel2.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel2 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "LastRun", + table: "TestRun", + newName: "Result"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Result", + table: "TestRun", + newName: "LastRun"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151823_RemakeModel3.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151823_RemakeModel3.Designer.cs new file mode 100644 index 0000000..c7fecdb --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151823_RemakeModel3.Designer.cs @@ -0,0 +1,602 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240411151823_RemakeModel3")] + partial class RemakeModel3 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Description"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TenantNavigationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantNavigationId"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType") + .IsRequired(); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("TenantNavigationId"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151823_RemakeModel3.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151823_RemakeModel3.cs new file mode 100644 index 0000000..eb0a463 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411151823_RemakeModel3.cs @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel3 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TestRun_TestRunCollection_TestRun", + table: "TestRun"); + + migrationBuilder.RenameColumn( + name: "TestRun", + table: "TestRun", + newName: "TestRunCollection"); + + migrationBuilder.RenameIndex( + name: "IX_TestRun_TestRun", + table: "TestRun", + newName: "IX_TestRun_TestRunCollection"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRun_TestRunCollection_TestRunCollection", + table: "TestRun", + column: "TestRunCollection", + principalTable: "TestRunCollection", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_TestRun_TestRunCollection_TestRunCollection", + table: "TestRun"); + + migrationBuilder.RenameColumn( + name: "TestRunCollection", + table: "TestRun", + newName: "TestRun"); + + migrationBuilder.RenameIndex( + name: "IX_TestRun_TestRunCollection", + table: "TestRun", + newName: "IX_TestRun_TestRun"); + + migrationBuilder.AddForeignKey( + name: "FK_TestRun_TestRunCollection_TestRun", + table: "TestRun", + column: "TestRun", + principalTable: "TestRunCollection", + principalColumn: "Id"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411193359_RemakeModel4.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411193359_RemakeModel4.Designer.cs new file mode 100644 index 0000000..34caf2f --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411193359_RemakeModel4.Designer.cs @@ -0,0 +1,601 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240411193359_RemakeModel4")] + partial class RemakeModel4 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Description"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TenantNavigationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantNavigationId"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .IsRequired() + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("TenantNavigationId"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411193359_RemakeModel4.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411193359_RemakeModel4.cs new file mode 100644 index 0000000..f76f783 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411193359_RemakeModel4.cs @@ -0,0 +1,33 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel4 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ResultType", + table: "UnitTest", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ResultType", + table: "UnitTest", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411195500_RemakeModel5.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411195500_RemakeModel5.Designer.cs new file mode 100644 index 0000000..3903e4f --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411195500_RemakeModel5.Designer.cs @@ -0,0 +1,593 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240411195500_RemakeModel5")] + partial class RemakeModel5 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Description"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TenantNavigationId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("TenantNavigationId"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("TenantNavigationId"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411195500_RemakeModel5.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411195500_RemakeModel5.cs new file mode 100644 index 0000000..29977bc --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411195500_RemakeModel5.cs @@ -0,0 +1,304 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel5 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "UserStory", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "UserStory", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "UserStory", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "UserStory", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "UnitTest", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "UnitTest", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "UnitTest", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "UnitTest", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "TestRunCollection", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "TestRunCollection", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "TestRunCollection", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "TestRunCollection", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "TestRun", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "TestRun", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "TestRun", + type: "datetime2", + nullable: true, + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "TestRun", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "UserStory", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "UserStory", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "UserStory", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "UserStory", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "UnitTest", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "UnitTest", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "UnitTest", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "UnitTest", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "TestRunCollection", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "TestRunCollection", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "TestRunCollection", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "TestRunCollection", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedOn", + table: "TestRun", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ModifiedBy", + table: "TestRun", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedOn", + table: "TestRun", + type: "datetime2", + nullable: false, + defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedBy", + table: "TestRun", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411200539_RemakeModel6.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411200539_RemakeModel6.Designer.cs new file mode 100644 index 0000000..8425540 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411200539_RemakeModel6.Designer.cs @@ -0,0 +1,594 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240411200539_RemakeModel6")] + partial class RemakeModel6 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Description"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411200539_RemakeModel6.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411200539_RemakeModel6.cs new file mode 100644 index 0000000..b4b05c0 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240411200539_RemakeModel6.cs @@ -0,0 +1,57 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel6 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Workspace_Tenant_TenantNavigationId", + table: "Workspace"); + + migrationBuilder.RenameColumn( + name: "TenantNavigationId", + table: "Workspace", + newName: "Tenant"); + + migrationBuilder.RenameIndex( + name: "IX_Workspace_TenantNavigationId", + table: "Workspace", + newName: "IX_Workspace_Tenant"); + + migrationBuilder.AddForeignKey( + name: "FK_Workspace_Tenant", + table: "Workspace", + column: "Tenant", + principalTable: "Tenant", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Workspace_Tenant", + table: "Workspace"); + + migrationBuilder.RenameColumn( + name: "Tenant", + table: "Workspace", + newName: "TenantNavigationId"); + + migrationBuilder.RenameIndex( + name: "IX_Workspace_Tenant", + table: "Workspace", + newName: "IX_Workspace_TenantNavigationId"); + + migrationBuilder.AddForeignKey( + name: "FK_Workspace_Tenant_TenantNavigationId", + table: "Workspace", + column: "TenantNavigationId", + principalTable: "Tenant", + principalColumn: "Id"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427114147_RemakeModel7.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427114147_RemakeModel7.Designer.cs new file mode 100644 index 0000000..ad4f375 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427114147_RemakeModel7.Designer.cs @@ -0,0 +1,594 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240427114147_RemakeModel7")] + partial class RemakeModel7 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427114147_RemakeModel7.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427114147_RemakeModel7.cs new file mode 100644 index 0000000..f601123 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427114147_RemakeModel7.cs @@ -0,0 +1,25 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel7 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Description", + table: "UserStory", + newName: "Name"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.RenameColumn( + name: "Name", + table: "UserStory", + newName: "Description"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427122504_RemakeModel8.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427122504_RemakeModel8.Designer.cs new file mode 100644 index 0000000..fa4a9fc --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427122504_RemakeModel8.Designer.cs @@ -0,0 +1,618 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240427122504_RemakeModel8")] + partial class RemakeModel8 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.HasKey("Id"); + + b.ToTable("ResultType", (string)null); + + b.HasData( + new + { + Id = 1, + Name = "Date" + }, + new + { + Id = 2, + Name = "Float" + }, + new + { + Id = 3, + Name = "Percentage" + }, + new + { + Id = 4, + Name = "String" + }); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("ResultType"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") + .WithMany("UnitTests") + .HasForeignKey("ResultType"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("ResultTypeNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427122504_RemakeModel8.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427122504_RemakeModel8.cs new file mode 100644 index 0000000..03483c1 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240427122504_RemakeModel8.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel8 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Unique Identifier", + table: "Workspace", + type: "uniqueidentifier", + nullable: false, + defaultValueSql: "NEWID()"); + + migrationBuilder.AddColumn( + name: "Unique Identifier", + table: "UserStory", + type: "uniqueidentifier", + nullable: false, + defaultValueSql: "NEWID()"); + + migrationBuilder.AddColumn( + name: "Unique Identifier", + table: "UnitTest", + type: "uniqueidentifier", + nullable: false, + defaultValueSql: "NEWID()"); + + migrationBuilder.AddColumn( + name: "Unique Identifier", + table: "TabularModel", + type: "uniqueidentifier", + nullable: false, + defaultValueSql: "NEWID()"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Unique Identifier", + table: "Workspace"); + + migrationBuilder.DropColumn( + name: "Unique Identifier", + table: "UserStory"); + + migrationBuilder.DropColumn( + name: "Unique Identifier", + table: "UnitTest"); + + migrationBuilder.DropColumn( + name: "Unique Identifier", + table: "TabularModel"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428163503_RemakeModel9.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428163503_RemakeModel9.Designer.cs new file mode 100644 index 0000000..1a66529 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428163503_RemakeModel9.Designer.cs @@ -0,0 +1,564 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240428163503_RemakeModel9")] + partial class RemakeModel9 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("varchar(255)") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428163503_RemakeModel9.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428163503_RemakeModel9.cs new file mode 100644 index 0000000..0ea5d3a --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428163503_RemakeModel9.cs @@ -0,0 +1,80 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel9 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_UnitTest_ResultType_ResultType", + table: "UnitTest"); + + migrationBuilder.DropTable( + name: "ResultType"); + + migrationBuilder.DropIndex( + name: "IX_UnitTest_ResultType", + table: "UnitTest"); + + migrationBuilder.AlterColumn( + name: "ResultType", + table: "UnitTest", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "ResultType", + table: "UnitTest", + type: "int", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.CreateTable( + name: "ResultType", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ResultType", x => x.Id); + }); + + migrationBuilder.InsertData( + table: "ResultType", + columns: new[] { "Id", "Name" }, + values: new object[,] + { + { 1, "Date" }, + { 2, "Float" }, + { 3, "Percentage" }, + { 4, "String" } + }); + + migrationBuilder.CreateIndex( + name: "IX_UnitTest_ResultType", + table: "UnitTest", + column: "ResultType"); + + migrationBuilder.AddForeignKey( + name: "FK_UnitTest_ResultType_ResultType", + table: "UnitTest", + column: "ResultType", + principalTable: "ResultType", + principalColumn: "Id"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428175729_RemakeModel10.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428175729_RemakeModel10.Designer.cs new file mode 100644 index 0000000..aba3590 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428175729_RemakeModel10.Designer.cs @@ -0,0 +1,563 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240428175729_RemakeModel10")] + partial class RemakeModel10 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("bit") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428175729_RemakeModel10.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428175729_RemakeModel10.cs new file mode 100644 index 0000000..ff9d1b9 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428175729_RemakeModel10.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel10 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Result", + table: "TestRunCollection", + type: "bit", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)", + oldUnicode: false, + oldMaxLength: 255); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Result", + table: "TestRunCollection", + type: "varchar(255)", + unicode: false, + maxLength: 255, + nullable: false, + oldClrType: typeof(bool), + oldType: "bit", + oldUnicode: false, + oldMaxLength: 255); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200617_RemakeModel11.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200617_RemakeModel11.Designer.cs new file mode 100644 index 0000000..90332b2 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200617_RemakeModel11.Designer.cs @@ -0,0 +1,571 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240428200617_RemakeModel11")] + partial class RemakeModel11 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExecutedSuccessfully") + .HasColumnType("bit") + .HasColumnName("Executed Successfully"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("JsonResponse") + .HasColumnType("nvarchar(max)") + .HasColumnName("Json Repsonse"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("bit") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200617_RemakeModel11.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200617_RemakeModel11.cs new file mode 100644 index 0000000..5fc3ad5 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200617_RemakeModel11.cs @@ -0,0 +1,36 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel11 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "Executed Successfully", + table: "TestRun", + type: "bit", + nullable: false, + defaultValue: false); + + migrationBuilder.AddColumn( + name: "Json Repsonse", + table: "TestRun", + type: "nvarchar(max)", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "Executed Successfully", + table: "TestRun"); + + migrationBuilder.DropColumn( + name: "Json Repsonse", + table: "TestRun"); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200847_RemakeModel12.Designer.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200847_RemakeModel12.Designer.cs new file mode 100644 index 0000000..7835d89 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200847_RemakeModel12.Designer.cs @@ -0,0 +1,570 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using at.PowerBIUnitTest.Portal.Data.Models; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + [DbContext(typeof(PortalDbContext))] + [Migration("20240428200847_RemakeModel12")] + partial class RemakeModel12 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .UseCollation("SQL_Latin1_General_CP1_CI_AS") + .HasAnnotation("ProductVersion", "6.0.1") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("int") + .HasColumnName("Id"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("Workspace") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Workspace"); + + b.ToTable("TabularModel", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Tenant", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExecutedSuccessfully") + .HasColumnType("bit") + .HasColumnName("Executed Successfully"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("JsonResponse") + .HasColumnType("nvarchar(max)") + .HasColumnName("Json Repsonse"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Result") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Result"); + + b.Property("TestRunCollection") + .HasColumnType("int"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("UnitTest") + .HasColumnType("int"); + + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); + + b.Property("WasPassed") + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnType("bit") + .HasColumnName("Result"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("DAX") + .IsRequired() + .HasMaxLength(3000) + .IsUnicode(true) + .HasColumnType("nvarchar(3000)") + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8"); + + b.Property("DateTimeFormat") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DateTimeFormat"); + + b.Property("DecimalPlaces") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("DecimalPlaces"); + + b.Property("ExpectedResult") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("FloatSeparators") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("FloatSeparators"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("ResultType") + .HasColumnType("nvarchar(max)"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.Property("UserStory") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("UserStory"); + + b.HasIndex("Name", "UserStory") + .IsUnique(); + + b.ToTable("UnitTest", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Firstname") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Lastname") + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("MS Id"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("User", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("TabularModel") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TabularModel"); + + b.ToTable("UserStory", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); + + b.Property("Tenant") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + + b.HasKey("Id"); + + b.HasIndex("Tenant"); + + b.ToTable("Workspace", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") + .WithMany("TestRuns") + .HasForeignKey("UnitTest") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); + + b.Navigation("UnitTestNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") + .WithMany("UnitTests") + .HasForeignKey("UserStory") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("UserStoryNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Users") + .HasForeignKey("Tenant") + .IsRequired(); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") + .WithMany("UserStories") + .HasForeignKey("TabularModel") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TabularModelNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.Navigation("UserStories"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => + { + b.Navigation("Users"); + + b.Navigation("Workspaces"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => + { + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => + { + b.Navigation("UnitTests"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => + { + b.Navigation("TabularModels"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200847_RemakeModel12.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200847_RemakeModel12.cs new file mode 100644 index 0000000..dea4b03 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/20240428200847_RemakeModel12.cs @@ -0,0 +1,37 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace at.PowerBIUnitTest.Portal.Data.Migrations +{ + public partial class RemakeModel12 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Result", + table: "TestRun", + type: "nvarchar(255)", + maxLength: 255, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Result", + table: "TestRun", + type: "nvarchar(255)", + maxLength: 255, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(255)", + oldMaxLength: 255, + oldNullable: true); + } + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/PortalDbContextModelSnapshot.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/PortalDbContextModelSnapshot.cs index 9fd5bd1..3de0722 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/PortalDbContextModelSnapshot.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Migrations/PortalDbContextModelSnapshot.cs @@ -23,7 +23,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b => + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -34,102 +34,20 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - b.Property("ExpectedRun") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("ExpectedRun"); - - b.Property("LastRun") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("LastRun"); - - b.Property("Result") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("Result"); - - b.Property("TestRun") - .HasColumnType("int"); - - b.Property("TimeStamp") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)") - .HasColumnName("TimeStamp"); - - b.Property("UnitTest") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("TestRun"); - - b.HasIndex("UnitTest"); - - b.ToTable("History", (string)null); - }); + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => - { b.Property("Name") .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("Name"); - b.HasKey("Name"); - - b.ToTable("ResultType", (string)null); - - b.HasData( - new - { - Name = "Date" - }, - new - { - Name = "Float" - }, - new - { - Name = "Percentage" - }, - new - { - Name = "String" - }); - }); - - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => - { - b.Property("Id") + b.Property("UniqueIdentifier") .ValueGeneratedOnAdd() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("int") - .HasColumnName("Id"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - - b.Property("DatasetPbId") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("DatasetPbId"); - - b.Property("Name") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("Name"); + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); b.Property("Workspace") .HasColumnType("int"); @@ -150,92 +68,138 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); b.Property("MsId") - .HasMaxLength(36) - .IsUnicode(false) .HasColumnType("uniqueidentifier") .HasColumnName("MS Id"); b.Property("Name") .IsRequired() .HasMaxLength(100) - .IsUnicode(false) - .HasColumnType("varchar(100)"); + .HasColumnType("nvarchar(100)"); b.HasKey("Id"); b.ToTable("Tenant", (string)null); }); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("int") - .HasColumnName("Id"); + .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - b.Property("Count") + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ExecutedSuccessfully") + .HasColumnType("bit") + .HasColumnName("Executed Successfully"); + + b.Property("ExpectedResult") + .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("int") - .HasColumnName("Count"); + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); + + b.Property("JsonResponse") + .HasColumnType("nvarchar(max)") + .HasColumnName("Json Repsonse"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); b.Property("Result") - .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("Result"); - b.Property("TabularModel") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("TabularModel"); + b.Property("TestRunCollection") + .HasColumnType("int"); - b.Property("TimeStamp") - .IsRequired() - .IsUnicode(false) - .HasColumnType("varchar(max)") + b.Property("TimeStamp") + .HasColumnType("datetime2") .HasColumnName("TimeStamp"); - b.Property("Type") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("Type"); + b.Property("UnitTest") + .HasColumnType("int"); - b.Property("UserStory") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("UserStory"); + b.Property("WasPassed") + .HasColumnType("bit") + .HasColumnName("WasPassed"); + + b.HasKey("Id"); + + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.HasIndex("TestRunCollection"); + + b.HasIndex("UnitTest"); + + b.ToTable("TestRun", (string)null); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("TimeStamp") + .HasColumnType("datetime2") + .HasColumnName("TimeStamp"); - b.Property("Workspace") + b.Property("WasPassed") .HasMaxLength(255) .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("Workspace"); + .HasColumnType("bit") + .HasColumnName("Result"); b.HasKey("Id"); - b.ToTable("TestRuns", (string)null); + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + + b.ToTable("TestRunCollection", (string)null); }); modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => { b.Property("Id") .ValueGeneratedOnAdd() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("int") - .HasColumnName("Id"); + .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + b.Property("DAX") .IsRequired() .HasMaxLength(3000) @@ -246,59 +210,54 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("DateTimeFormat") .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("DateTimeFormat"); b.Property("DecimalPlaces") .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("DecimalPlaces"); b.Property("ExpectedResult") .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("ExpectedResult"); + .HasColumnType("nvarchar(255)") + .HasColumnName("Expected Result"); b.Property("FloatSeparators") .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("FloatSeparators"); - b.Property("LastResult") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("LastResult"); + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); b.Property("Name") .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("Name"); b.Property("ResultType") - .HasColumnType("varchar(255)"); + .HasColumnType("nvarchar(max)"); - b.Property("Timestamp") + b.Property("UniqueIdentifier") .ValueGeneratedOnAdd() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasDefaultValue("Error") - .HasColumnName("LastRun"); + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); b.Property("UserStory") .HasColumnType("int"); b.HasKey("Id"); - b.HasIndex("ResultType"); + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); b.HasIndex("UserStory"); @@ -319,23 +278,18 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Email") .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); + .HasColumnType("nvarchar(255)"); b.Property("Firstname") .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)"); + .HasColumnType("nvarchar(255)"); b.Property("Lastname") - .HasMaxLength(100) - .IsUnicode(false) - .HasColumnType("varchar(100)"); + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); b.Property("MsId") - .HasMaxLength(36) - .IsUnicode(false) .HasColumnType("uniqueidentifier") .HasColumnName("MS Id"); @@ -353,25 +307,43 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("int") - .HasColumnName("Id"); + .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); - b.Property("Beschreibung") + b.Property("CreatedBy") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("ModifiedBy") + .HasColumnType("int"); + + b.Property("ModifiedOn") + .HasColumnType("datetime2"); + + b.Property("Name") .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("Beschreibung"); + .HasColumnType("nvarchar(255)") + .HasColumnName("Name"); b.Property("TabularModel") .HasColumnType("int"); + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); + b.HasKey("Id"); + b.HasIndex("CreatedBy"); + + b.HasIndex("ModifiedBy"); + b.HasIndex("TabularModel"); b.ToTable("UserStory", (string)null); @@ -381,65 +353,106 @@ protected override void BuildModel(ModelBuilder modelBuilder) { b.Property("Id") .ValueGeneratedOnAdd() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("int") - .HasColumnName("Id"); + .HasColumnType("int"); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + b.Property("MsId") + .HasColumnType("uniqueidentifier") + .HasColumnName("Ms Id"); + b.Property("Name") .IsRequired() .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") + .HasColumnType("nvarchar(255)") .HasColumnName("Name"); - b.Property("WorkspacePbId") - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnType("varchar(255)") - .HasColumnName("WorkspacePbId"); + b.Property("Tenant") + .HasColumnType("int"); + + b.Property("UniqueIdentifier") + .ValueGeneratedOnAdd() + .HasColumnType("uniqueidentifier") + .HasColumnName("Unique Identifier") + .HasDefaultValueSql("NEWID()"); b.HasKey("Id"); + b.HasIndex("Tenant"); + b.ToTable("Workspace", (string)null); }); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.History", b => + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") + .WithMany("TabularModels") + .HasForeignKey("Workspace") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("WorkspaceNavigation"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRun", b => { - b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", "TestRunNavigation") - .WithMany("HistoriesRun") - .HasForeignKey("TestRun"); + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRun_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRun_Modified_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", "TestRunCollectionNavigation") + .WithMany("TestRuns") + .HasForeignKey("TestRunCollection"); b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", "UnitTestNavigation") - .WithMany("Histories") + .WithMany("TestRuns") .HasForeignKey("UnitTest") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("TestRunNavigation"); + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + + b.Navigation("TestRunCollectionNavigation"); b.Navigation("UnitTestNavigation"); }); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => { - b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Workspace", "WorkspaceNavigation") - .WithMany("TabularModels") - .HasForeignKey("Workspace") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("TestRunCollectionCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_TestRunCollection_Created_By"); - b.Navigation("WorkspaceNavigation"); + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("TestRunCollectionModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_TestRunCollection_Modified_By"); + + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); }); modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => { - b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.ResultType", "ResultTypeNavigation") - .WithMany("UnitTests") - .HasForeignKey("ResultType"); + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UnitTestCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UnitTest_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UnitTestModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UnitTest_Modified_By"); b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.UserStory", "UserStoryNavigation") .WithMany("UnitTests") @@ -447,7 +460,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.Navigation("ResultTypeNavigation"); + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); b.Navigation("UserStoryNavigation"); }); @@ -464,18 +479,37 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => { + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "CreatedByNavigation") + .WithMany("UserStoryCreatedByNavigations") + .HasForeignKey("CreatedBy") + .HasConstraintName("FK_UserStory_Created_By"); + + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.User", "ModifiedByNavigation") + .WithMany("UserStoryModifiedByNavigations") + .HasForeignKey("ModifiedBy") + .HasConstraintName("FK_UserStory_Modified_By"); + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", "TabularModelNavigation") .WithMany("UserStories") .HasForeignKey("TabularModel") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); + b.Navigation("CreatedByNavigation"); + + b.Navigation("ModifiedByNavigation"); + b.Navigation("TabularModelNavigation"); }); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.ResultType", b => + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Workspace", b => { - b.Navigation("UnitTests"); + b.HasOne("at.PowerBIUnitTest.Portal.Data.Models.Tenant", "TenantNavigation") + .WithMany("Workspaces") + .HasForeignKey("Tenant") + .HasConstraintName("FK_Workspace_Tenant"); + + b.Navigation("TenantNavigation"); }); modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TabularModel", b => @@ -486,16 +520,37 @@ protected override void BuildModel(ModelBuilder modelBuilder) modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.Tenant", b => { b.Navigation("Users"); + + b.Navigation("Workspaces"); }); - modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRuns", b => + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.TestRunCollection", b => { - b.Navigation("HistoriesRun"); + b.Navigation("TestRuns"); }); modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UnitTest", b => { - b.Navigation("Histories"); + b.Navigation("TestRuns"); + }); + + modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.User", b => + { + b.Navigation("TestRunCollectionCreatedByNavigations"); + + b.Navigation("TestRunCollectionModifiedByNavigations"); + + b.Navigation("TestRunCreatedByNavigations"); + + b.Navigation("TestRunModifiedByNavigations"); + + b.Navigation("UnitTestCreatedByNavigations"); + + b.Navigation("UnitTestModifiedByNavigations"); + + b.Navigation("UserStoryCreatedByNavigations"); + + b.Navigation("UserStoryModifiedByNavigations"); }); modelBuilder.Entity("at.PowerBIUnitTest.Portal.Data.Models.UserStory", b => diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/History.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/History.cs deleted file mode 100644 index c58867d..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/History.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Microsoft.AspNetCore.OData.Routing.Attributes; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.SqlServer; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace at.PowerBIUnitTest.Portal.Data.Models -{ - public partial class History - { - - public int Id {get; set;} - public string TimeStamp {get; set;} - public string Result {get; set;} - public string LastRun {get; set;} - public string ExpectedRun{get; set;} - public int UnitTest {get; set;} - public int? TestRun {get; set;} - - - public virtual UnitTest UnitTestNavigation { get; set; } - public virtual TestRuns TestRunNavigation { get; set; } - - } -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackCreated.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackCreated.cs index ca7eeca..ac7c04a 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackCreated.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackCreated.cs @@ -4,7 +4,7 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { public interface ITrackCreated { - int CreatedBy { get; set; } - DateTime CreatedOn { get; set; } + int? CreatedBy { get; set; } + DateTime? CreatedOn { get; set; } } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackModified.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackModified.cs index e9de5bb..e36d844 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackModified.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ITrackModified.cs @@ -4,7 +4,7 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { public interface ITrackModified : ITrackCreated { - int ModifiedBy { get; set; } - DateTime ModifiedOn { get; set; } + int? ModifiedBy { get; set; } + DateTime? ModifiedOn { get; set; } } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/PortalDbContext.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/PortalDbContext.cs index 10898d7..eb53356 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/PortalDbContext.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/PortalDbContext.cs @@ -22,14 +22,15 @@ public PortalDbContext(DbContextOptions options) { } + public virtual DbSet TabularModels { get; set; } public virtual DbSet Tenants { get; set; } + public virtual DbSet TestRuns { get; set; } + public virtual DbSet TestRunCollections { get; set; } + public virtual DbSet UnitTests { get; set; } public virtual DbSet Users { get; set; } + public virtual DbSet UserStories { get; set; } public virtual DbSet Workspaces { get; set; } - public virtual DbSet TabularModels {get; set;} - public virtual DbSet UserStories {get; set;} - public virtual DbSet UnitTests {get; set;} - public virtual DbSet Histories {get; set;} - public virtual DbSet TestRuns {get; set;} + public Guid MsIdCurrentUser { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -41,20 +42,186 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + modelBuilder.Entity(entity => + { + entity.ToTable("TabularModel"); + + entity.Property(e => e.Id) + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnName("Id"); + + entity.Property(e => e.UniqueIdentifier) + .HasDefaultValueSql("NEWID()") + .IsRequired() + .HasColumnName("Unique Identifier"); + + entity.Property(e => e.MsId) + .IsRequired() + .HasColumnName("Ms Id"); + + entity.Property(e => e.Name) + .HasMaxLength(255) + .HasColumnName("Name"); + + entity.HasOne(d => d.WorkspaceNavigation) + .WithMany(p => p.TabularModels) + .HasForeignKey(d => d.Workspace) + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity(entity => { entity.ToTable("Tenant"); entity.Property(e => e.MsId) .IsRequired() - .HasMaxLength(36) - .IsUnicode(false) .HasColumnName("MS Id"); entity.Property(e => e.Name) .IsRequired() - .HasMaxLength(100) - .IsUnicode(false); + .HasMaxLength(100); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("TestRun"); + + entity.Property(e => e.WasPassed) + .IsRequired() + .HasColumnName("WasPassed"); + + entity.Property(e => e.TimeStamp) + .IsRequired() + .HasColumnName("TimeStamp"); + + entity.Property(e => e.Result) + .HasMaxLength(255) + .HasColumnName("Result"); + + entity.Property(e => e.ExpectedResult) + .IsRequired() + .HasMaxLength(255) + .HasColumnName("Expected Result"); + + entity.Property(e => e.JsonResponse) + .HasColumnName("Json Repsonse"); + + entity.Property(e => e.ExecutedSuccessfully) + .HasColumnName("Executed Successfully"); + + entity.HasOne(d => d.UnitTestNavigation) + .WithMany(p => p.TestRuns) + .HasForeignKey(d => d.UnitTest) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.TestRunCollectionNavigation) + .WithMany(p => p.TestRuns) + .HasForeignKey(d => d.TestRunCollection) + .OnDelete(DeleteBehavior.ClientSetNull) + .IsRequired(false); + + entity.HasOne(d => d.CreatedByNavigation) + .WithMany(p => p.TestRunCreatedByNavigations) + .HasForeignKey(d => d.CreatedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_TestRun_Created_By"); + + entity.HasOne(d => d.ModifiedByNavigation) + .WithMany(p => p.TestRunModifiedByNavigations) + .HasForeignKey(d => d.ModifiedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_TestRun_Modified_By"); + + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("TestRunCollection"); + + entity.Property(e => e.WasPassed) + .IsRequired() + .HasMaxLength(255) + .IsUnicode(false) + .HasColumnName("Result"); + + entity.Property(e => e.TimeStamp) + .IsRequired() + .HasColumnName("TimeStamp"); + + entity.HasOne(d => d.CreatedByNavigation) + .WithMany(p => p.TestRunCollectionCreatedByNavigations) + .HasForeignKey(d => d.CreatedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_TestRunCollection_Created_By"); + + entity.HasOne(d => d.ModifiedByNavigation) + .WithMany(p => p.TestRunCollectionModifiedByNavigations) + .HasForeignKey(d => d.ModifiedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_TestRunCollection_Modified_By"); + }); + + modelBuilder.Entity(entity => + { + entity.ToTable("UnitTest"); + + entity.HasIndex(p => new { p.Name, p.UserStory }) + .IsUnique(); + + entity.Property(e => e.Name) + .IsRequired() + .HasMaxLength(255) + .HasColumnName("Name"); + + entity.Property(e => e.UniqueIdentifier) + .HasDefaultValueSql("NEWID()") + .IsRequired() + .HasColumnName("Unique Identifier"); + + entity.Property(e => e.ExpectedResult) + .IsRequired() + .HasMaxLength(255) + .HasColumnName("Expected Result"); + + entity.Property(e => e.DateTimeFormat) + .HasMaxLength(255) + .HasColumnName("DateTimeFormat"); + + entity.Property(e => e.DecimalPlaces) + .HasMaxLength(255) + .HasColumnName("DecimalPlaces"); + + entity.Property(e => e.FloatSeparators) + .HasMaxLength(255) + .HasColumnName("FloatSeparators"); + + entity.Property(e => e.DAX) + .IsRequired() + .HasMaxLength(3000) + .HasColumnName("DAX") + .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8") + .IsUnicode(); + + entity.HasOne(d => d.UserStoryNavigation) + .WithMany(p => p.UnitTests) + .HasForeignKey(d => d.UserStory) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.CreatedByNavigation) + .WithMany(p => p.UnitTestCreatedByNavigations) + .HasForeignKey(d => d.CreatedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_UnitTest_Created_By") + .IsRequired(false); + + entity.HasOne(d => d.ModifiedByNavigation) + .WithMany(p => p.UnitTestModifiedByNavigations) + .HasForeignKey(d => d.ModifiedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_UnitTest_Modified_By") + .IsRequired(false); }); modelBuilder.Entity(entity => @@ -63,22 +230,17 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) entity.Property(e => e.Email) .IsRequired() - .HasMaxLength(255) - .IsUnicode(false); + .HasMaxLength(255); entity.Property(e => e.Firstname) .IsRequired() - .HasMaxLength(255) - .IsUnicode(false); + .HasMaxLength(255); entity.Property(e => e.Lastname) - .HasMaxLength(100) - .IsUnicode(false); + .HasMaxLength(255); entity.Property(e => e.MsId) .IsRequired() - .HasMaxLength(36) - .IsUnicode(false) .HasColumnName("MS Id"); entity.HasOne(d => d.TenantNavigation) @@ -87,264 +249,65 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) .OnDelete(DeleteBehavior.ClientSetNull); }); - modelBuilder.Entity(entity => - { - entity.ToTable("Workspace"); - - entity.Property(e => e.Id) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Id"); - - entity.Property(e => e.Name) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Name"); - - entity.Property(e => e.WorkspacePbId) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("WorkspacePbId"); - }); - modelBuilder.Entity(entity => { entity.ToTable("UserStory"); - entity.Property(e => e.Id) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Id"); - - entity.Property(e => e.Beschreibung) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Beschreibung"); - - entity.HasOne(d => d.TabularModelNavigation) - .WithMany(p => p.UserStories) - .HasForeignKey(d => d.TabularModel) - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("UnitTest"); - - - entity.Property(e => e.Id) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Id"); - - entity.Property(e => e.Name) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Name"); - - entity.Property(e => e.ExpectedResult) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("ExpectedResult"); - - entity.Property(e => e.LastResult) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("LastResult"); - - entity.Property(e => e.Timestamp) - .HasDefaultValue("Error") - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("LastRun"); - - entity.Property(e => e.DateTimeFormat) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("DateTimeFormat"); - - entity.Property(e => e.DecimalPlaces) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("DecimalPlaces"); - - entity.Property(e => e.FloatSeparators) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("FloatSeparators"); - - entity.Property(e => e.DAX) - .IsRequired() - .HasMaxLength(3000) - .IsUnicode(false) - .HasColumnName("DAX") - .UseCollation("LATIN1_GENERAL_100_CI_AS_SC_UTF8") - .IsUnicode(); - - entity.HasOne(d => d.UserStoryNavigation) - .WithMany(p => p.UnitTests) - .HasForeignKey(d => d.UserStory) - .OnDelete(DeleteBehavior.Cascade); - - entity.HasOne(d => d.ResultTypeNavigation) - .WithMany(p => p.UnitTests) - .HasForeignKey(d => d.ResultType) - .OnDelete(DeleteBehavior.ClientSetNull); + entity.Property(e => e.UniqueIdentifier) + .HasDefaultValueSql("NEWID()") + .IsRequired() + .HasColumnName("Unique Identifier"); - entity.HasIndex(p => new {p.Name , p.UserStory}).IsUnique(); - + entity.Property(e => e.Name) + .IsRequired() + .HasMaxLength(255) + .HasColumnName("Name"); + + entity.HasOne(d => d.TabularModelNavigation) + .WithMany(p => p.UserStories) + .HasForeignKey(d => d.TabularModel) + .OnDelete(DeleteBehavior.Cascade); + + entity.HasOne(d => d.CreatedByNavigation) + .WithMany(p => p.UserStoryCreatedByNavigations) + .HasForeignKey(d => d.CreatedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_UserStory_Created_By") + .IsRequired(false); + + entity.HasOne(d => d.ModifiedByNavigation) + .WithMany(p => p.UserStoryModifiedByNavigations) + .HasForeignKey(d => d.ModifiedBy) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_UserStory_Modified_By") + .IsRequired(false); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.ToTable("ResultType"); + entity.ToTable("Workspace"); entity.Property(e => e.Name) .IsRequired() .HasMaxLength(255) - .IsUnicode(false) .HasColumnName("Name"); - entity.HasData(new ResultType{Name = "Date"}); - entity.HasData(new ResultType{Name = "Float"}); - entity.HasData(new ResultType{Name = "Percentage"}); - entity.HasData(new ResultType{Name = "String"}); - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("TabularModel"); - - entity.Property(e => e.Id) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Id"); - - entity.Property(e => e.DatasetPbId) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("DatasetPbId"); - - entity.Property(e => e.Name) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Name"); - - entity.HasOne(d => d.WorkspaceNavigation) - .WithMany(p => p.TabularModels) - .HasForeignKey(d => d.Workspace) - .OnDelete(DeleteBehavior.Cascade); - }); - + entity.Property(e => e.UniqueIdentifier) + .HasDefaultValueSql("NEWID()") + .IsRequired() + .HasColumnName("Unique Identifier"); - modelBuilder.Entity(entity => - { - entity.ToTable("History"); - - entity.Property(e => e.Id) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Id"); - - entity.Property(e => e.Result) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Result"); - - entity.Property(e => e.TimeStamp) - .IsRequired() - .IsUnicode(false) - . HasColumnName("TimeStamp"); - - entity.Property(e => e.LastRun) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("LastRun"); - - entity.Property(e => e.ExpectedRun) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("ExpectedRun"); - - entity.HasOne(d => d.UnitTestNavigation) - .WithMany(p => p.Histories) - .HasForeignKey(d => d.UnitTest) - .OnDelete(DeleteBehavior.Cascade); - - - entity.HasOne(d => d.TestRunNavigation) - .WithMany(p => p.HistoriesRun) - .HasForeignKey(d => d.TestRun) - .OnDelete(DeleteBehavior.ClientSetNull) - .IsRequired(false); - - - - }); - - modelBuilder.Entity(entity => - { - entity.ToTable("TestRuns"); - - entity.Property(e => e.Id) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Id"); - - entity.Property(e => e.Result) - .IsRequired() - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Result"); - - entity.Property(e => e.TimeStamp) - .IsRequired() - .IsUnicode(false) - . HasColumnName("TimeStamp"); - - entity.Property(e => e.Workspace) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Workspace"); - - entity.Property(e => e.Count) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Count"); - - entity.Property(e => e.TabularModel) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("TabularModel"); - - entity.Property(e => e.UserStory) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("UserStory"); - - entity.Property(e => e.Type) - .HasMaxLength(255) - .IsUnicode(false) - .HasColumnName("Type"); + entity.Property(e => e.MsId) + .IsRequired() + .HasColumnName("Ms Id"); + entity.HasOne(d => d.TenantNavigation) + .WithMany(p => p.Workspaces) + .HasForeignKey(d => d.Tenant) + .OnDelete(DeleteBehavior.ClientSetNull) + .HasConstraintName("FK_Workspace_Tenant") + .IsRequired(false); }); - - OnModelCreatingPartial(modelBuilder); } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ResultType.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ResultType.cs deleted file mode 100644 index c904fe2..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/ResultType.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Microsoft.AspNetCore.OData.Routing.Attributes; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.SqlServer; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace at.PowerBIUnitTest.Portal.Data.Models -{ - public partial class ResultType - { - public ResultType() - { - UnitTests = new HashSet(); - } - [Key] - public string Name {get; set;} - - public virtual ICollection UnitTests { get; set; } - } - - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Root.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Root.cs deleted file mode 100644 index 498aa99..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Root.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; -using System.Collections.ObjectModel; - -public class Root - { - [JsonProperty("@odata.context")] - public string OdataContext { get; set; } - - [JsonProperty("@odata.count")] - public int OdataCount { get; set; } - - [JsonProperty("value")] - public virtual ICollection Values { get; set; } - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Root3.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Root3.cs deleted file mode 100644 index c6903c9..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Root3.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System.Collections.Generic; -using Newtonsoft.Json; - - -public class Root3 - { - [JsonProperty("@odata.context")] - public string OdataContext { get; set; } - - [JsonProperty("value")] - public List Values { get; set; } - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Structure.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Structure.cs deleted file mode 100644 index 7cad98f..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Structure.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace at.PowerBIUnitTest.Portal.Data.Models{ -public class Structur - { - public string Typ { get; set; } - public string Name { get; set; } - public string WorkspacePbId { get; set; } - public string DatasetPbId { get; set; } - public string ExpectedResult { get; set; } - public string DAX { get; set; } - public string Timestamp { get; set; } - public string LastResult { get; set; } - public int UserStory { get; set; } - public int Id { get; set; } - public List items { get; set; } - - public virtual UserStory UserStoryNavigation { get; set; } - } -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TabularModel.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TabularModel.cs index ffe8847..13cff13 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TabularModel.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TabularModel.cs @@ -8,23 +8,17 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { public partial class TabularModel { - public TabularModel() - { - UserStories = new HashSet(); - } - - [Key] public int Id { get; set; } + public Guid UniqueIdentifier { get; set; } - public string DatasetPbId { get; set; } + public Guid MsId { get; set; } - public int Workspace {get; set;} + public int Workspace { get; set; } - public string Name {get; set;} + public string Name { get; set; } public virtual ICollection UserStories { get; set; } public virtual Workspace WorkspaceNavigation { get; set; } - } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Tenant.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Tenant.cs index ac1b2c4..3205f36 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Tenant.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Tenant.cs @@ -7,15 +7,11 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { public partial class Tenant { - public Tenant() - { - Users = new HashSet(); - } - public int Id { get; set; } public string Name { get; set; } public Guid MsId { get; set; } public virtual ICollection Users { get; set; } + public virtual ICollection Workspaces { get; set; } } } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRun.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRun.cs new file mode 100644 index 0000000..e2e7d8a --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRun.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.OData.Routing.Attributes; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.SqlServer; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace at.PowerBIUnitTest.Portal.Data.Models +{ + public partial class TestRun : ITrackModified + { + public int Id {get; set;} + public DateTime TimeStamp {get; set;} + public bool WasPassed {get; set;} + public string Result {get; set;} + public string ExpectedResult{get; set;} + public string JsonResponse {get; set;} + public bool ExecutedSuccessfully {get; set;} + public int UnitTest {get; set;} + public int TestRunCollection {get; set;} + + public int? CreatedBy { get; set; } + public DateTime? CreatedOn { get; set; } + public int? ModifiedBy { get; set; } + public DateTime? ModifiedOn { get; set; } + + public virtual User CreatedByNavigation { get; set; } + public virtual User ModifiedByNavigation { get; set; } + + public virtual UnitTest UnitTestNavigation { get; set; } + public virtual TestRunCollection TestRunCollectionNavigation { get; set; } + + } +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRunCollection.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRunCollection.cs new file mode 100644 index 0000000..0c56457 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRunCollection.cs @@ -0,0 +1,26 @@ +using Microsoft.AspNetCore.OData.Routing.Attributes; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.SqlServer; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace at.PowerBIUnitTest.Portal.Data.Models +{ + public partial class TestRunCollection : ITrackModified + { + public int Id {get; set;} + public DateTime TimeStamp {get; set;} + public bool WasPassed {get; set;} + + public int? CreatedBy { get; set; } + public DateTime? CreatedOn { get; set; } + public int? ModifiedBy { get; set; } + public DateTime? ModifiedOn { get; set; } + + public virtual User CreatedByNavigation { get; set; } + public virtual User ModifiedByNavigation { get; set; } + + public virtual ICollection TestRuns { get; set; } + } +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRuns.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRuns.cs deleted file mode 100644 index b2cace8..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/TestRuns.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.AspNetCore.OData.Routing.Attributes; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.SqlServer; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace at.PowerBIUnitTest.Portal.Data.Models -{ - public partial class TestRuns - { - public TestRuns() - { - HistoriesRun = new HashSet(); - } - - [Key] - public int Id {get; set;} - public string TimeStamp {get; set;} - public string Result {get; set;} - public string Workspace {get; set;} - public string TabularModel {get; set;} - public string UserStory {get; set;} - public int Count {get; set;} - public string Type {get; set;} - - public virtual ICollection HistoriesRun { get; set; } - //public virtual UnitTest UnitTestNavigation { get; set; } - - } -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTest.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTest.cs index beb25dc..a9fddbb 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTest.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTest.cs @@ -10,39 +10,29 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { - public partial class UnitTest + public partial class UnitTest : ITrackModified { - public UnitTest() - { - Histories = new HashSet(); - } - - [Key] public int Id { get; set; } + public Guid UniqueIdentifier { get; set; } public string Name { get; set; } - public string ExpectedResult { get; set; } - - public string LastResult { get; set; } - - public string Timestamp { get; set; } - - public int UserStory {get; set;} - - public string DAX {get; set;} - - public string ResultType {get; set;} - - public string DateTimeFormat {get; set;} - - public string DecimalPlaces {get; set;} - - public string FloatSeparators {get; set;} - - public virtual ICollection Histories { get; set; } + public int UserStory { get; set; } + public string DAX { get; set; } + public string ResultType { get; set; } + public string DateTimeFormat { get; set; } + public string DecimalPlaces { get; set; } + public string FloatSeparators { get; set; } + + public int? CreatedBy { get; set; } + public DateTime? CreatedOn { get; set; } + public int? ModifiedBy { get; set; } + public DateTime? ModifiedOn { get; set; } + + public virtual User CreatedByNavigation { get; set; } + public virtual User ModifiedByNavigation { get; set; } + + public virtual ICollection TestRuns { get; set; } public virtual UserStory UserStoryNavigation { get; set; } - public virtual ResultType ResultTypeNavigation {get; set;} - } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTestExecutetionResult.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTestExecutetionResult.cs deleted file mode 100644 index 8c4d2d2..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UnitTestExecutetionResult.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Microsoft.AspNetCore.OData.Routing.Attributes; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; - -namespace at.PowerBIUnitTest.Portal.Data.Models { - -public class UnitTestExecutionResult{ - - public bool UnitTestSucceeded { get; set; } - public bool UnitTestExecuted { get; set; } - -} - -} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/User.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/User.cs index 9e9f66c..6f2296b 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/User.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/User.cs @@ -14,6 +14,15 @@ public partial class User public Guid MsId { get; set; } public int Tenant { get; set; } + public virtual ICollection UserStoryCreatedByNavigations { get; set; } + public virtual ICollection UserStoryModifiedByNavigations { get; set; } + public virtual ICollection UnitTestCreatedByNavigations { get; set; } + public virtual ICollection UnitTestModifiedByNavigations { get; set; } + public virtual ICollection TestRunCreatedByNavigations { get; set; } + public virtual ICollection TestRunModifiedByNavigations { get; set; } + public virtual ICollection TestRunCollectionCreatedByNavigations { get; set; } + public virtual ICollection TestRunCollectionModifiedByNavigations { get; set; } + public virtual Tenant TenantNavigation { get; set; } } } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UserStory.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UserStory.cs index 1f7cca5..6d806a9 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UserStory.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/UserStory.cs @@ -6,22 +6,23 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { - public partial class UserStory + public partial class UserStory : ITrackModified { - public UserStory() - { - UnitTests = new HashSet(); - } - - [Key] public int Id { get; set; } + public Guid UniqueIdentifier { get; set; } - public string Beschreibung { get; set; } - + public string Name { get; set; } public int TabularModel { get; set; } - public virtual ICollection UnitTests { get; set; } + public int? CreatedBy { get; set; } + public DateTime? CreatedOn { get; set; } + public int? ModifiedBy { get; set; } + public DateTime? ModifiedOn { get; set; } + public virtual User CreatedByNavigation { get; set; } + public virtual User ModifiedByNavigation { get; set; } + + public virtual ICollection UnitTests { get; set; } public virtual TabularModel TabularModelNavigation { get; set; } } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Value.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Value.cs deleted file mode 100644 index e3eae65..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Value.cs +++ /dev/null @@ -1,10 +0,0 @@ - public class Value - { - public string id { get; set; } - public bool isReadOnly { get; set; } - public bool isOnDedicatedCapacity { get; set; } - public string type { get; set; } - public string dataflowStorageId { get; set; } - public string name { get; set; } - public string capacityId { get; set; } - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Value2.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Value2.cs deleted file mode 100644 index 37cd2e6..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Value2.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using Newtonsoft.Json; - -public class Value2 - { - public string id { get; set; } - public string name { get; set; } - public string webUrl { get; set; } - public bool addRowsAPIEnabled { get; set; } - public string configuredBy { get; set; } - public bool isRefreshable { get; set; } - public bool isEffectiveIdentityRequired { get; set; } - public bool isEffectiveIdentityRolesRequired { get; set; } - public bool isOnPremGatewayRequired { get; set; } - public string targetStorageMode { get; set; } - public DateTime createdDate { get; set; } - public string createReportEmbedURL { get; set; } - public string qnaEmbedURL { get; set; } - public List upstreamDatasets { get; set; } - public List users { get; set; } - } diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Workspace.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Workspace.cs index 5cb0fc5..b46e237 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Workspace.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Data/Models/Workspace.cs @@ -8,19 +8,17 @@ namespace at.PowerBIUnitTest.Portal.Data.Models { public partial class Workspace { - public Workspace() - { - TabularModels = new HashSet(); - } - - [Key] public int Id { get; set; } public string Name { get; set; } - public string WorkspacePbId {get; set;} + public Guid MsId { get; set; } + + public Guid UniqueIdentifier { get; set; } + + public int? Tenant { get; set; } + public virtual Tenant TenantNavigation { get; set; } public virtual ICollection TabularModels { get; set; } - } } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/PowerBiService.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/PowerBiService.cs index 6f37b20..de618f2 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/PowerBiService.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/PowerBiService.cs @@ -8,180 +8,124 @@ using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Logging; using Microsoft.Identity.Client; - +using Newtonsoft.Json.Linq; namespace at.PowerBIUnitTest.Portal.Services { - public class PowerBiService + public class PowerBiService { + private readonly ILogger logger; private readonly string clientId; private readonly string clientSecret; - private readonly ILogger logger; - - public PowerBiService(IConfiguration config, ILogger logger){ + + public PowerBiService(IConfiguration config, ILogger logger) + { + this.logger = logger; this.clientId = config["AzureAd:ClientId"]; this.clientSecret = config["AzureAd:ClientSecret"]; - this.logger = logger; - } - public bool QueryDataset(Guid datasetId, string daxQuery, string authToken, out string jsonResponse) + + public async Task GetTokenOnBehalfOf(Guid msIdTenant, string accessToken) { - logger.LogDebug($"Begin: PowerBIService QueryDataset(datasetId: {datasetId}, daxQuery: {daxQuery})"); + logger.LogDebug($"Begin: PowerBiService GetTokenOnBehalfOf()"); try { - logger.LogDebug("Querying dataset..."); - HttpClient client = new HttpClient(); - client.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", authToken); - - string url = $"https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries"; - - var requestBody = JsonSerializer.Serialize( - new QueryRequest(daxQuery) - ); + logger.LogDebug("Getting token"); + IConfidentialClientApplication PublicClientApp = ConfidentialClientApplicationBuilder.Create(clientId) + .WithClientSecret(clientSecret) + .WithAuthority(AzureCloudInstance.AzurePublic, msIdTenant) + .Build(); + AuthenticationResult authResult = await PublicClientApp.AcquireTokenOnBehalfOf(scopes: new[] { "https://analysis.windows.net/powerbi/api/.default " }, new UserAssertion(accessToken)) + .ExecuteAsync(); - var response = client.PostAsync(url, new StringContent(requestBody, UnicodeEncoding.UTF8, "application/json")).Result; - jsonResponse = response.Content.ReadAsStringAsync().Result; - - var IsSuccessStatusCode = response.IsSuccessStatusCode; - logger.LogDebug($"End: PowerBIService QueryDataset(jsonResponse: {jsonResponse}, Return: {IsSuccessStatusCode})"); - return IsSuccessStatusCode; - + var Token = authResult.AccessToken; + logger.LogDebug($"End: PowerBiService GetTokenOnBehalf( Return: {Token})"); + return Token; } - catch(Exception ex) + catch (Exception ex) { - logger.LogError(ex, "An error occurred while querying the dataset."); + logger.LogError(ex, "An error occured while getting Token"); throw; + } } - public bool ShowValue(Guid datasetId, string daxQuery, string authToken, out string jsonResponse) + public async Task LoadWorkspace(string authToken) { - logger.LogDebug($"Begin: PowerBIService ShowValue(datasetId: {datasetId})"); + logger.LogDebug($"Begin: PowerBiService LoadWorkspace"); try { - logger.LogDebug("Showing Value....."); + logger.LogDebug("Loading Workspace"); HttpClient client = new HttpClient(); - client.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", authToken); - - string url = $"https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries?Monat=Januar"; - - var requestBody = JsonSerializer.Serialize( - new QueryRequest(daxQuery) - ); - + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken); - var response = client.PostAsync(url, new StringContent(requestBody, UnicodeEncoding.UTF8, "application/json")).Result; - jsonResponse = response.Content.ReadAsStringAsync().Result; + string url = $"https://api.powerbi.com/v1.0/myorg/groups"; - var IsSuccessStatusCode = response.IsSuccessStatusCode; - logger.LogDebug($"End: PowerBIService ShowValue(jsonResponse: {jsonResponse}, Return: {IsSuccessStatusCode})"); - return IsSuccessStatusCode; - + var response = await client.GetAsync(url); + var jsonResponse = (await response.Content.ReadAsAsync())["value"]; + logger.LogDebug($"End: PowerBiService LoadWorkspace(return: {jsonResponse})"); + return jsonResponse; } - catch(Exception ex) + catch (Exception ex) { - logger.LogError(ex, "An error occurred while querying the dataset"); + logger.LogError(ex, "An error occurred while loading workspaces"); throw; } } - public bool LoadWorkspace(string authToken, out string jsonResponse) + public async Task LoadDataset(string authToken, Guid datasetId) { - logger.LogDebug($"Begin: PowerBIService LoadWorkspace"); + logger.LogDebug($"Begin: PowerBIService LoadDataset(datasetId: {datasetId})"); try { - logger.LogDebug("Loading Workspace...."); + logger.LogDebug("Loading Dataset"); HttpClient client = new HttpClient(); - client.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", authToken); - - string url = $"https://api.powerbi.com/v1.0/myorg/groups"; - - + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken); + string url = $"https://api.powerbi.com/v1.0/myorg/groups/{datasetId}/datasets"; - var response =client.GetAsync(url).Result; - jsonResponse = response.Content.ReadAsStringAsync().Result; - var IsSuccessStatusCode = response.IsSuccessStatusCode; - logger.LogDebug($"End: PowerBIService LoadWorkspace(jsonResponse: {jsonResponse}, Return: {IsSuccessStatusCode})"); - return IsSuccessStatusCode; + var response = await client.GetAsync(url); + var jsonResponse = (await response.Content.ReadAsAsync())["value"]; + logger.LogDebug($"End: PowerBIService LoadDataset(return: {jsonResponse})"); + return jsonResponse; } - catch(Exception ex) + catch (Exception ex) { - logger.LogError(ex, "An error occurred while loading workspaces"); + logger.LogError(ex, "An error occurred while loading Dataset"); throw; } - } - public bool LoadDataset(string datasetId, string authToken, out string jsonResponse) + public async Task<(string jsonResponse, JObject jObject)> QueryDataset(string authToken, Guid datasetId, string daxQuery) { - logger.LogDebug($"Begin: PowerBIService LoadDataset(datasetId: {datasetId})"); + logger.LogDebug($"Begin: PowerBIService QueryDataset(datasetId: {datasetId}, daxQuery: {daxQuery})"); try { - logger.LogDebug("Loading Dataset...."); - HttpClient client = new HttpClient(); - client.DefaultRequestHeaders.Authorization = - new AuthenticationHeaderValue("Bearer", authToken); + logger.LogDebug("Querying dataset"); + HttpClient client = new HttpClient(); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken); - string url = $"https://api.powerbi.com/v1.0/myorg/groups/{datasetId}/datasets"; + string url = $"https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/executeQueries"; + + var requestBody = JsonSerializer.Serialize( + new QueryRequest(daxQuery) + ); - + var response = await client.PostAsync(url, new StringContent(requestBody, UnicodeEncoding.UTF8, "application/json")); + var jObject = await response.Content.ReadAsAsync(); + var jsonResponse = await response.Content.ReadAsStringAsync(); - var response =client.GetAsync(url).Result; - jsonResponse = response.Content.ReadAsStringAsync().Result; - var IsSuccessStatusCode = response.IsSuccessStatusCode; - logger.LogDebug($"End: PowerBIService LoadDataset(jsonResponse: {jsonResponse}, Return: {IsSuccessStatusCode})"); - return IsSuccessStatusCode; + logger.LogDebug($"End: PowerBIService QueryDataset(jsonResponse: {jsonResponse})"); + + return (jsonResponse, jObject); } - catch(Exception ex) + catch (Exception ex) { - logger.LogError(ex, "An error occurred while loading Dataset"); + logger.LogError(ex, "An error occurred while querying the dataset."); throw; } - } - - - public async Task GetTokenOnBehalfOf(Guid msIdTenant, string accessToken) - { - logger.LogDebug($"Begin: PowerBIService GetTokenOnBehalfOf()"); - try - { - logger.LogDebug("Getting token"); - IConfidentialClientApplication PublicClientApp = ConfidentialClientApplicationBuilder.Create(clientId) - .WithClientSecret(clientSecret) - .WithAuthority(AzureCloudInstance.AzurePublic, msIdTenant) - .Build(); - AuthenticationResult authResult = await PublicClientApp.AcquireTokenOnBehalfOf(scopes: new[] { "https://analysis.windows.net/powerbi/api/.default " }, new UserAssertion(accessToken)) - .ExecuteAsync(); - - var Token = authResult.AccessToken; - logger.LogDebug($"End: PowerBIService GetTokenOnBehalf( Return: {Token})"); - return Token; - } - catch(Exception ex) - { - logger.LogError(ex, "An error occured while getting Token"); - throw; - - } - } - - //public async Task GetOAuthToken(string OAuthToken){ - // IConfidentialClientApplication PublicClientApp = ConfidentialClientApplicationBuilder.Create(clientId) - // .WithClientSecret(clientSecret) - // .WithAuthority(AzureCloudInstance.AzurePublic, "fbfd2005-2cb0-4cea-9c07-d5ad0307112d") - // .Build(); - - //} - - } - - } \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/TabularModelService.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/TabularModelService.cs new file mode 100644 index 0000000..cb3207c --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/TabularModelService.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using at.PowerBIUnitTest.Portal.Data.Models; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; + +namespace at.PowerBIUnitTest.Portal.Services +{ + public class TabularModelService + { + private readonly ILogger logger; + private readonly PortalDbContext dbContext; + private readonly PowerBiService powerBiService; + + public TabularModelService(ILogger logger, PortalDbContext dbContext, PowerBiService powerBiService) + { + this.logger = logger; + this.dbContext = dbContext; + this.powerBiService = powerBiService; + } + + public async Task PullDatasetsFromPowerBi(Guid msIdTenantCurrentUser, string accessToken) + { + logger.LogDebug($"Begin: TabularModelService PullDatasetsFromPowerBi(msIdTenantCurrentUser: {msIdTenantCurrentUser})"); + + var powerBiToken = await powerBiService.GetTokenOnBehalfOf(msIdTenantCurrentUser, accessToken); + + foreach (var workspace in dbContext.Workspaces.Where(e => e.TenantNavigation.MsId == msIdTenantCurrentUser).ToList()) + { + var remoteDatasets = await powerBiService.LoadDataset(powerBiToken, workspace.MsId); + List tabularModels = new List(); + + foreach (var remoteDataset in remoteDatasets) + { + var tabularModel = new TabularModel + { + MsId = remoteDataset["id"].ToObject(), + Name = remoteDataset["name"].ToString(), + Workspace = workspace.Id + }; + tabularModels.Add(tabularModel); + } + + tabularModels.ForEach(e => + { + var dbTabularModel = this.dbContext.TabularModels.FirstOrDefault(t => t.MsId == t.MsId); + + if (dbTabularModel == null) + { + this.dbContext.TabularModels.Add(e); + } + else + { + dbTabularModel.Name = e.Name; + dbTabularModel.Workspace = e.Workspace; + dbContext.Update(dbTabularModel); + } + }); + }; + + await dbContext.SaveChangesAsync(); + + logger.LogDebug($"End: TabularModelService PullDatasetsFromPowerBi(msIdTenantCurrentUser: {msIdTenantCurrentUser})"); + } + } +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/UnitTestService.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/UnitTestService.cs new file mode 100644 index 0000000..9973620 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/UnitTestService.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using at.PowerBIUnitTest.Portal.Data.Models; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; + +namespace at.PowerBIUnitTest.Portal.Services +{ + public class UnitTestService + { + private readonly ILogger logger; + private readonly PortalDbContext dbContext; + private readonly PowerBiService powerBiService; + + public UnitTestService(ILogger logger, PortalDbContext dbContext, PowerBiService powerBiService) + { + this.logger = logger; + this.dbContext = dbContext; + this.powerBiService = powerBiService; + } + + public async Task ExecuteMultipe(Guid msIdTenantCurrentUser, string accessToken, IEnumerable unitTestIds) + { + var powerBiToken = await powerBiService.GetTokenOnBehalfOf(msIdTenantCurrentUser, accessToken); + + var testRuns = new List(); + foreach (var unitTestId in unitTestIds) + { + var testRun = await Execute(powerBiToken, unitTestId); + if (testRun != null) + { + testRuns.Add(testRun); + } + } + + var testRunCollection = new TestRunCollection + { + TimeStamp = DateTime.Now, + TestRuns = testRuns, + WasPassed = testRuns.All(e => e.WasPassed) + }; + + dbContext.TestRunCollections.Add(testRunCollection); + await dbContext.SaveChangesAsync(); + } + + private async Task Execute(string powerBiToken, int unitTestIds) + { + var unitTest = dbContext.UnitTests.FirstOrDefault(e => e.Id == unitTestIds); + if (unitTest == null) + { + logger.LogError($"Unit test with id {unitTestIds} not found"); + return null; + } + + var result = await this.powerBiService.QueryDataset(powerBiToken, unitTest.UserStoryNavigation.TabularModelNavigation.MsId, unitTest.DAX); + string testResult = null; + try + { + testResult = ((result.jObject["results"][0]["tables"][0]["rows"][0] as JObject).First as JProperty).Value.ToString(); + + if (unitTest.ResultType == "Float") + { + float floatResult = float.Parse(testResult); + + if (unitTest.DecimalPlaces != null) + testResult = Math.Round(floatResult, int.Parse(unitTest.DecimalPlaces)).ToString(); + + if (unitTest.FloatSeparators == "Use Seperators") + { + double number = float.Parse(testResult); + testResult = number.ToString("N"); + } + } + else if (unitTest.ResultType == "Date") + { + if (unitTest.DateTimeFormat == "UTC") + { + testResult = DateTime.Parse(testResult).ToUniversalTime().ToString(); + } + + if (unitTest.DateTimeFormat == "CET") + { + testResult = DateTime.Parse(testResult).ToLocalTime().ToString(); + testResult = TimeZoneInfo.ConvertTimeFromUtc(DateTime.Parse(testResult).ToUniversalTime(), TimeZoneInfo.FindSystemTimeZoneById("Central Europe Standard Time")).ToString(); + } + } + else if (unitTest.ResultType == "Percentage") + { + double number = float.Parse(testResult); + testResult = number.ToString("#0.###%"); + } + } + catch (Exception ex) + { + logger.LogError(ex, $"Error while parsing result for unit test {unitTest.Id}"); + } + + var testRun = new TestRun + { + UnitTest = unitTest.Id, + JsonResponse = result.jsonResponse, + Result = testResult ?? null, + TimeStamp = DateTime.Now, + ExecutedSuccessfully = testResult != null, + WasPassed = testResult == unitTest.ExpectedResult, + ExpectedResult = unitTest.ExpectedResult + }; + + return testRun; + } + } +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/WorkspaceService.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/WorkspaceService.cs new file mode 100644 index 0000000..f4fe52e --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Services/WorkspaceService.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using at.PowerBIUnitTest.Portal.Data.Models; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json.Linq; + +namespace at.PowerBIUnitTest.Portal.Services +{ + public class WorkspaceService + { + private readonly ILogger logger; + private readonly PortalDbContext dbContext; + private readonly PowerBiService powerBiService; + + public WorkspaceService(ILogger logger, PortalDbContext dbContext, PowerBiService powerBiService) + { + this.logger = logger; + this.dbContext = dbContext; + this.powerBiService = powerBiService; + } + + public async Task PullWorkspacesFromPowerBi(Guid msIdTenantCurrentUser, string accessToken) + { + logger.LogDebug($"Begin: WorkspaceService PullWorkspacesFromPowerBi(msIdTenantCurrentUser: {msIdTenantCurrentUser})"); + + var powerBiToken = await powerBiService.GetTokenOnBehalfOf(msIdTenantCurrentUser, accessToken); + + var remoteWorkspaces = await powerBiService.LoadWorkspace(powerBiToken); + List workspaces = new List(); + Tenant currentUsersTenant = this.dbContext.Tenants.First(e => e.MsId == msIdTenantCurrentUser); + + foreach (var remoteWorkspace in remoteWorkspaces) + { + var workspace = new Workspace + { + MsId = remoteWorkspace["id"].ToObject(), + Name = remoteWorkspace["name"].ToString(), + Tenant = currentUsersTenant.Id + }; + workspaces.Add(workspace); + } + + workspaces.ForEach(e => + { + var dbWorkspace = this.dbContext.Workspaces.FirstOrDefault(w => w.MsId == e.MsId); + + if (dbWorkspace == null) + { + this.dbContext.Workspaces.Add(e); + } + else + { + dbWorkspace.Name = e.Name; + dbWorkspace.Tenant = e.Tenant; + dbContext.Update(dbWorkspace); + } + }); + + await dbContext.SaveChangesAsync(); + + logger.LogDebug($"End: WorkspaceService PullWorkspacesFromPowerBi(msIdTenantCurrentUser: {msIdTenantCurrentUser})"); + } + } +} \ No newline at end of file diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Startup.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Startup.cs index f556136..64402a6 100644 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Startup.cs +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/Startup.cs @@ -16,10 +16,10 @@ using Microsoft.OData.ModelBuilder; using Microsoft.Net.Http.Headers; using Microsoft.AspNetCore.Http; -using at.PowerBIUnitTest.Portal.Services; using System.Globalization; using Microsoft.AspNetCore.Localization; using System.Collections.Generic; +using at.PowerBIUnitTest.Portal.Services; namespace at.PowerBIUnitTest.Portal { @@ -41,40 +41,17 @@ private static IEdmModel GetEdmModel() builder.EntitySet("UserStories"); builder.EntitySet("Workspaces"); builder.EntitySet("TabularModels"); - builder.EntitySet("Histories"); - builder.EntitySet("TestRuns"); + builder.EntitySet("TestRuns"); + builder.EntitySet("ResultTypes"); + builder.EntitySet("TestRunCollections"); builder.EntityType().Collection.Action("Login"); - builder.EntityType().Collection.Action("Execute"); - builder.EntityType().Collection.Action("LoadWorkspace"); - builder.EntityType().Collection.Action("LoadDataset"); - var SaveTestRun = builder.EntityType().Collection.Action("SaveTestRun"); - SaveTestRun.Parameter("Result"); - SaveTestRun.Parameter("Type"); - SaveTestRun.Parameter("Count"); - SaveTestRun.Parameter("Name"); - builder.EntityType().Collection.Action("FilterWorkspace"); + builder.EntityType().Collection.Action("Pull"); + + builder.EntityType().Collection.Action("Execute").CollectionParameter("unitTestIds"); var copyUserStory = builder.EntityType().Action("Copy"); copyUserStory.Parameter("targetTabularModelId"); - var copy = builder.EntityType().Action("Copy2"); - copy.Parameter("targetTabularModelId1"); - copy.Parameter("targetWorkspaceId1"); - copy.Parameter("userStoryId1"); - - // var executeAction = builder.Function("Execute"); - //executeAction.Parameter("unitTestToExecute"); - //executeAction.ReturnsFromEntitySet("UnitTests"); - - //var execute = - //builder.EntityType() - // .Collection - //.Action("Execute"); - - - //execute.Parameter("id").Required(); - //execute.Returns(); - return builder.GetEdmModel(); } @@ -95,14 +72,16 @@ public void ConfigureServices(IServiceCollection services) services.AddDbContext(options => options.UseLazyLoadingProxies().UseSqlServer(Configuration.GetConnectionString("AzureDbConnection"))); - services.AddControllers().AddOData(options => options.AddRouteComponents("odata", GetEdmModel()).Select().Count().Filter().OrderBy().Expand().SetMaxTop(100)); + services.AddControllers(options => { options.Filters.Add(); }).AddOData(options => options.AddRouteComponents("odata", GetEdmModel()).Select().Count().Filter().OrderBy().Expand().SetMaxTop(100)); services.AddSwaggerGen(); services.AddSingleton(); services.AddScoped(); - + services.AddScoped(); + services.AddScoped(); + services.AddScoped(); } @@ -128,7 +107,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, PortalDb app.UseDeveloperExceptionPage(); } else - { + { dbContext.Database.MigrateAsync(); app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/UnhandledExceptionFilterAttribute .cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/UnhandledExceptionFilterAttribute .cs new file mode 100644 index 0000000..b4e18b1 --- /dev/null +++ b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/UnhandledExceptionFilterAttribute .cs @@ -0,0 +1,18 @@ + +using System.Net; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.OData; + +public class UnhandledExceptionFilterAttribute : ExceptionFilterAttribute +{ + public override void OnException(ExceptionContext context) + { + var e = context.Exception; + + if(e.InnerException != null) + context.Result = new ObjectResult(new ODataError { ErrorCode = "500", Message = e.Message, InnerError = new ODataInnerError(e.InnerException) }) { StatusCode = (int)HttpStatusCode.InternalServerError }; + else + context.Result = new ObjectResult(new ODataError { ErrorCode = "500", Message = e.Message }) { StatusCode = (int)HttpStatusCode.InternalServerError }; + } +} diff --git a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/testclass.cs b/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/testclass.cs deleted file mode 100644 index 5031d2e..0000000 --- a/at.PowerBIUnitTest.Portal/at.PowerBIUnitTest.Portal/testclass.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; -namespace at.PowerBIUnitTest.Portal{ -public class testclass -{ - [Fact] - public void PassingAddTest(){ - Assert.Equal(4,Adds.Add(2,2)); - - -} - - - -} -} \ No newline at end of file