public void DriverResultDTO_Test()
        {
            // Act
            DriverResultDTO driverResultDTO  = Mapper.Map <DriverResultDTO>(driverResult);
            DriverResult    testDriverResult = Mapper.Map <DriverResult>(driverResultDTO);

            // Assert
            Assert.AreEqual(driverResult.Id, driverResultDTO.Id);
            Assert.AreEqual(driverResult.BestLapTime, driverResultDTO.BestLapTime);
            Assert.AreEqual(driverResult.CarId, driverResultDTO.CarId);
            Assert.AreEqual(driverResult.ControllerNumber, driverResultDTO.ControllerNumber);
            Assert.AreEqual(driverResult.ApplicationUserId, driverResultDTO.DriverId);
            Assert.AreEqual(driverResult.Finished, driverResultDTO.Finished);
            Assert.AreEqual(driverResult.Fuel, driverResultDTO.Fuel);
            Assert.AreEqual(driverResult.Laps, driverResultDTO.Laps);
            Assert.AreEqual(driverResult.Position, driverResultDTO.Position);
            Assert.AreEqual(driverResult.RaceSessionId, driverResultDTO.RaceSessionId);
            Assert.AreEqual(driverResult.TimeOffPace, driverResultDTO.TimeOffPace);
            Assert.AreEqual(driverResult.TotalTime, driverResultDTO.TotalTime);

            Assert.AreEqual(driverResult.Id, testDriverResult.Id);
            Assert.AreEqual(driverResult.BestLapTime, testDriverResult.BestLapTime);
            Assert.AreEqual(driverResult.CarId, testDriverResult.CarId);
            Assert.AreEqual(driverResult.ControllerNumber, testDriverResult.ControllerNumber);
            Assert.AreEqual(driverResult.ApplicationUserId, testDriverResult.ApplicationUserId);
            Assert.AreEqual(driverResult.Finished, testDriverResult.Finished);
            Assert.AreEqual(driverResult.Fuel, testDriverResult.Fuel);
            Assert.AreEqual(driverResult.Laps, testDriverResult.Laps);
            Assert.AreEqual(driverResult.Position, testDriverResult.Position);
            Assert.AreEqual(driverResult.RaceSessionId, testDriverResult.RaceSessionId);
            Assert.AreEqual(driverResult.TimeOffPace, testDriverResult.TimeOffPace);
            Assert.AreEqual(driverResult.TotalTime, testDriverResult.TotalTime);
        }
            public async Task <IHttpActionResult> PostDriverResult(DriverResultDTO driverResultDTO)
            {
                DriverResult driverResult = Mapper.Map <DriverResult>(driverResultDTO);

                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                driverResult = await repo.Insert(driverResult);

                // Remove this driver from registered drivers
                DriversRepository <Driver, DriverDTO> driversRepo = new DriversRepository <Driver, DriverDTO>();
                Driver driver = driversRepo.GetForUser(driverResult.ApplicationUserId);

                if (driver != null)
                {
                    await driversRepo.Delete(driver.Id);
                }

                return(CreatedAtRoute("DefaultApi", new { id = driverResult.Id }, Mapper.Map <DriverResultDTO>(driverResult)));
            }