Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 0.1.0 #56

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FlowHub.DataAccess/FlowHub.DataAccess.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<ItemGroup>
<PackageReference Include="LiteDB.Async" Version="0.1.6" />
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="MongoDB.Driver" Version="2.20.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace FlowHub.DataAccess.IRepositories;
public interface IExpendituresRepository
{
// Task<List<ExpendituresModel>> GetAllExpendituresAsync();
event Action OfflineExpendituresListChanged;
Task<List<ExpendituresModel>> GetAllExpendituresAsync();
// List<ExpendituresModel> OnlineExpendituresList { get; set; }

Expand Down
26 changes: 24 additions & 2 deletions FlowHub.DataAccess/Repositories/ExpendituresRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public class ExpendituresRepository : IExpendituresRepository

public List<ExpendituresModel> OfflineExpendituresList { get; set; }

bool isBatchUpdate;
public event Action OfflineExpendituresListChanged;

private IMongoCollection<ExpendituresModel> AllOnlineExpenditures;
private IMongoCollection<IDsToBeDeleted> AllOnlineIDsToBeDeleted;

Expand Down Expand Up @@ -55,7 +58,7 @@ public async Task<List<ExpendituresModel>> GetAllExpendituresAsync()
userId = usersRepo.OfflineUser.UserIDOnline;
}
OfflineExpendituresList = await AllExpenditures.Query().Where(x => x.UserId == userId && x.Currency == userCurrency).ToListAsync();

db.Dispose();

