sequenceDiagram
participant u as Browser
participant az as AuthN/AuthZ<br>(Entry Point)
participant e as VehicleMarketPlaceEntryPoint<br>(Entry Point)
participant vpm as VehicleMarketPlaceManager<br>(Manager Layer)
participant vps as RequestVehicleMarketValueService<br>(Services Layer)
participant ll as LogService<br>(Services Layer)
participant dg as SqlDbVehicleTarget<br>(Data Gateway)
participant da as SqlServerDAO<br>(Data Access Object)
participant ds as Data Store<br>(Sql Server)

Note Left of u: User attempts to to create new vehicle profile
u->>+az: CheckToken() 
    Note over u,az: *Temporary method signature*<br>Browser checks for<br>authorized access to the page.<br>See authorization success case
az-->>-u: Return valid check

u->>+e: RequestVehicleMarketValue() : IActionResult
    Note over u,e: Invoked when user accepts inputs for all fields to<br>Create VehicleProfile

    e->>+vpm:  RequestVehicleMarketValue(vin: string, licensePlate: string, make: string, model: string, year: int, color: string, description: string, userAccont: IUserAccount) : IResponse
        Note over e,vpm: Entry point calls upon manager<br>to create vehicle profiles
        
        vpm->>vpm: Validate Parameters

        vpm->>+vps:  RequestVehicleMarketValue(vin: string, licensePlate: string, make: string, model: string, year: int, color: string, description: string, userAccount: IUserAccount) : IResponse
            Note over vpm,vps: VehicleProfileManager calls upon<br>VehicleProfileCreationService to create the vehicle

            vps->>vps: Validate Parameters

            # Use api to search for other details on the vehicle
            vps->>vps: HttpCleint.SendAsync(request: HttpRequestMessage) : Task<HttpResponseMessage>
                Note over vps,vps: Requests information from API using the vin of the vehicle

            # Create default IPublicVehicleProfileDetails object

            # Send to data store
            vps->>+dg: UpateMarketValueSql(VIN: string, price: int) : IResponse
                Note over vps,dg: VehicleProfileCreationService calls upon SqlDbVechileTarget to generate<br>the sql statement and parameters

                dg->>+da: ExecuteWriteSQL(sqlCommands: ICollection<KeyValuePair<sql: string, sqlParameters: HashSet<SqlParameter>>>) : int
                    Note over dg,da: SqlServerUserTarget calls upon<br>SqlServerDAO to execute the sql

                    da->>+ds: SqlCommand.ExecuteNonQuery() : Int
                        Note over da,ds: SqlServerDAO calls upon<br>`SqlCommand.ExecuteNonQuery()`<br>to execute the sql command

                        ds->>ds: INSERT INTO MarketplaceStatus (VIN, Price)<br>VALUES (@VIN, @Price)

                        ds->>ds: Vehicle profile is successfully<br>written to the Data Store

                    ds-->>-da: Database returns the number of rows affected

                    da->>da: Check for thrown exceptions

                da-->>-dg: SqlServerDAO returns the number of rows affected

                dg->>dg: SqlDbVehicleTarget checks to see that one and only one row was affected

            dg-->>-vps: IResponse object returned with<br>`IResponse.HasError` equal to false

            vps->>vps: Check for errors in IResponseObject

            # Log successful vehicle creation
            vps-->>ll: CreateLogAsync(logLevel: string, logCategory: string, logContext: string, userHash: string) : IResponse
                Note over vps,ll: VehicleProfileCreationService calls upon LogService to log<br>successful creation of vehicle profile.<br>See logging success case

        vps-->>-vpm: IResponse object returned

        vpm->>vpm: Check for errors in returned IResponse object

        vpm->>vpm: Check for violation of business rules

        # Log successful vehicle creation
        vpm-->>ll: CreateLogAsync(logLevel: string, logCategory: string, logContext: string, userHash: string) : IResponse
            Note over vpm,ll: VehicleProfileManager calls upon LogService to log<br>successful creation of vehicle profile.<br>See logging success case

    vpm-->>-e: IResponse object returned

    e->>e: Check for errors in returned IResponse object

    e->>e: Inject success into HTML
e-->>-u: Return OK IActionResult