@@ -30,22 +30,10 @@ public partial class ItemsPageViewModel : BaseViewModel
30
30
private bool isShowPopup = false ;
31
31
32
32
[ ObservableProperty ]
33
- private bool isItemPopupShow = false ;
33
+ private bool isDeletePopupShow = false ;
34
34
35
35
[ ObservableProperty ]
36
- private OperationItem operationItem = new ( ) ;
37
-
38
- [ ObservableProperty ]
39
- private bool isInfoPopupShow = false ;
40
-
41
- [ ObservableProperty ]
42
- private Color infoPopupColor = SkyBlue ;
43
-
44
- [ ObservableProperty ]
45
- private string infoPopupTitle = "BİLGİ" ;
46
-
47
- [ ObservableProperty ]
48
- private string infoPopupDesc = "İşlem başarılı olmuştur." ;
36
+ private Guid deleteId ;
49
37
50
38
private int index = 15 ;
51
39
@@ -55,7 +43,6 @@ public ItemsPageViewModel(IOperationItemsRepo operationItemsRepo, IMapper mapper
55
43
_mapper = mapper ;
56
44
57
45
Items = GetItems ( GetDate ( ) ) . Result ;
58
- OperationItem . Date = DateTime . Now ;
59
46
}
60
47
61
48
@@ -65,7 +52,8 @@ private async Task<List<OperationItemsVM>> GetItems(DateTime date)
65
52
expression : e => e . Date >= date && ( OperationType == 0 ? true : OperationType == 1 ? e . IsIncome : ! e . IsIncome ) ,
66
53
ordered : e => e . Date ,
67
54
skip : index ,
68
- limit : 15 ) ;
55
+ limit : 15 ,
56
+ descOrder : true ) ;
69
57
index += 15 ;
70
58
71
59
if ( tempList . Count == 0 )
@@ -119,51 +107,36 @@ public void ShowFilterPopup()
119
107
}
120
108
121
109
[ RelayCommand ]
122
- public void ShowItemPopup ( )
110
+ public async void ShowItem ( )
123
111
{
124
- IsItemPopupShow = true ;
112
+ await AppShell . Current . GoToAsync ( $ "//{ nameof ( AddOrEditPage ) } ") ;
113
+ await GetItems ( GetDate ( ) ) ;
125
114
}
126
115
127
116
[ RelayCommand ]
128
- public void CloseItemPopup ( )
117
+ public async void GotoEditPage ( object parameter )
129
118
{
130
- IsItemPopupShow = false ;
131
- OperationItem = new ( ) ;
119
+ //AddOrEditPageViewModel.Id = true;
120
+ await AppShell . Current . GoToAsync ( $ "//{ nameof ( AddOrEditPage ) } ") ;
121
+ await GetItems ( GetDate ( ) ) ;
132
122
}
133
123
134
124
[ RelayCommand ]
135
- public async Task Save ( )
125
+ public void Cancel ( )
136
126
{
137
- var currentUser = Preferences . Get ( nameof ( App . CurrentUserId ) , string . Empty ) ;
138
- OperationItem . IsActive = true ;
139
- OperationItem . CreatedBy = ! string . IsNullOrEmpty ( currentUser ) ? Guid . Parse ( currentUser ) : Guid . Empty ;
140
- OperationItem . UpdatedBy = ! string . IsNullOrEmpty ( currentUser ) ? Guid . Parse ( currentUser ) : Guid . Empty ;
141
-
142
- var result = await _operationItemsRepo . InsertAsync ( OperationItem ) ;
143
- if ( result )
144
- {
145
- InfoPopupColor = SkyBlue ;
146
- InfoPopupTitle = "BİLGİ" ;
147
- infoPopupDesc = "İşlem başarılı olmuştur." ;
148
- }
149
- else
150
- {
151
- InfoPopupColor = DarkOrange ;
152
- InfoPopupTitle = "HATA" ;
153
- infoPopupDesc = "İşlem sırasında beklenmeyen bir hata oluştu." ;
154
- }
155
- IsInfoPopupShow = true ;
127
+ DeleteId = Guid . Empty ;
128
+ IsDeletePopupShow = false ;
156
129
}
157
130
158
131
[ RelayCommand ]
159
- public void ClosePopup ( )
132
+ public async Task Yes ( )
160
133
{
161
- if ( InfoPopupTitle == "BİLGİ" )
162
- {
163
- IsInfoPopupShow = false ;
164
- IsItemPopupShow = false ;
165
- }
166
- else
167
- IsInfoPopupShow = false ;
134
+ var result = await _operationItemsRepo . RemoveAsync ( DeleteId ) ;
135
+ IsLoadingItems = true ;
136
+ await GetItems ( GetDate ( ) ) ;
137
+ IsDeletePopupShow = false ;
138
+ await Task . Delay ( 1500 ) ;
139
+
140
+ IsLoadingItems = false ;
168
141
}
169
142
}
0 commit comments