2
2
using Microsoft . Maui . Controls . Compatibility . Hosting ;
3
3
using SkiaSharp . Views . Maui . Controls . Hosting ;
4
4
using DXImage = DevExpress . Maui . Core . DXImage ;
5
+ using SwipeItem = DevExpress . Maui . CollectionView . SwipeItem ;
5
6
6
7
namespace MyFinance ;
7
8
@@ -10,7 +11,8 @@ namespace MyFinance;
10
11
[ MauiMarkup ( typeof ( PasswordEdit ) , typeof ( CheckEdit ) , typeof ( DXPopup ) , typeof ( ComboBoxEditBase ) , typeof ( ItemsEditBase ) ) ]
11
12
[ MauiMarkup ( typeof ( DXImage ) , typeof ( DXButton ) , typeof ( DXViewBase ) , typeof ( DXBorder ) , typeof ( DXContentPresenterBase ) ) ]
12
13
[ MauiMarkup ( typeof ( DXContentPresenter ) , typeof ( DXCollectionView ) , typeof ( CartesianChart ) , typeof ( TabView ) , typeof ( TabViewItem ) ) ]
13
- [ MauiMarkup ( typeof ( TabItem ) , typeof ( DXButtonBase ) , typeof ( ShimmerView ) ) ]
14
+ [ MauiMarkup ( typeof ( TabItem ) , typeof ( DXButtonBase ) , typeof ( ShimmerView ) , typeof ( DXCollectionViewBase ) , typeof ( SwipeContainer ) ) ]
15
+ [ MauiMarkup ( typeof ( SwipeItem ) ) ]
14
16
public static class MauiProgram
15
17
{
16
18
public static MauiApp CreateMauiApp ( )
@@ -34,14 +36,16 @@ public static MauiApp CreateMauiApp()
34
36
. AddSingleton < App > ( )
35
37
. AddSingleton < AppShell > ( )
36
38
. AddDbContext < MyFinanceContext > ( )
39
+ . AddAutoMapper ( typeof ( App ) )
37
40
. AddScopedWithShellRoute < MainPage , MainPageViewModel > ( $ "//{ nameof ( MainPage ) } ")
38
41
. AddScopedWithShellRoute < ChartPage , ChartPageViewModel > ( $ "//{ nameof ( ChartPage ) } ")
39
42
. AddScopedWithShellRoute < ItemsPage , ItemsPageViewModel > ( $ "//{ nameof ( ItemsPage ) } ")
40
43
. AddScopedWithShellRoute < AccountPage , AccountPageViewModel > ( $ "//{ nameof ( AccountPage ) } ")
41
44
. AddScopedWithShellRoute < LoginPage , LoginPageViewModel > ( $ "//{ nameof ( LoginPage ) } ")
42
45
. AddScopedWithShellRoute < RegisterPage , RegisterPageViewModel > ( $ "//{ nameof ( RegisterPage ) } ")
43
46
. AddScoped < StartedPage > ( )
44
- . AddScoped < IUserRepo , UserRepo > ( ) ;
47
+ . AddScoped < IUserRepo , UserRepo > ( )
48
+ . AddScoped < IOperationItemsRepo , OperationItemsRepo > ( ) ;
45
49
46
50
#region Init DB
47
51
var dbContext = new MyFinanceContext ( ) ;
@@ -61,6 +65,33 @@ public static MauiApp CreateMauiApp()
61
65
} ) ;
62
66
dbContext . SaveChanges ( ) ;
63
67
}
68
+
69
+ if ( dbContext . OperationItems . Count ( ) <= 0 )
70
+ {
71
+ List < OperationItem > items = new List < OperationItem > ( ) ;
72
+ Random random = new Random ( ) ;
73
+ for ( int i = 1 ; i <= 500 ; i ++ )
74
+ {
75
+ var amount = random . Next ( 1 , 10000 ) ;
76
+ items . Add (
77
+ new OperationItem
78
+ {
79
+ Icon = amount % 2 == 0 ? "loss.png" : "profits.png" ,
80
+ Color = amount % 2 == 0 ? nameof ( Red ) : nameof ( Green ) ,
81
+ Date = DateTime . Now . AddDays ( - ( amount % 200 ) ) ,
82
+ Title = amount % 2 == 0 ? "Borç ödendi" : "Ödeme Alındı" ,
83
+ Description = amount % 2 == 0 ? "Ödemeler yapıldı" : "Yaka parası alındı." ,
84
+ Amount = amount ,
85
+ CreateDate = DateTime . Now . AddDays ( - ( amount % 200 ) ) ,
86
+ UpdateDate = DateTime . Now . AddDays ( - ( amount % 200 ) ) ,
87
+ IsActive = true
88
+ }
89
+ ) ;
90
+ }
91
+
92
+ dbContext . AddRange ( items ) ;
93
+ dbContext . SaveChanges ( ) ;
94
+ }
64
95
dbContext . Dispose ( ) ;
65
96
#endregion
66
97
0 commit comments