nikitrifonovprojects / Datebase-Access

0 stars 0 forks source link

Create list commands for car #32

Closed iliantrifonov closed 6 years ago

iliantrifonov commented 6 years ago

Create two commands. One for the short form on the main page, and one for the advanced.

iliantrifonov commented 6 years ago

Rename SearchTypeEnum to SearchEnum (and if you have other similar namings, move them to this convention) Make a default constructor for all searches, that uses a SearchType.Equals as default. CarMakeIdSearch and CarModelIdSearch create additional constructors that take only int, and give it to the other constructor as List { value }. ShortSearchCarModel - Change CarMake and CarModel to int instead of List. Rename them to CarMakeId and CarModelId and make them nullable

Move IsLeftSteering to be an extra. Remove it from the DB table and from the models/queries.

Change CarConditionSearch and CarConditionWhere so they do not use a dictionary, but instead give them nullable boolean variables for IsForParts and IsUsed

AdvancedSearchCarModel - Rename CarModel and CarMake to CarModelIds and CarMakeIds. Rename IncludedExtras to IncludedExtraIds and ExcludedExtras to ExcludedExtraIds. Rename CarGearBox to CarGearBoxId. Remove IsLeftSteering.

Rename all {SOMETHING}Type to {Something}Enum where you have enumerations for consistency.

Change ShortSearchCarCommand and AdvancedSearchCarCommand so they use Linq instead of foreach. If you have default/null initializations for no reason, move them so they directly get assigned instead. Same goes for empty list initializations that get overridden.

Also if the searches return no results, just return an empty list. Do not return NotFound as that is an error condition. Make all services in a way so they dispose their repositories (UserService and CarService). Test them to make sure multiple dispose calls do not cause errors, and if they do, make sure to dispose repos only once.

Rename constants so they have underscores.

CarRepository - Make the Map method to include all properties of the inner types. Make the Map method take Includes and use them.

CarRepository - Use the table name and constants for columns to construct the select. This will help for refactoring in future.

CarRepository - ProcessCarExtras is not joining tables correctly. Fix and retest.

Use constants in Where's and OrderBy's for table names and columns.