Cleaning up the solution. Separating Shared.WinRT, Services and Synchronization. Removing synchronization from app. Reducing bundle size by 45mb.

This commit is contained in:
Burak Kaan Köse
2024-07-21 05:45:02 +02:00
parent f112f369a7
commit 495885e006
523 changed files with 2254 additions and 2375 deletions

View File

@@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MimeKit;
using SqlKata;
using Wino.Domain.Entities;
using Wino.Domain.Interfaces;
using Wino.Services.Extensions;
namespace Wino.Services.Services
{
public class ContactService : BaseDatabaseService, IContactService
{
public ContactService(IDatabaseService databaseService) : base(databaseService) { }
public Task<List<AddressInformation>> GetAddressInformationAsync(string queryText)
{
if (queryText == null || queryText.Length < 2)
return Task.FromResult<List<AddressInformation>>(null);
var query = new Query(nameof(AddressInformation));
query.WhereContains("Address", queryText);
query.OrWhereContains("Name", queryText);
var rawLikeQuery = query.GetRawQuery();
return Connection.QueryAsync<AddressInformation>(rawLikeQuery);
}
public async Task<AddressInformation> GetAddressInformationByAddressAsync(string address)
{
return await Connection.Table<AddressInformation>().Where(a => a.Address == address).FirstOrDefaultAsync()
?? new AddressInformation() { Name = address, Address = address };
}
public async Task SaveAddressInformationAsync(MimeMessage message)
{
var recipients = message
.GetRecipients(true)
.Where(a => !string.IsNullOrEmpty(a.Name) && !string.IsNullOrEmpty(a.Address));
var addressInformations = recipients.Select(a => new AddressInformation() { Name = a.Name, Address = a.Address });
foreach (var info in addressInformations)
await Connection.InsertOrReplaceAsync(info).ConfigureAwait(false);
}
}
}