Exemple #1
0
    private static Attendance MapAttendance(TestData.TestData data, IImmutableList <Location> locations)
    {
        var location = locations.Single(predicate: l => l.CheckInsLocationId == (long)data.TestLocation);

        return(new()
        {
            CheckInsId = data.CheckInsId,
            LocationId = location.Id,
            SecurityCode = data.SecurityCode,
            AttendanceTypeId = (int)data.AttendanceType + 1,
            InsertDate = DateTime.UtcNow,
            CheckInDate = null,
            CheckOutDate = null
        });
    }
Exemple #2
0
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Owners",
                columns: table => new
            {
                id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                name   = table.Column <string>(nullable: true),
                age    = table.Column <int>(nullable: false),
                adress = table.Column <string>(nullable: true)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Owners", x => x.id);
            });

            migrationBuilder.CreateTable(
                name: "Cars",
                columns: table => new
            {
                id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                regnr        = table.Column <string>(nullable: true),
                CarOfOwnerId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Cars", x => x.id);
                table.ForeignKey(
                    name: "FK_Cars_Owners_CarOfOwnerId",
                    column: x => x.CarOfOwnerId,
                    principalTable: "Owners",
                    principalColumn: "id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateTable(
                name: "Tolls",
                columns: table => new
            {
                id = table.Column <int>(nullable: false)
                     .Annotation("SqlServer:Identity", "1, 1"),
                date         = table.Column <DateTime>(nullable: false),
                currentCarId = table.Column <int>(nullable: false)
            },
                constraints: table =>
            {
                table.PrimaryKey("PK_Tolls", x => x.id);
                table.ForeignKey(
                    name: "FK_Tolls_Cars_currentCarId",
                    column: x => x.currentCarId,
                    principalTable: "Cars",
                    principalColumn: "id",
                    onDelete: ReferentialAction.Cascade);
            });

            migrationBuilder.CreateIndex(
                name: "IX_Cars_CarOfOwnerId",
                table: "Cars",
                column: "CarOfOwnerId",
                unique: true);

            migrationBuilder.CreateIndex(
                name: "IX_Tolls_currentCarId",
                table: "Tolls",
                column: "currentCarId");

            /* Randomize Test Data */
            var testData = new TestData.TestData();

            testData.insertTestData(migrationBuilder);
        }