├── Enums
├── ThemeType.cs
└── Enums.csproj
├── Notebook
├── ApplicationConfig.json
├── Content
│ ├── Images
│ │ ├── Logo
│ │ │ └── Logo.ico
│ │ └── Controls
│ │ │ ├── MenuControl
│ │ │ ├── Default.png
│ │ │ └── MouseEnter.png
│ │ │ └── WindowControls
│ │ │ ├── Close
│ │ │ ├── Default.png
│ │ │ └── MouseEnter.png
│ │ │ └── CloseLeftMenu
│ │ │ └── Default.png
│ ├── Font
│ │ └── ProximaNova
│ │ │ ├── proxima-nova-thin.ttf
│ │ │ └── proxima-nova-light.ttf
│ ├── Animations
│ │ └── AnimationDictionary.xaml
│ └── Theme
│ │ └── ClassicTheme.xaml
├── AssemblyInfo.cs
├── Views
│ ├── UserControls
│ │ ├── NoteView.xaml.cs
│ │ ├── SettingsView.xaml.cs
│ │ ├── CreateNoteView.xaml.cs
│ │ ├── DeleteNoteView.xaml.cs
│ │ ├── NoteView.xaml
│ │ ├── SettingsView.xaml
│ │ ├── DeleteNoteView.xaml
│ │ └── CreateNoteView.xaml
│ ├── MainView.xaml.cs
│ ├── LoginView.xaml.cs
│ ├── LoginView.xaml
│ └── MainView.xaml
├── ViewModels
│ ├── Abstract
│ │ └── BaseViewModel.cs
│ ├── UserControls
│ │ ├── NoteViewModel.cs
│ │ ├── DeleteNoteViewModel.cs
│ │ ├── SettingsViewModel.cs
│ │ └── CreateNoteViewModel.cs
│ ├── MainViewModel.cs
│ └── LoginViewModel.cs
├── App.xaml
├── GlobalUsings.cs
├── App.xaml.cs
└── Notebook.csproj
├── Services
├── Abstract
│ ├── Users
│ │ ├── IUserRegistrationService.cs
│ │ ├── IUserAuthorizationService.cs
│ │ ├── IUserRepositoryService.cs
│ │ └── IUserFacadeService.cs
│ ├── IActiveSessionService.cs
│ └── Notes
│ │ ├── INoteFacadeService.cs
│ │ └── INoteRepositoryService.cs
├── GlobalUsings.cs
├── Services.csproj
├── ApplicationRunnerService.cs
├── ResourcesDictionaryManagerService.cs
├── Users
│ ├── UserAuthorizationService.cs
│ ├── UserRepositoryService.cs
│ ├── UserRegistrationService.cs
│ └── UserFacadeService.cs
├── Notes
│ ├── NoteRepositoryService.cs
│ └── NoteFacadeService.cs
├── ActiveSessionService.cs
└── ApplicationConfiguratorService.cs
├── Models
├── Abstract
│ ├── IBaseModel.cs
│ └── BaseModel.cs
├── Serialize
│ └── ApplicationSettings.cs
├── Models.csproj
├── User.cs
└── Note.cs
├── MVVM
├── MVVM.csproj
└── Command
│ └── RelayCommand.cs
├── Data
├── GlobalUsings.cs
├── Repositories
│ ├── Abstract
│ │ ├── INoteRepository.cs
│ │ └── IUserRepository.cs
│ ├── UserRepository.cs
│ └── NoteRepository.cs
├── Data.csproj
└── Context
│ └── ApplicationContext.cs
├── Common
├── Common.csproj
└── StringHelper.cs
├── .gitattributes
├── Notebook.sln
└── .gitignore
/Enums/ThemeType.cs:
--------------------------------------------------------------------------------
1 | namespace Enums;
2 |
3 | public enum ThemeType
4 | {
5 | Classic,
6 | Dark
7 | }
8 |
--------------------------------------------------------------------------------
/Notebook/ApplicationConfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "Theme": 0,
3 | "DataBaseConnection": "Data Source=.\\ApplicationDataBase.db"
4 | }
--------------------------------------------------------------------------------
/Notebook/Content/Images/Logo/Logo.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Images/Logo/Logo.ico
--------------------------------------------------------------------------------
/Notebook/Content/Font/ProximaNova/proxima-nova-thin.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Font/ProximaNova/proxima-nova-thin.ttf
--------------------------------------------------------------------------------
/Notebook/Content/Font/ProximaNova/proxima-nova-light.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Font/ProximaNova/proxima-nova-light.ttf
--------------------------------------------------------------------------------
/Notebook/Content/Images/Controls/MenuControl/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Images/Controls/MenuControl/Default.png
--------------------------------------------------------------------------------
/Notebook/Content/Images/Controls/MenuControl/MouseEnter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Images/Controls/MenuControl/MouseEnter.png
--------------------------------------------------------------------------------
/Notebook/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | [assembly: ThemeInfo(
4 | ResourceDictionaryLocation.None,
5 | ResourceDictionaryLocation.SourceAssembly
6 | )]
7 |
--------------------------------------------------------------------------------
/Notebook/Content/Images/Controls/WindowControls/Close/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Images/Controls/WindowControls/Close/Default.png
--------------------------------------------------------------------------------
/Services/Abstract/Users/IUserRegistrationService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract.Users;
2 |
3 | public interface IUserRegistrationService
4 | {
5 | bool Register(User user);
6 | }
7 |
--------------------------------------------------------------------------------
/Notebook/Content/Images/Controls/WindowControls/Close/MouseEnter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Images/Controls/WindowControls/Close/MouseEnter.png
--------------------------------------------------------------------------------
/Services/Abstract/Users/IUserAuthorizationService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract.Users;
2 |
3 | public interface IUserAuthorizationService
4 | {
5 | bool Authorize(User user);
6 | }
7 |
--------------------------------------------------------------------------------
/Models/Abstract/IBaseModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Models.Abstract;
4 |
5 | public interface IBaseModel
6 | {
7 | int Id { get; set; }
8 | DateTime CreatedDate { get; set; }
9 | }
--------------------------------------------------------------------------------
/Notebook/Content/Images/Controls/WindowControls/CloseLeftMenu/Default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/DimaInNature/Notebook/HEAD/Notebook/Content/Images/Controls/WindowControls/CloseLeftMenu/Default.png
--------------------------------------------------------------------------------
/Models/Abstract/BaseModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Models.Abstract;
4 |
5 | public abstract class BaseModel : IBaseModel
6 | {
7 | public int Id { get; set; }
8 | public DateTime CreatedDate { get; set; } = DateTime.UtcNow;
9 | }
--------------------------------------------------------------------------------
/MVVM/MVVM.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | enable
6 | true
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Enums/Enums.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | enable
6 | true
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Services/Abstract/IActiveSessionService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract;
2 |
3 | public interface IActiveSessionService
4 | {
5 | void StartSession(User user);
6 | void EndSession();
7 | User GetUser();
8 | bool GetStatus();
9 | }
10 |
--------------------------------------------------------------------------------
/Data/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using Data.Context;
2 | global using Data.Repositories.Abstract;
3 | global using Microsoft.EntityFrameworkCore;
4 | global using Models;
5 | global using System.Collections.Generic;
6 | global using System.Linq;
7 | global using System.Threading.Tasks;
--------------------------------------------------------------------------------
/Services/Abstract/Notes/INoteFacadeService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract.Notes;
2 |
3 | public interface INoteFacadeService
4 | {
5 | void Write(Note noteItem);
6 | void Erase(Note noteItem);
7 | IEnumerable GetAll();
8 | Note GetNoteById(int id);
9 | }
10 |
--------------------------------------------------------------------------------
/Models/Serialize/ApplicationSettings.cs:
--------------------------------------------------------------------------------
1 | using Enums;
2 | using System;
3 |
4 | namespace Models.Serialize;
5 |
6 | [Serializable]
7 | public class ApplicationSettings
8 | {
9 | public ThemeType Theme { get; set; }
10 |
11 | public string DataBaseConnection { get; set; }
12 | }
--------------------------------------------------------------------------------
/Data/Repositories/Abstract/INoteRepository.cs:
--------------------------------------------------------------------------------
1 | namespace Data.Repositories.Abstract;
2 |
3 | public interface INoteRepository
4 | {
5 | Task AddNoteAsync(Note noteItem);
6 | Task DeleteNote(Note noteItem);
7 | Note GetNoteById(int id);
8 | IEnumerable GetAll();
9 | }
10 |
--------------------------------------------------------------------------------
/Data/Repositories/Abstract/IUserRepository.cs:
--------------------------------------------------------------------------------
1 | namespace Data.Repositories.Abstract;
2 |
3 | public interface IUserRepository
4 | {
5 | Task AddUserAsync(User userItem);
6 | Task DeleteUser(User userItem);
7 | User GetUserById(int id);
8 | IEnumerable GetAll();
9 | }
10 |
--------------------------------------------------------------------------------
/Services/Abstract/Notes/INoteRepositoryService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract.Notes;
2 |
3 | public interface INoteRepositoryService
4 | {
5 | void AddNote(Note noteItem);
6 | void DeleteNote(Note noteItem);
7 | IEnumerable GetAll();
8 | Note GetNoteById(int id);
9 | }
10 |
--------------------------------------------------------------------------------
/Services/Abstract/Users/IUserRepositoryService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract.Users;
2 |
3 | public interface IUserRepositoryService
4 | {
5 | void AddUser(User userItem);
6 | void DeleteUser(User userItem);
7 | IEnumerable GetAll();
8 | User GetUserById(int id);
9 | }
10 |
--------------------------------------------------------------------------------
/Services/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using Data.Repositories.Abstract;
2 | global using Models;
3 | global using Services.Abstract;
4 | global using Services.Abstract.Notes;
5 | global using Services.Abstract.Users;
6 | global using System;
7 | global using System.Collections.Generic;
8 | global using System.Linq;
--------------------------------------------------------------------------------
/Services/Abstract/Users/IUserFacadeService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Abstract.Users;
2 |
3 | public interface IUserFacadeService
4 | {
5 | bool Register(User userItem);
6 | void DeleteUser(User userItem);
7 | IEnumerable GetAll();
8 | User GetUserById(int id);
9 | bool Authorize(User user);
10 | }
11 |
--------------------------------------------------------------------------------
/Common/Common.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | enable
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Models/Models.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | enable
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Notebook/Views/UserControls/NoteView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Notebook.Views.UserControls;
4 |
5 | public partial class NoteView : UserControl
6 | {
7 | public NoteView()
8 | {
9 | InitializeComponent();
10 | DataContext = (Application.Current as App)?
11 | .ServiceProvider.GetService();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Notebook/Views/UserControls/SettingsView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Notebook.Views.UserControls;
4 |
5 | public partial class SettingsView : UserControl
6 | {
7 | public SettingsView()
8 | {
9 | InitializeComponent();
10 | DataContext = (Application.Current as App)?
11 | .ServiceProvider.GetService();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Notebook/ViewModels/Abstract/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 |
3 | namespace MVVM.ViewModel.Abstract;
4 |
5 | public abstract class BaseViewModel : INotifyPropertyChanged
6 | {
7 | public event PropertyChangedEventHandler? PropertyChanged;
8 |
9 | public void OnPropertyChanged(string propertyName) =>
10 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
11 | }
--------------------------------------------------------------------------------
/Notebook/Views/UserControls/CreateNoteView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Notebook.Views.UserControls;
4 |
5 | public partial class CreateNoteView : UserControl
6 | {
7 | public CreateNoteView()
8 | {
9 | InitializeComponent();
10 | DataContext = (Application.Current as App)?
11 | .ServiceProvider.GetService();
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Models/User.cs:
--------------------------------------------------------------------------------
1 | using Models.Abstract;
2 | using System.ComponentModel.DataAnnotations.Schema;
3 |
4 | namespace Models;
5 |
6 | [Table("Users")]
7 | public class User : BaseModel
8 | {
9 | public string Login { get; set; }
10 | public string Password { get; set; }
11 |
12 | public User(string login, string password) =>
13 | (Login, Password) = (login, password);
14 |
15 | public User() { }
16 | }
--------------------------------------------------------------------------------
/Common/StringHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 |
3 | namespace Common;
4 |
5 | public static class StringHelper
6 | {
7 | public static bool StrIsNotNullOrWhiteSpace(params string[] stringsArray) =>
8 | stringsArray.All(stroke => !string.IsNullOrWhiteSpace(stroke));
9 |
10 | public static bool StrIsNullOrWhiteSpace(params string[] stringsArray) =>
11 | stringsArray.All(stroke => string.IsNullOrWhiteSpace(stroke));
12 | }
--------------------------------------------------------------------------------
/Notebook/Views/MainView.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Notebook.Views;
2 |
3 | public partial class MainView : Window
4 | {
5 | public MainView()
6 | {
7 | InitializeComponent();
8 | DataContext = (Application.Current as App)?
9 | .ServiceProvider.GetService();
10 | }
11 |
12 | private void WindowDragMove(object sender, MouseButtonEventArgs e)
13 | {
14 | if (e.LeftButton == MouseButtonState.Pressed)
15 | DragMove();
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/Services/Services.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | enable
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Data/Data.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net6.0-windows
5 | enable
6 | true
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/Notebook/Views/UserControls/DeleteNoteView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Notebook.Views.UserControls;
4 |
5 | public partial class DeleteNoteView : UserControl
6 | {
7 | public DeleteNoteView()
8 | {
9 | InitializeComponent();
10 | DataContext = (Application.Current as App)?
11 | .ServiceProvider.GetService();
12 | }
13 |
14 | public DeleteNoteView(Note deletableNote) : this()
15 | {
16 | var vm = DataContext as DeleteNoteViewModel;
17 | vm.DeletableNote = deletableNote;
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/Notebook/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/Services/ApplicationRunnerService.cs:
--------------------------------------------------------------------------------
1 | namespace Services;
2 |
3 | public class ApplicationRunnerService
4 | {
5 | private readonly ApplicationConfiguratorService _configurator;
6 |
7 | private readonly ResourcesDictionaryManagerService _recourceManager;
8 |
9 | public ApplicationRunnerService(ApplicationConfiguratorService configurator,
10 | ResourcesDictionaryManagerService recourceManager)
11 | {
12 | _configurator = configurator;
13 | _recourceManager = recourceManager;
14 | }
15 |
16 | public void Run()
17 | {
18 | var theme = _configurator.Theme;
19 | _recourceManager.SwitchTheme(theme);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/Models/Note.cs:
--------------------------------------------------------------------------------
1 | using Models.Abstract;
2 | using System;
3 | using System.ComponentModel.DataAnnotations.Schema;
4 |
5 | namespace Models;
6 |
7 | [Table("Notes")]
8 | public class Note : BaseModel
9 | {
10 | public string Title { get; set; }
11 | public string Text { get; set; }
12 | public int CreatorId { get; set; }
13 | public DateOnly CreationDate { get; set; }
14 |
15 | public Note(string title,
16 | string text, User creator)
17 | {
18 | Title = title;
19 | Text = text;
20 | CreatorId = creator.Id;
21 | CreationDate = DateOnly.FromDateTime(dateTime: DateTime.UtcNow);
22 | }
23 |
24 | public Note() { }
25 | }
26 |
--------------------------------------------------------------------------------
/Services/ResourcesDictionaryManagerService.cs:
--------------------------------------------------------------------------------
1 | using Enums;
2 | using System.Windows;
3 |
4 | namespace Services;
5 |
6 | public class ResourcesDictionaryManagerService
7 | {
8 | public void SwitchTheme(ThemeType theme)
9 | {
10 | Application.Current.Resources
11 | .MergedDictionaries.Clear();
12 |
13 | var url = new Uri(
14 | uriString: $@"/Content/Theme/{theme}Theme.xaml",
15 | uriKind: UriKind.Relative);
16 |
17 | var resource = Application
18 | .LoadComponent(url) as ResourceDictionary;
19 |
20 | Application.Current.Resources
21 | .MergedDictionaries.Add(resource);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/Services/Users/UserAuthorizationService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Users;
2 |
3 | public class UserAuthorizationService : IUserAuthorizationService
4 | {
5 | private readonly IUserRepositoryService _repository;
6 |
7 | public UserAuthorizationService(IUserRepositoryService repository)
8 | {
9 | _repository = repository;
10 | }
11 |
12 | public bool Authorize(User user)
13 | {
14 | ArgumentNullException.ThrowIfNull(user);
15 |
16 | var existUser = _repository.GetAll()
17 | .FirstOrDefault(u => u.Login == user.Login &&
18 | user.Password == user.Password);
19 |
20 | return existUser is not null;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/Services/Notes/NoteRepositoryService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Notes;
2 |
3 | public class NoteRepositoryService : INoteRepositoryService
4 | {
5 | private readonly INoteRepository _repository;
6 |
7 | public NoteRepositoryService(INoteRepository repository)
8 | {
9 | _repository = repository;
10 | }
11 |
12 | public void AddNote(Note noteItem) =>
13 | _repository.AddNoteAsync(noteItem);
14 |
15 | public void DeleteNote(Note noteItem) =>
16 | _repository.DeleteNote(noteItem);
17 |
18 | public IEnumerable GetAll() =>
19 | _repository.GetAll();
20 |
21 | public Note GetNoteById(int id) =>
22 | _repository.GetNoteById(id);
23 | }
24 |
--------------------------------------------------------------------------------
/Services/Users/UserRepositoryService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Users;
2 |
3 | public class UserRepositoryService : IUserRepositoryService
4 | {
5 | private readonly IUserRepository _repository;
6 |
7 | public UserRepositoryService(IUserRepository repository)
8 | {
9 | _repository = repository;
10 | }
11 |
12 | public void AddUser(User userItem) =>
13 | _repository.AddUserAsync(userItem);
14 |
15 | public void DeleteUser(User userItem) =>
16 | _repository.DeleteUser(userItem);
17 |
18 | public IEnumerable GetAll() =>
19 | _repository.GetAll();
20 |
21 | public User GetUserById(int id) =>
22 | _repository.GetUserById(id);
23 | }
24 |
--------------------------------------------------------------------------------
/Services/Notes/NoteFacadeService.cs:
--------------------------------------------------------------------------------
1 | namespace Services.Notes;
2 |
3 | public class NoteFacadeService : INoteFacadeService
4 | {
5 | private readonly INoteRepositoryService _repositoryService;
6 |
7 | public NoteFacadeService(INoteRepositoryService repository)
8 | {
9 | _repositoryService = repository;
10 | }
11 |
12 | public void Write(Note noteItem) =>
13 | _repositoryService.AddNote(noteItem);
14 |
15 | public void Erase(Note noteItem) =>
16 | _repositoryService.DeleteNote(noteItem);
17 |
18 | public IEnumerable GetAll() =>
19 | _repositoryService.GetAll();
20 |
21 | public Note GetNoteById(int id) =>
22 | _repositoryService.GetNoteById(id);
23 | }
24 |
--------------------------------------------------------------------------------
/Data/Repositories/UserRepository.cs:
--------------------------------------------------------------------------------
1 | namespace Data.Repositories;
2 |
3 | public class UserRepository : IUserRepository
4 | {
5 | private readonly ApplicationContext _context;
6 |
7 | public UserRepository(ApplicationContext context)
8 | {
9 | _context = context;
10 | }
11 |
12 | public async Task AddUserAsync(User userItem)
13 | {
14 | await _context.Users.AddAsync(entity: userItem);
15 | await _context.SaveChangesAsync();
16 | }
17 |
18 | public async Task DeleteUser(User userItem)
19 | {
20 | _context.Users.Attach(entity: userItem);
21 | _context.Users.Remove(entity: userItem);
22 | await _context.SaveChangesAsync();
23 | }
24 |
25 | public IEnumerable GetAll() => _context.Users;
26 |
27 | public User GetUserById(int id) =>
28 | _context.Users.FirstOrDefault(user => user.Id == id);
29 | }
--------------------------------------------------------------------------------
/Data/Repositories/NoteRepository.cs:
--------------------------------------------------------------------------------
1 | namespace Data.Repositories;
2 |
3 | public class NoteRepository : INoteRepository
4 | {
5 | private readonly ApplicationContext _context;
6 |
7 | public NoteRepository(ApplicationContext context)
8 | {
9 | _context = context;
10 | }
11 |
12 | public async Task AddNoteAsync(Note noteItem)
13 | {
14 | await _context.Notes.AddAsync(entity: noteItem);
15 | await _context.SaveChangesAsync();
16 | }
17 |
18 | public async Task DeleteNote(Note noteItem)
19 | {
20 | _context.Notes.Attach(entity: noteItem);
21 | _context.Notes.Remove(entity: noteItem);
22 | await _context.SaveChangesAsync();
23 | }
24 |
25 | public IEnumerable GetAll() => _context.Notes;
26 |
27 | public Note? GetNoteById(int id) =>
28 | _context.Notes.FirstOrDefault(note => note.Id == id);
29 | }
30 |
--------------------------------------------------------------------------------
/Notebook/GlobalUsings.cs:
--------------------------------------------------------------------------------
1 | global using Common;
2 | global using Data.Context;
3 | global using Data.Repositories;
4 | global using Data.Repositories.Abstract;
5 | global using Enums;
6 | global using Microsoft.EntityFrameworkCore;
7 | global using Microsoft.Extensions.DependencyInjection;
8 | global using Models;
9 | global using MVVM.Command;
10 | global using MVVM.ViewModel.Abstract;
11 | global using Notebook.ViewModels;
12 | global using Notebook.ViewModels.UserControls;
13 | global using Notebook.Views;
14 | global using Notebook.Views.UserControls;
15 | global using Services;
16 | global using Services.Abstract;
17 | global using Services.Abstract.Notes;
18 | global using Services.Abstract.Users;
19 | global using Services.Notes;
20 | global using Services.Users;
21 | global using System;
22 | global using System.Collections.Generic;
23 | global using System.Linq;
24 | global using System.Windows;
25 | global using System.Windows.Input;
--------------------------------------------------------------------------------
/MVVM/Command/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace MVVM.Command;
5 |
6 | public sealed class RelayCommand : ICommand
7 | {
8 | private readonly Action