123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Avalonia.Controls;
- using ReactiveUI;
- using FinancialManagement.Views;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using FinancialManagement.Models;
- namespace FinancialManagement.ViewModels
- {
- public class CategoryTableViewModel : ReactiveObject
- {
- ShmelevTeamContext ppContext;
- List<CategoryTableView> categores = new List<CategoryTableView>();
- private string categoryTitle;
- int indexCategory;
- public int IndexCategory { get => indexCategory; set => indexCategory = value; }
- public List<CategoryTableView> Categores { get => categores; set => this.RaiseAndSetIfChanged(ref categores, value); }
- public Category ItemCategory { get => ppContext.Categories.First(it => it.CategoryId == categores[IndexCategory].CategoryId); }
- public string CategoryTitle { get => categoryTitle; set => categoryTitle = value; }
- public CategoryTableViewModel(User currentUser, ShmelevTeamContext ppContext)
- {
- this.ppContext = ppContext;
- List<Category> categoriesList = ppContext.Categories
- .Where( c => c.IdUser == currentUser.UserId)
- .ToList();
- categoriesList.ForEach(it =>
- {
- CategoryTableView item = new CategoryTableView();
- item.CategoryId = it.CategoryId;
- item.CategoryTitle = it.Title;
- categores.Add(item);
- });
- }
- }
- public class CategoryTableView
- {
- public int CategoryId { get; set; }
- public string CategoryTitle { get; set; } = null!;
- }
- }
|