Esempio n. 1
0
        public static void GenerateDatabase()
        {
            List <ClientData> clients = new List <ClientData>();

            for (int i = 0; i < 10; i++)
            {
                ClientData   data         = new ClientData();
                LicensePlate licensePlate = new LicensePlate();
                ParkClient   parkClient   = new ParkClient();
                data.LicenseNumber      = licensePlate.GenerateLicensePlate().LicenseNumber;
                data.CompanyParkingCode = parkClient.GenerateParkingCode();
                clients.Add(data);
            }
            foreach (ClientData data in clients)
            {
                CreateParkClient(data);
            }
        }
Esempio n. 2
0
        public static ParkClient ReadParkClient(string licenseNumber)
        {
            ParkClient   parkClient   = new ParkClient();
            LicensePlate licensePlate = new LicensePlate();

            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConString("ParkingDatabase")))
            {
                try
                {
                    licensePlate = connection.QuerySingle <LicensePlate>("SELECT * FROM LicensePlates WHERE LicenseNumber = @LicenseNumber", new { @LicenseNumber = licenseNumber });
                }
                catch (InvalidOperationException)
                {
                    throw;
                }
                licensePlate            = connection.QuerySingle <LicensePlate>("SELECT * FROM LicensePlates WHERE LicenseNumber = @LicenseNumber", new { @LicenseNumber = licenseNumber });
                parkClient              = connection.QuerySingle <ParkClient>("SELECT * FROM ParkClients WHERE ParkClientID = @ParkClientIDKey", new { @ParkClientIDKey = licensePlate.ParkClientIDKey });
                parkClient.LicensePlate = licensePlate;
                return(parkClient);
            }
        }