7.6 KiB
Plan: Add ApkType to AndroidApkVersion for WebView and FaceDetection separation
Overview
The user wants to integrate the ApkType enum (WebView/FaceDetection) into the AndroidApkVersion entity to distinguish between the two different APK types. Currently, all APKs are treated as WebView. The system needs to be updated to support both types with separate handling.
Steps
1. Update AndroidApkVersion.cs domain entity
File: Company.Domain\AndroidApkVersionAgg\AndroidApkVersion.cs
- Add
ApkTypeproperty to the class - Update constructor to accept
ApkTypeparameter - Modify
Titleproperty generation to include APK type information - Update the constructor logic to handle both WebView and FaceDetection types
2. Update AndroidApkVersionMapping.cs EF configuration
File: CompanyManagment.EFCore\Mapping\AndroidApkVersionMapping.cs
- Add mapping configuration for
ApkTypeproperty - Use enum-to-string conversion (similar to existing
IsActivemapping) - Set appropriate column max length for the enum value
3. Create database migration
Files: Generated migration files in CompanyManagment.EFCore\Migrations\
- Generate new migration to add
ApkTypecolumn toAndroidApkVersionstable - Set default value to
ApkType.WebViewfor existing records - Apply migration to update database schema
4. Update IAndroidApkVersionRepository.cs interface
File: Company.Domain\AndroidApkVersionAgg\IAndroidApkVersionRepository.cs
- Modify
GetActives()to acceptApkTypeparameter for filtering - Modify
GetLatestActiveVersionPath()to acceptApkTypeparameter - Add methods to handle type-specific queries
5. Update AndroidApkVersionRepository.cs implementation
File: CompanyManagment.EFCore\Repository\AndroidApkVersionRepository.cs
- Implement type-based filtering in
GetActives()method - Implement type-based filtering in
GetLatestActiveVersionPath()method - Add appropriate WHERE clauses to filter by
ApkType
6. Update IAndroidApkVersionApplication.cs interface
File: CompanyManagment.App.Contracts\AndroidApkVersion\IAndroidApkVersionApplication.cs
- Add
ApkTypeparameter toCreateAndActive()method - Add
ApkTypeparameter toCreateAndDeActive()method - Add
ApkTypeparameter toGetLatestActiveVersionPath()method - Add
ApkTypeparameter toHasAndroidApkToDownload()method
7. Update AndroidApkVersionApplication.cs implementation
File: CompanyManagment.Application\AndroidApkVersionApplication.cs
-
Update
CreateAndActive()method:- Accept
ApkTypeparameter - Change storage path from hardcoded "GozreshgirWebView" to dynamic based on type
- Use "GozreshgirWebView" for
ApkType.WebView - Use "GozreshgirFaceDetection" for
ApkType.FaceDetection - Pass
ApkTypeto repository methods when getting/deactivating existing APKs - Pass
ApkTypeto entity constructor
- Accept
-
Update
CreateAndDeActive()method:- Accept
ApkTypeparameter - Update storage path logic similar to
CreateAndActive() - Pass
ApkTypeto entity constructor
- Accept
-
Update
GetLatestActiveVersionPath()method:- Accept
ApkTypeparameter - Pass type to repository method
- Accept
-
Update
HasAndroidApkToDownload()method:- Accept
ApkTypeparameter - Filter by type when checking for active APKs
- Accept
8. Update AndroidApk.cs controller
File: ServiceHost\Pages\Apk\AndroidApk.cs
- Modify the download endpoint to accept
ApkTypeparameter - Options:
- Add query string parameter:
/Apk/Android?type=WebViewor/Apk/Android?type=FaceDetection - Create separate routes:
/Apk/Android/WebViewand/Apk/Android/FaceDetection
- Add query string parameter:
- Pass the type parameter to
GetLatestActiveVersionPath()method - Maintain backward compatibility by defaulting to
ApkType.WebViewif no type specified
9. Update admin UI Index.cshtml.cs
File: ServiceHost\Areas\AdminNew\Pages\Company\AndroidApk\Index.cshtml.cs
- Add property to store selected
ApkType - Add
[BindProperty]for ApkType selection - Modify
OnPostUpload()to pass selectedApkTypeto application method - Create corresponding UI changes in Index.cshtml (if exists) to allow type selection
10. Update client-facing pages
Files:
-
ServiceHost\Pages\login\Index.cshtml.cs -
ServiceHost\Areas\Client\Pages\Index.cshtml.cs -
Update calls to
HasAndroidApkToDownload()to specify which APK type to check -
Consider showing different download buttons/links for WebView vs FaceDetection apps
-
Update download links to include APK type parameter
Migration Strategy
Handling Existing Data
- All existing
AndroidApkVersionrecords should be marked asApkType.WebViewby default - Use migration to set default value
- No manual data update required if migration includes default value
Database Schema Change
ALTER TABLE AndroidApkVersions
ADD ApkType NVARCHAR(20) NOT NULL DEFAULT 'WebView';
UI Design Considerations
Admin Upload Page
Recommended approach: Single form with radio buttons or dropdown
- Add radio buttons or dropdown to select APK type before upload
- Labels: "WebView Application" and "Face Detection Application"
- Group uploads by type in the list/table view
- Show type column in the APK list
Client Download Pages
Recommended approach: Separate download buttons
- Show "Download Gozareshgir WebView" button (existing functionality)
- Show "Download Gozareshgir FaceDetection" button (new functionality)
- Only show buttons if corresponding APK type is available
- Use different icons or colors to distinguish between types
Download URL Structure
Recommended approach: Single endpoint with query parameter
- Current:
/Apk/Android(defaults to WebView for backward compatibility) - New WebView:
/Apk/Android?type=WebView - New FaceDetection:
/Apk/Android?type=FaceDetection
Alternative approach: Separate endpoints
/Apk/Android/WebView/Apk/Android/FaceDetection
Testing Checklist
- ✅ Upload WebView APK successfully
- ✅ Upload FaceDetection APK successfully
- ✅ Both types can coexist in database
- ✅ Activating WebView APK doesn't affect FaceDetection APK
- ✅ Activating FaceDetection APK doesn't affect WebView APK
- ✅ Download correct APK based on type parameter
- ✅ Admin UI shows type information correctly
- ✅ Client pages show correct download availability
- ✅ Backward compatibility maintained (existing links still work)
- ✅ Migration applies successfully to existing database
File Summary
Files to modify:
Company.Domain\AndroidApkVersionAgg\AndroidApkVersion.csCompanyManagment.EFCore\Mapping\AndroidApkVersionMapping.csCompany.Domain\AndroidApkVersionAgg\IAndroidApkVersionRepository.csCompanyManagment.EFCore\Repository\AndroidApkVersionRepository.csCompanyManagment.App.Contracts\AndroidApkVersion\IAndroidApkVersionApplication.csCompanyManagment.Application\AndroidApkVersionApplication.csServiceHost\Pages\Apk\AndroidApk.csServiceHost\Areas\AdminNew\Pages\Company\AndroidApk\Index.cshtml.csServiceHost\Pages\login\Index.cshtml.csServiceHost\Areas\Client\Pages\Index.cshtml.cs
Files to create:
- New migration file (auto-generated)
- Possibly
ServiceHost\Areas\AdminNew\Pages\Company\AndroidApk\Index.cshtml(if doesn't exist)
Notes
- The
ApkTypeenum is already defined inAndroidApkVersion.cs - Storage folders will be separate:
Storage/Apk/Android/GozreshgirWebViewandStorage/Apk/Android/GozreshgirFaceDetection - Each APK type maintains its own active/inactive state independently
- Consider adding validation to ensure APK file matches selected type (optional enhancement)