return OfflineExpendituresList;
Expand All @@ -80,7 +83,12 @@ public async Task<bool> AddExpenditureAsync(ExpendituresModel expenditure)
{
if (await AllExpenditures.InsertAsync(expenditure) is not null)
{
return true;
OfflineExpendituresList.Add(expenditure);
if (!isBatchUpdate)
{
OfflineExpendituresListChanged?.Invoke();
}
return true;
}
else
{
Expand Down Expand Up @@ -109,6 +117,12 @@ public async Task<bool> UpdateExpenditureAsync(ExpendituresModel expenditure)
if (await AllExpenditures.UpdateAsync(expenditure))
{
db.Dispose();
int index = OfflineExpendituresList.FindIndex(x => x.Id == expenditure.Id);
OfflineExpendituresList[index] = expenditure;
if (!isBatchUpdate)
{
OfflineExpendituresListChanged?.Invoke();
}
return true;
}
else
Expand Down Expand Up @@ -142,6 +156,11 @@ public async Task<bool> DeleteExpenditureAsync(string id)

await AllIDsToBeDeleted.InsertAsync(idToBeDeleted);
db.Dispose();
OfflineExpendituresList.Remove(OfflineExpendituresList.Where(x => x.Id == id).FirstOrDefault());
if (!isBatchUpdate)
{
OfflineExpendituresListChanged?.Invoke();
}
return true;
}
else
Expand Down Expand Up @@ -232,6 +251,7 @@ public async Task<bool> SynchronizeExpendituresAsync(string userEmail, string us

private async Task UpdateLocalDBWithOnlineData(List<ExpendituresModel> tempExpList)
{
isBatchUpdate = true;
foreach (var expOnline in OnlineExpendituresList)
{
if (tempExpList.Exists(x => x.Id == expOnline.Id) && expOnline.UpdateOnSync &&
Expand All @@ -250,6 +270,8 @@ private async Task UpdateLocalDBWithOnlineData(List<ExpendituresModel> tempExpLi
await AddExpenditureAsync(expOnline);
}
}
isBatchUpdate = false;
OfflineExpendituresListChanged?.Invoke();
}

private async Task UpdateOnlineDBWithLocalData(List<ExpendituresModel> tempExpList)
Expand Down
7 changes: 7 additions & 0 deletions FlowHub.Main/AppShell.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
xmlns:viewsExpenditures="clr-namespace:FlowHub.Main.Views.Desktop.Expenditures"
xmlns:viewsIncomes="clr-namespace:FlowHub.Main.Views.Desktop.Incomes"
xmlns:viewsSettings="clr-namespace:FlowHub.Main.Views.Desktop.Settings"
xmlns:viewsStatistics="clr-namespace:FlowHub.Main.Views.Desktop.Statistics"
Shell.NavBarIsVisible="False"
Shell.FlyoutBehavior="Disabled"
CurrentItem ="{x:Reference login}">
Expand Down Expand Up @@ -35,6 +36,12 @@
ContentTemplate="{DataTemplate viewsIncomes:ManageIncomesD}"
Route="ManageIncomes"/>
</Tab>

<Tab Title="Flow Insights">
<ShellContent Title="Flow Insights"
ContentTemplate="{DataTemplate viewsStatistics:StatisticsPageD}"
Route="Statistics"/>
</Tab>

<Tab Title="Planning">
<ShellContent Title="Monthly Plannings"/>
Expand Down
5 changes: 4 additions & 1 deletion FlowHub.Main/AppShell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using FlowHub.Main.Views.Desktop.Expenditures;
using FlowHub.Main.Views.Desktop.Incomes;
using FlowHub.Main.Views.Desktop.Settings;
using FlowHub.Main.Views.Desktop.Statistics;

namespace FlowHub.Main;

Expand All @@ -15,11 +16,13 @@ public AppShell()
Routing.RegisterRoute(nameof(LoginD), typeof(LoginD));

Routing.RegisterRoute(nameof(ManageExpendituresPageD), typeof(ManageExpendituresPageD));

Routing.RegisterRoute(nameof(UpSertExpenditurePageD), typeof(UpSertExpenditurePageD));

Routing.RegisterRoute(nameof(ManageIncomesD), typeof(ManageIncomesD));

Routing.RegisterRoute(nameof(StatisticsPageD), typeof(StatisticsPageD));

Routing.RegisterRoute(nameof(UserSettingsPageD), typeof(UserSettingsPageD));
}
}
3 changes: 3 additions & 0 deletions FlowHub.Main/FlowHub.Main.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
<MauiXaml Update="Views\Desktop\Settings\UserSettingsPageD.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Desktop\Statistics\StatisticsPageD.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Mobile\Expenditures\ManageExpendituresM.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
Expand Down
3 changes: 3 additions & 0 deletions FlowHub.Main/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using FlowHub.Main.Views.Desktop.Expenditures;
using FlowHub.Main.Views.Desktop.Incomes;
using FlowHub.Main.Views.Desktop.Settings;
using FlowHub.Main.Views.Desktop.Statistics;
using FlowHub.Main.Views.Mobile;
using FlowHub.Main.Views.Mobile.Expenditures;
using FlowHub.Main.Views.Mobile.Expenditures.PlannedExpenditures.MonthlyPlannedExp;
Expand Down Expand Up @@ -120,6 +121,8 @@ public static MauiApp CreateMauiApp()
builder.Services.AddSingleton<UpSertMonthlyPlannedExpPageM>();

/* -- Section For Statistics --*/
builder.Services.AddTransient<StatisticsPageD>();

builder.Services.AddTransient<StatisticsPageM>();
builder.Services.AddSingleton<SingleMonthStatsPageM>();
/*--------------------------------------------------------------------------------------------------------------------------------*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static async Task FromUpsertExpToManageExpenditures(Dictionary<string, ob

public static async Task FromManageExpToSingleMonthStats(Dictionary<string, object> navParams)
{
await Shell.Current.GoToAsync(nameof(SingleMonthStatsPageM), true, navParams);
await Shell.Current.GoToAsync(nameof(StatisticsPageM), true, navParams);
}
public static async Task ReturnOnce()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FlowHub.Main.Views.Desktop.Expenditures;
using FlowHub.Main.Views.Desktop.Statistics;

namespace FlowHub.Main.Platforms.NavigationMethods;

Expand All @@ -14,7 +15,7 @@ public static async Task FromUpsertExpToManageExpenditures(Dictionary<string, ob
}
public static async Task FromManageExpToSingleMonthStats(Dictionary<string, object> navParams)
{
//await Shell.Current.GoToAsync(nameof(SingleMonthStatsPageM), true, navParams);
await Shell.Current.GoToAsync(nameof(StatisticsPageD), true, navParams);
}

public static async Task ReturnOnce()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public InputCurrencyForPrintPopUpPage(string DisplayText, string UserCurrency)
DisplayAlertText.Text = DisplayText;
//TODO: Pass the user currency in th title of the popup page and remove this display text


List<string> ListOfCurrencies = new()
{
"AED", // United Arab Emirates Dirham
Expand Down
2 changes: 1 addition & 1 deletion FlowHub.Main/Utilities/EnumConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
return null;
}

private object GetDescription(Enum enumValue)
public static string GetDescription(Enum enumValue)
{
FieldInfo fieldInfo = enumValue.GetType().GetField(enumValue.ToString());
var attribute = (DescriptionAttribute)fieldInfo.GetCustomAttribute(typeof(DescriptionAttribute));
Expand Down
Loading