├── Resources
├── Images
│ ├── user.png
│ ├── clear.png
│ ├── search.png
│ └── dotnet_bot.svg
├── Fonts
│ ├── OpenSans-Regular.ttf
│ └── OpenSans-Semibold.ttf
├── AppIcon
│ ├── appicon.svg
│ └── appiconfg.svg
├── Raw
│ └── AboutAssets.txt
├── Splash
│ └── splash.svg
└── Styles
│ ├── Colors.xaml
│ └── Styles.xaml
├── Properties
└── launchSettings.json
├── App.xaml.cs
├── Platforms
├── Android
│ ├── Resources
│ │ └── values
│ │ │ └── colors.xml
│ ├── MainApplication.cs
│ ├── AndroidManifest.xml
│ └── MainActivity.cs
├── iOS
│ ├── AppDelegate.cs
│ ├── Program.cs
│ └── Info.plist
├── MacCatalyst
│ ├── AppDelegate.cs
│ ├── Program.cs
│ └── Info.plist
├── Windows
│ ├── App.xaml
│ ├── app.manifest
│ ├── App.xaml.cs
│ └── Package.appxmanifest
└── Tizen
│ ├── Main.cs
│ └── tizen-manifest.xml
├── AppShell.xaml.cs
├── Views
├── AddUpdateStudentDetail.xaml.cs
├── StudentListPage.xaml.cs
├── AddUpdateStudentDetail.xaml
└── StudentListPage.xaml
├── AppShell.xaml
├── MainPage.xaml.cs
├── Services
├── IStudentService.cs
└── StudentService.cs
├── Models
└── StudentModel.cs
├── App.xaml
├── MauiProgram.cs
├── SQLiteDemo.sln
├── SearchHandlers
└── StudentSearchHandler.cs
├── MainPage.xaml
├── ViewModels
├── AddUpdateStudentDetailViewModel.cs
└── StudentListPageViewModel.cs
├── .gitattributes
├── SQLiteDemo.csproj
└── .gitignore
/Resources/Images/user.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mistrypragnesh40/SQLiteDemoMAUI/HEAD/Resources/Images/user.png
--------------------------------------------------------------------------------
/Resources/Images/clear.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mistrypragnesh40/SQLiteDemoMAUI/HEAD/Resources/Images/clear.png
--------------------------------------------------------------------------------
/Resources/Images/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mistrypragnesh40/SQLiteDemoMAUI/HEAD/Resources/Images/search.png
--------------------------------------------------------------------------------
/Resources/Fonts/OpenSans-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mistrypragnesh40/SQLiteDemoMAUI/HEAD/Resources/Fonts/OpenSans-Regular.ttf
--------------------------------------------------------------------------------
/Resources/Fonts/OpenSans-Semibold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mistrypragnesh40/SQLiteDemoMAUI/HEAD/Resources/Fonts/OpenSans-Semibold.ttf
--------------------------------------------------------------------------------
/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "Windows Machine": {
4 | "commandName": "MsixPackage",
5 | "nativeDebugging": false
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SQLiteDemo;
2 |
3 | public partial class App : Application
4 | {
5 | public App()
6 | {
7 | InitializeComponent();
8 |
9 | MainPage = new AppShell();
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Platforms/Android/Resources/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #512BD4
4 | #2B0B98
5 | #2B0B98
6 |
--------------------------------------------------------------------------------
/Resources/AppIcon/appicon.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Platforms/iOS/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace SQLiteDemo;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
10 |
--------------------------------------------------------------------------------
/Platforms/MacCatalyst/AppDelegate.cs:
--------------------------------------------------------------------------------
1 | using Foundation;
2 |
3 | namespace SQLiteDemo;
4 |
5 | [Register("AppDelegate")]
6 | public class AppDelegate : MauiUIApplicationDelegate
7 | {
8 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9 | }
10 |
--------------------------------------------------------------------------------
/AppShell.xaml.cs:
--------------------------------------------------------------------------------
1 | using SQLiteDemo.Views;
2 |
3 | namespace SQLiteDemo;
4 |
5 | public partial class AppShell : Shell
6 | {
7 | public AppShell()
8 | {
9 | InitializeComponent();
10 |
11 | Routing.RegisterRoute(nameof(AddUpdateStudentDetail), typeof(AddUpdateStudentDetail));
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Platforms/Windows/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Views/AddUpdateStudentDetail.xaml.cs:
--------------------------------------------------------------------------------
1 | using SQLiteDemo.ViewModels;
2 |
3 | namespace SQLiteDemo.Views;
4 |
5 | public partial class AddUpdateStudentDetail : ContentPage
6 | {
7 | public AddUpdateStudentDetail(AddUpdateStudentDetailViewModel viewModel)
8 | {
9 | InitializeComponent();
10 | this.BindingContext = viewModel;
11 | }
12 | }
--------------------------------------------------------------------------------
/Platforms/Tizen/Main.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Microsoft.Maui;
3 | using Microsoft.Maui.Hosting;
4 |
5 | namespace SQLiteDemo;
6 |
7 | class Program : MauiApplication
8 | {
9 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
10 |
11 | static void Main(string[] args)
12 | {
13 | var app = new Program();
14 | app.Run(args);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Platforms/Android/MainApplication.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Runtime;
3 |
4 | namespace SQLiteDemo;
5 |
6 | [Application]
7 | public class MainApplication : MauiApplication
8 | {
9 | public MainApplication(IntPtr handle, JniHandleOwnership ownership)
10 | : base(handle, ownership)
11 | {
12 | }
13 |
14 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
15 | }
16 |
--------------------------------------------------------------------------------
/Platforms/iOS/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace SQLiteDemo;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Platforms/MacCatalyst/Program.cs:
--------------------------------------------------------------------------------
1 | using ObjCRuntime;
2 | using UIKit;
3 |
4 | namespace SQLiteDemo;
5 |
6 | public class Program
7 | {
8 | // This is the main entry point of the application.
9 | static void Main(string[] args)
10 | {
11 | // if you want to use a different Application Delegate class from "AppDelegate"
12 | // you can specify it here.
13 | UIApplication.Main(args, null, typeof(AppDelegate));
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/Platforms/Android/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Platforms/Android/MainActivity.cs:
--------------------------------------------------------------------------------
1 | using Android.App;
2 | using Android.Content.PM;
3 | using Android.OS;
4 |
5 | namespace SQLiteDemo;
6 |
7 | [Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
8 | public class MainActivity : MauiAppCompatActivity
9 | {
10 | }
11 |
--------------------------------------------------------------------------------
/AppShell.xaml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/MainPage.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SQLiteDemo;
2 |
3 | public partial class MainPage : ContentPage
4 | {
5 | int count = 0;
6 |
7 | public MainPage()
8 | {
9 | InitializeComponent();
10 | }
11 |
12 | private void OnCounterClicked(object sender, EventArgs e)
13 | {
14 | count++;
15 |
16 | if (count == 1)
17 | CounterBtn.Text = $"Clicked {count} time";
18 | else
19 | CounterBtn.Text = $"Clicked {count} times";
20 |
21 | SemanticScreenReader.Announce(CounterBtn.Text);
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Services/IStudentService.cs:
--------------------------------------------------------------------------------
1 | using SQLiteDemo.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SQLiteDemo.Services
9 | {
10 | public interface IStudentService
11 | {
12 | Task> GetStudentList();
13 | Task AddStudent(StudentModel studentModel);
14 | Task DeleteStudent(StudentModel studentModel);
15 | Task UpdateStudent(StudentModel studentModel);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Views/StudentListPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using SQLiteDemo.ViewModels;
2 |
3 | namespace SQLiteDemo.Views;
4 |
5 | public partial class StudentListPage : ContentPage
6 | {
7 | private StudentListPageViewModel _viewMode;
8 | public StudentListPage(StudentListPageViewModel viewModel)
9 | {
10 | InitializeComponent();
11 | _viewMode = viewModel;
12 | this.BindingContext = viewModel;
13 | }
14 |
15 | protected override void OnAppearing()
16 | {
17 | base.OnAppearing();
18 | _viewMode.GetStudentListCommand.Execute(null);
19 | }
20 | }
--------------------------------------------------------------------------------
/Models/StudentModel.cs:
--------------------------------------------------------------------------------
1 | using SQLite;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SQLiteDemo.Models
9 | {
10 | public class StudentModel
11 | {
12 | [PrimaryKey, AutoIncrement]
13 | public int StudentID { get; set; }
14 | public string FirstName { get; set; }
15 | public string LastName { get; set; }
16 | public string Email { get; set; }
17 | [Ignore]
18 | public string FullName => $"{FirstName} {LastName}";
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/App.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Resources/Raw/AboutAssets.txt:
--------------------------------------------------------------------------------
1 | Any raw assets you want to be deployed with your application can be placed in
2 | this directory (and child directories). Deployment of the asset to your application
3 | is automatically handled by the following `MauiAsset` Build Action within your `.csproj`.
4 |
5 |
6 |
7 | These files will be deployed with you package and will be accessible using Essentials:
8 |
9 | async Task LoadMauiAsset()
10 | {
11 | using var stream = await FileSystem.OpenAppPackageFileAsync("AboutAssets.txt");
12 | using var reader = new StreamReader(stream);
13 |
14 | var contents = reader.ReadToEnd();
15 | }
16 |
--------------------------------------------------------------------------------
/Platforms/Tizen/tizen-manifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | appicon.xhigh.png
7 |
8 |
9 |
10 |
11 | http://tizen.org/privilege/internet
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/Platforms/Windows/app.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
11 | true/PM
12 | PerMonitorV2, PerMonitor
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/Platforms/Windows/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.UI.Xaml;
2 |
3 | // To learn more about WinUI, the WinUI project structure,
4 | // and more about our project templates, see: http://aka.ms/winui-project-info.
5 |
6 | namespace SQLiteDemo.WinUI;
7 |
8 | ///
9 | /// Provides application-specific behavior to supplement the default Application class.
10 | ///
11 | public partial class App : MauiWinUIApplication
12 | {
13 | ///
14 | /// Initializes the singleton application object. This is the first line of authored code
15 | /// executed, and as such is the logical equivalent of main() or WinMain().
16 | ///
17 | public App()
18 | {
19 | this.InitializeComponent();
20 | }
21 |
22 | protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/Platforms/MacCatalyst/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | UIDeviceFamily
6 |
7 | 1
8 | 2
9 |
10 | UIRequiredDeviceCapabilities
11 |
12 | arm64
13 |
14 | UISupportedInterfaceOrientations
15 |
16 | UIInterfaceOrientationPortrait
17 | UIInterfaceOrientationLandscapeLeft
18 | UIInterfaceOrientationLandscapeRight
19 |
20 | UISupportedInterfaceOrientations~ipad
21 |
22 | UIInterfaceOrientationPortrait
23 | UIInterfaceOrientationPortraitUpsideDown
24 | UIInterfaceOrientationLandscapeLeft
25 | UIInterfaceOrientationLandscapeRight
26 |
27 | XSAppIconAssets
28 | Assets.xcassets/appicon.appiconset
29 |
30 |
31 |
--------------------------------------------------------------------------------
/MauiProgram.cs:
--------------------------------------------------------------------------------
1 | using SQLiteDemo.Services;
2 | using SQLiteDemo.ViewModels;
3 | using SQLiteDemo.Views;
4 |
5 | namespace SQLiteDemo;
6 |
7 | public static class MauiProgram
8 | {
9 | public static MauiApp CreateMauiApp()
10 | {
11 | var builder = MauiApp.CreateBuilder();
12 | builder
13 | .UseMauiApp()
14 | .ConfigureFonts(fonts =>
15 | {
16 | fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
17 | fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
18 | });
19 |
20 | // Services
21 | builder.Services.AddSingleton();
22 |
23 |
24 | //Views Registration
25 | builder.Services.AddSingleton();
26 | builder.Services.AddTransient();
27 |
28 |
29 | //View Modles
30 | builder.Services.AddSingleton();
31 | builder.Services.AddTransient();
32 |
33 |
34 | return builder.Build();
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/Platforms/iOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | LSRequiresIPhoneOS
6 |
7 | UIDeviceFamily
8 |
9 | 1
10 | 2
11 |
12 | UIRequiredDeviceCapabilities
13 |
14 | arm64
15 |
16 | UISupportedInterfaceOrientations
17 |
18 | UIInterfaceOrientationPortrait
19 | UIInterfaceOrientationLandscapeLeft
20 | UIInterfaceOrientationLandscapeRight
21 |
22 | UISupportedInterfaceOrientations~ipad
23 |
24 | UIInterfaceOrientationPortrait
25 | UIInterfaceOrientationPortraitUpsideDown
26 | UIInterfaceOrientationLandscapeLeft
27 | UIInterfaceOrientationLandscapeRight
28 |
29 | XSAppIconAssets
30 | Assets.xcassets/appicon.appiconset
31 |
32 |
33 |
--------------------------------------------------------------------------------
/SQLiteDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.0.31611.283
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLiteDemo", "SQLiteDemo.csproj", "{93DACE04-044B-465B-9053-44CE20BC2CB6}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {93DACE04-044B-465B-9053-44CE20BC2CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {93DACE04-044B-465B-9053-44CE20BC2CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {93DACE04-044B-465B-9053-44CE20BC2CB6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17 | {93DACE04-044B-465B-9053-44CE20BC2CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
18 | {93DACE04-044B-465B-9053-44CE20BC2CB6}.Release|Any CPU.Build.0 = Release|Any CPU
19 | {93DACE04-044B-465B-9053-44CE20BC2CB6}.Release|Any CPU.Deploy.0 = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(SolutionProperties) = preSolution
22 | HideSolutionNode = FALSE
23 | EndGlobalSection
24 | GlobalSection(ExtensibilityGlobals) = postSolution
25 | SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
26 | EndGlobalSection
27 | EndGlobal
28 |
--------------------------------------------------------------------------------
/SearchHandlers/StudentSearchHandler.cs:
--------------------------------------------------------------------------------
1 | using SQLiteDemo.Models;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace SQLiteDemo.SearchHandlers
9 | {
10 | public class StudentSearchHandler : SearchHandler
11 | {
12 | public IList Students { get; set; }
13 | public string NavigationRoute { get; set; }
14 | public Type NavigationType { get; set; }
15 | protected override void OnQueryChanged(string oldValue, string newValue)
16 | {
17 | base.OnQueryChanged(oldValue, newValue);
18 |
19 | if (string.IsNullOrWhiteSpace(newValue))
20 | {
21 | ItemsSource = null;
22 | }
23 | else
24 | {
25 | ItemsSource = Students.Where(student => student.FullName.ToLower().Contains(newValue.ToLower())).ToList();
26 | }
27 | }
28 |
29 | protected override async void OnItemSelected(object item)
30 | {
31 | base.OnItemSelected(item);
32 | var navParam = new Dictionary();
33 | navParam.Add("StudentDetail", item);
34 | if (!string.IsNullOrWhiteSpace(NavigationRoute))
35 | {
36 | await Shell.Current.GoToAsync(NavigationRoute, navParam);
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
11 |
12 |
17 |
18 |
23 |
24 |
30 |
31 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/Views/AddUpdateStudentDetail.xaml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
8 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/Services/StudentService.cs:
--------------------------------------------------------------------------------
1 | using SQLite;
2 | using SQLiteDemo.Models;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 |
9 | namespace SQLiteDemo.Services
10 | {
11 | public class StudentService : IStudentService
12 | {
13 | private SQLiteAsyncConnection _dbConnection;
14 |
15 | private async Task SetUpDb()
16 | {
17 | if (_dbConnection == null)
18 | {
19 | string dbPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Student.db3");
20 | _dbConnection = new SQLiteAsyncConnection(dbPath);
21 | await _dbConnection.CreateTableAsync();
22 | }
23 | }
24 |
25 | public async Task AddStudent(StudentModel studentModel)
26 | {
27 | await SetUpDb();
28 | return await _dbConnection.InsertAsync(studentModel);
29 | }
30 |
31 | public async Task DeleteStudent(StudentModel studentModel)
32 | {
33 | await SetUpDb();
34 | return await _dbConnection.DeleteAsync(studentModel);
35 | }
36 |
37 | public async Task> GetStudentList()
38 | {
39 | await SetUpDb();
40 | var studentList = await _dbConnection.Table().ToListAsync();
41 | return studentList;
42 | }
43 |
44 | public async Task UpdateStudent(StudentModel studentModel)
45 | {
46 | await SetUpDb();
47 | return await _dbConnection.UpdateAsync(studentModel);
48 | }
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/Resources/AppIcon/appiconfg.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Resources/Splash/splash.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/Platforms/Windows/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
9 |
10 |
11 | $placeholder$
12 | User Name
13 | $placeholder$.png
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/ViewModels/AddUpdateStudentDetailViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using CommunityToolkit.Mvvm.Input;
3 | using SQLiteDemo.Models;
4 | using SQLiteDemo.Services;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 |
11 | namespace SQLiteDemo.ViewModels
12 | {
13 | [QueryProperty(nameof(StudentDetail), "StudentDetail")]
14 | public partial class AddUpdateStudentDetailViewModel : ObservableObject
15 | {
16 | [ObservableProperty]
17 | private StudentModel _studentDetail = new StudentModel();
18 |
19 | private readonly IStudentService _studentService;
20 | public AddUpdateStudentDetailViewModel(IStudentService studentService)
21 | {
22 | _studentService = studentService;
23 | }
24 |
25 | [RelayCommand]
26 | public async void AddUpdateStudent()
27 | {
28 | int response = -1;
29 | if (StudentDetail.StudentID > 0)
30 | {
31 | response = await _studentService.UpdateStudent(StudentDetail);
32 | }
33 | else
34 | {
35 | response = await _studentService.AddStudent(new Models.StudentModel
36 | {
37 | Email = StudentDetail.Email,
38 | FirstName = StudentDetail.FirstName,
39 | LastName = StudentDetail.LastName,
40 | });
41 | }
42 |
43 |
44 |
45 | if (response > 0)
46 | {
47 | await Shell.Current.DisplayAlert("Student Info Saved", "Record Saved", "OK");
48 | }
49 | else
50 | {
51 | await Shell.Current.DisplayAlert("Heads Up!", "Something went wrong while adding record", "OK");
52 | }
53 | }
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/Resources/Styles/Colors.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 | #512BD4
8 | #DFD8F7
9 | #2B0B98
10 | White
11 | Black
12 | #E1E1E1
13 | #C8C8C8
14 | #ACACAC
15 | #919191
16 | #6E6E6E
17 | #404040
18 | #212121
19 | #141414
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 | #F7B548
35 | #FFD590
36 | #FFE5B9
37 | #28C2D1
38 | #7BDDEF
39 | #C3F2F4
40 | #3E8EED
41 | #72ACF1
42 | #A7CBF6
43 |
44 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/ViewModels/StudentListPageViewModel.cs:
--------------------------------------------------------------------------------
1 | using CommunityToolkit.Mvvm.ComponentModel;
2 | using CommunityToolkit.Mvvm.Input;
3 | using SQLiteDemo.Models;
4 | using SQLiteDemo.Services;
5 | using SQLiteDemo.Views;
6 | using System;
7 | using System.Collections.Generic;
8 | using System.Collections.ObjectModel;
9 | using System.Linq;
10 | using System.Text;
11 | using System.Threading.Tasks;
12 |
13 | namespace SQLiteDemo.ViewModels
14 | {
15 | public partial class StudentListPageViewModel : ObservableObject
16 | {
17 | public static List StudentsListForSearch { get; private set; } = new List();
18 | public ObservableCollection Students { get; set; } = new ObservableCollection();
19 |
20 | private readonly IStudentService _studentService;
21 | public StudentListPageViewModel(IStudentService studentService)
22 | {
23 | _studentService = studentService;
24 | }
25 |
26 |
27 |
28 | [RelayCommand]
29 | public async void GetStudentList()
30 | {
31 | Students.Clear();
32 | var studentList = await _studentService.GetStudentList();
33 | if (studentList?.Count > 0)
34 | {
35 | studentList = studentList.OrderBy(f => f.FullName).ToList();
36 | foreach (var student in studentList)
37 | {
38 | Students.Add(student);
39 | }
40 | StudentsListForSearch.Clear();
41 | StudentsListForSearch.AddRange(studentList);
42 | }
43 | }
44 |
45 |
46 | [RelayCommand]
47 | public async void AddUpdateStudent()
48 | {
49 | await AppShell.Current.GoToAsync(nameof(AddUpdateStudentDetail));
50 | }
51 |
52 | [RelayCommand]
53 | public async void EditStudent(StudentModel studentModel)
54 | {
55 | var navParam = new Dictionary();
56 | navParam.Add("StudentDetail", studentModel);
57 | await AppShell.Current.GoToAsync(nameof(AddUpdateStudentDetail), navParam);
58 | }
59 |
60 | [RelayCommand]
61 | public async void DeleteStudent(StudentModel studentModel)
62 | {
63 | var delResponse = await _studentService.DeleteStudent(studentModel);
64 | if (delResponse > 0)
65 | {
66 | GetStudentList();
67 | }
68 | }
69 |
70 |
71 | [RelayCommand]
72 | public async void DisplayAction(StudentModel studentModel)
73 | {
74 | var response = await AppShell.Current.DisplayActionSheet("Select Option", "OK", null, "Edit", "Delete");
75 | if (response == "Edit")
76 | {
77 | var navParam = new Dictionary();
78 | navParam.Add("StudentDetail", studentModel);
79 | await AppShell.Current.GoToAsync(nameof(AddUpdateStudentDetail), navParam);
80 | }
81 | else if (response == "Delete")
82 | {
83 | var delResponse = await _studentService.DeleteStudent(studentModel);
84 | if (delResponse > 0)
85 | {
86 | GetStudentList();
87 | }
88 | }
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/SQLiteDemo.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0-android;net7.0-ios;net7.0-maccatalyst
5 | $(TargetFrameworks);net7.0-windows10.0.19041.0
6 |
7 |
8 | Exe
9 | SQLiteDemo
10 | true
11 | true
12 | enable
13 |
14 |
15 | SQLiteDemo
16 |
17 |
18 | com.companyname.sqlitedemo
19 | 7BD31CA9-CFFD-4A21-9B24-A87481C6221D
20 |
21 |
22 | 1.0
23 | 1
24 |
25 | 14.2
26 | 14.0
27 | 21.0
28 | 10.0.17763.0
29 | 10.0.17763.0
30 | 6.5
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | MSBuild:Compile
69 |
70 |
71 | MSBuild:Compile
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/Views/StudentListPage.xaml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Oo]ut/
33 | [Ll]og/
34 | [Ll]ogs/
35 |
36 | # Visual Studio 2015/2017 cache/options directory
37 | .vs/
38 | # Uncomment if you have tasks that create the project's static files in wwwroot
39 | #wwwroot/
40 |
41 | # Visual Studio 2017 auto generated files
42 | Generated\ Files/
43 |
44 | # MSTest test Results
45 | [Tt]est[Rr]esult*/
46 | [Bb]uild[Ll]og.*
47 |
48 | # NUnit
49 | *.VisualState.xml
50 | TestResult.xml
51 | nunit-*.xml
52 |
53 | # Build Results of an ATL Project
54 | [Dd]ebugPS/
55 | [Rr]eleasePS/
56 | dlldata.c
57 |
58 | # Benchmark Results
59 | BenchmarkDotNet.Artifacts/
60 |
61 | # .NET Core
62 | project.lock.json
63 | project.fragment.lock.json
64 | artifacts/
65 |
66 | # ASP.NET Scaffolding
67 | ScaffoldingReadMe.txt
68 |
69 | # StyleCop
70 | StyleCopReport.xml
71 |
72 | # Files built by Visual Studio
73 | *_i.c
74 | *_p.c
75 | *_h.h
76 | *.ilk
77 | *.meta
78 | *.obj
79 | *.iobj
80 | *.pch
81 | *.pdb
82 | *.ipdb
83 | *.pgc
84 | *.pgd
85 | *.rsp
86 | *.sbr
87 | *.tlb
88 | *.tli
89 | *.tlh
90 | *.tmp
91 | *.tmp_proj
92 | *_wpftmp.csproj
93 | *.log
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Microsoft Azure Build Output
210 | csx/
211 | *.build.csdef
212 |
213 | # Microsoft Azure Emulator
214 | ecf/
215 | rcf/
216 |
217 | # Windows Store app package directories and files
218 | AppPackages/
219 | BundleArtifacts/
220 | Package.StoreAssociation.xml
221 | _pkginfo.txt
222 | *.appx
223 | *.appxbundle
224 | *.appxupload
225 |
226 | # Visual Studio cache files
227 | # files ending in .cache can be ignored
228 | *.[Cc]ache
229 | # but keep track of directories ending in .cache
230 | !?*.[Cc]ache/
231 |
232 | # Others
233 | ClientBin/
234 | ~$*
235 | *~
236 | *.dbmdl
237 | *.dbproj.schemaview
238 | *.jfm
239 | *.pfx
240 | *.publishsettings
241 | orleans.codegen.cs
242 |
243 | # Including strong name files can present a security risk
244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
245 | #*.snk
246 |
247 | # Since there are multiple workflows, uncomment next line to ignore bower_components
248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
249 | #bower_components/
250 |
251 | # RIA/Silverlight projects
252 | Generated_Code/
253 |
254 | # Backup & report files from converting an old project file
255 | # to a newer Visual Studio version. Backup files are not needed,
256 | # because we have git ;-)
257 | _UpgradeReport_Files/
258 | Backup*/
259 | UpgradeLog*.XML
260 | UpgradeLog*.htm
261 | ServiceFabricBackup/
262 | *.rptproj.bak
263 |
264 | # SQL Server files
265 | *.mdf
266 | *.ldf
267 | *.ndf
268 |
269 | # Business Intelligence projects
270 | *.rdl.data
271 | *.bim.layout
272 | *.bim_*.settings
273 | *.rptproj.rsuser
274 | *- [Bb]ackup.rdl
275 | *- [Bb]ackup ([0-9]).rdl
276 | *- [Bb]ackup ([0-9][0-9]).rdl
277 |
278 | # Microsoft Fakes
279 | FakesAssemblies/
280 |
281 | # GhostDoc plugin setting file
282 | *.GhostDoc.xml
283 |
284 | # Node.js Tools for Visual Studio
285 | .ntvs_analysis.dat
286 | node_modules/
287 |
288 | # Visual Studio 6 build log
289 | *.plg
290 |
291 | # Visual Studio 6 workspace options file
292 | *.opt
293 |
294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
295 | *.vbw
296 |
297 | # Visual Studio LightSwitch build output
298 | **/*.HTMLClient/GeneratedArtifacts
299 | **/*.DesktopClient/GeneratedArtifacts
300 | **/*.DesktopClient/ModelManifest.xml
301 | **/*.Server/GeneratedArtifacts
302 | **/*.Server/ModelManifest.xml
303 | _Pvt_Extensions
304 |
305 | # Paket dependency manager
306 | .paket/paket.exe
307 | paket-files/
308 |
309 | # FAKE - F# Make
310 | .fake/
311 |
312 | # CodeRush personal settings
313 | .cr/personal
314 |
315 | # Python Tools for Visual Studio (PTVS)
316 | __pycache__/
317 | *.pyc
318 |
319 | # Cake - Uncomment if you are using it
320 | # tools/**
321 | # !tools/packages.config
322 |
323 | # Tabs Studio
324 | *.tss
325 |
326 | # Telerik's JustMock configuration file
327 | *.jmconfig
328 |
329 | # BizTalk build output
330 | *.btp.cs
331 | *.btm.cs
332 | *.odx.cs
333 | *.xsd.cs
334 |
335 | # OpenCover UI analysis results
336 | OpenCover/
337 |
338 | # Azure Stream Analytics local run output
339 | ASALocalRun/
340 |
341 | # MSBuild Binary and Structured Log
342 | *.binlog
343 |
344 | # NVidia Nsight GPU debugger configuration file
345 | *.nvuser
346 |
347 | # MFractors (Xamarin productivity tool) working folder
348 | .mfractor/
349 |
350 | # Local History for Visual Studio
351 | .localhistory/
352 |
353 | # BeatPulse healthcheck temp database
354 | healthchecksdb
355 |
356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
357 | MigrationBackup/
358 |
359 | # Ionide (cross platform F# VS Code tools) working folder
360 | .ionide/
361 |
362 | # Fody - auto-generated XML schema
363 | FodyWeavers.xsd
--------------------------------------------------------------------------------
/Resources/Images/dotnet_bot.svg:
--------------------------------------------------------------------------------
1 |
94 |
--------------------------------------------------------------------------------
/Resources/Styles/Styles.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 |
7 |
10 |
11 |
15 |
16 |
21 |
22 |
25 |
26 |
47 |
48 |
63 |
64 |
82 |
83 |
102 |
103 |
122 |
123 |
128 |
129 |
147 |
148 |
165 |
166 |
170 |
171 |
191 |
192 |
207 |
208 |
226 |
227 |
230 |
231 |
252 |
253 |
273 |
274 |
280 |
281 |
300 |
301 |
304 |
305 |
333 |
334 |
352 |
353 |
357 |
358 |
370 |
371 |
376 |
377 |
383 |
384 |
385 |
--------------------------------------------------------------------------------