Compare commits

..

No commits in common. "c3d2c5014a86b28561579f881cda98da1e5b3809" and "8583171b76e67befbbdf324334b209dadcdbf2f1" have entirely different histories.

16 changed files with 56 additions and 159 deletions

View File

@ -4,7 +4,6 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Database;
using AyCode.Utils.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Identity.Client;
using TIAM.Database.DbContexts.Transfers;
@ -21,36 +20,23 @@ public class TransferDestinationDal : DalBase<TransferDestinationDbContext>
public Task<bool> CreateTransferDestinationAsync(TransferDestination transferDestination)
{
if (transferDestination.Id.IsNullOrEmpty())
transferDestination.Id = Guid.NewGuid();
//transferDestination.Created = DateTime.UtcNow;
//transferDestination.Modified = DateTime.UtcNow;
Context.TransferDestinations.Add(transferDestination);
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
}
public async Task<bool> DeleteTransferDestinationAsync(Guid transferDestinationId)
{
var transferDestination = await Context.TransferDestinations.FirstOrDefaultAsync(x => x.Id == transferDestinationId);
if (transferDestination == null)
return true;
Context.TransferDestinations.Remove(transferDestination);
return await Context.SaveChangesAsync() > 0;
}
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination)
{
//transferDestination.Modified = DateTime.UtcNow;
Context.TransferDestinations.Update(transferDestination);
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
}
public Task<TransferDestination?> GetTransferDestinationById(Guid transferDestionationId)
{
return Context.TransferDestinations.FirstOrDefaultAsync(x => x.Id == transferDestionationId);
}
public Task<List<TransferDestination>> GetTransferDestinations()
{
return Context.TransferDestinations.ToListAsync();
}
}

View File

@ -31,8 +31,4 @@
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Emails\" />
</ItemGroup>
</Project>

View File

@ -7,52 +7,22 @@ using System.Text.RegularExpressions;
namespace TIAM.Entities.TransferDestinations
{
public enum PriceType : byte
[Table("TransferDestinations")]
public class TransferDestination : LocationBase, ITimeStampInfo
{
NotSet = 5,
Fix = 10,
Calculated = 15
}
[Table("TransferDestination")]
public class TransferDestination : IEntityGuid, ITimeStampInfo //LocationBase
{
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
public Guid Id { get; set; }
public Guid AddressId { get; set; }
//[Required(ErrorMessage = "The Username value should be specified.")]
public string Name { get; set; }
public string? Name { get; set; }
public string Description { get; set; }
public double Price { get; set; }
public PriceType PriceType { get; set; }
//TEMPORARY!!!
public string AddressString { get; set; }
public string? Description { get; set; }
public DateTime Created { get; set; }
public DateTime Modified { get; set; }
public TransferDestination() { }
public TransferDestination(string addressString) : this(Guid.NewGuid(), addressString) { }
//public TransferDestination(Guid id, double latitude, double longitude, string address) : base(id, latitude, longitude, address) { }
public TransferDestination(Guid id, string addressString)
{
Id = id;
AddressString = addressString;
}
public TransferDestination(Guid id, string name, string addressString) : this(id, addressString)
{
Name = name;
}
public TransferDestination(Guid id, string name, string description, string addressString) : this(id, name, addressString)
{
Description = description;
}
public TransferDestination(double latitude, double longitude, string address) : this(Guid.NewGuid(), latitude, longitude, address) { }
public TransferDestination(Guid id, double latitude, double longitude, string address) : base(Guid.NewGuid(), latitude, longitude, address) { }
public TransferDestination(Guid id, string name, double latitude, double longitude, string address) : base(id, latitude,longitude, address) { }
public TransferDestination(Guid id, string name, string description, double latitude, double longitude, string address) : base(id, latitude,longitude, address) { }
}
}

View File

@ -17,25 +17,11 @@ namespace TIAMMobileApp.Services
this.http = http;
}
public async Task<TransferDestination?> CreateTransferDestination(TransferDestinationWizardModel model)
public async Task<bool> CreateTransferDestination(TransferDestinationWizardModel model)
{
var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}";
var response = await http.PostAsJsonAsync(url, model);
//var result = new WizardProcessorResult();
//if (response.IsSuccessStatusCode)
//{
// result.IsSucces = true;
// result.ResultJson = await response.Content.ReadAsStringAsync();
//}
if (!response.IsSuccessStatusCode)
return null;
var result = (TransferDestination)(await response.Content.ReadFromJsonAsync(typeof(TransferDestination)))!;
return result;
return response.IsSuccessStatusCode;
}
/// <summary>

View File

@ -1,6 +1,5 @@
using TIAM.Entities.TransferDestinations;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models;
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
namespace TIAMMobileApp.Services
@ -17,22 +16,20 @@ namespace TIAMMobileApp.Services
this.userDataService = userDataService;
}
public async Task<TModelType?> ProcessWizardAsync<TModelType>(Type type, object data) where TModelType: class
public async Task<string> ProcessWizardAsync(Type type, object data)
{
switch (type.Name)
{
case "TransferDestinationWizardModel":
var result = await transferDataService.CreateTransferDestination((TransferDestinationWizardModel)data);
return result as TModelType;
//var a = new WizardProcessorResult<TransferDestination>();
//a.Model = result;
//return a as TResult;
if (result)
return "Success";
else
return "Failed";
case "ServiceProvider":
return null;
default:
return null;
return "Not implemented";
}
}

View File

@ -29,7 +29,6 @@
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

View File

@ -3,7 +3,6 @@
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Utility
@using TIAM.Entities.TransferDestinations
@inject LogToBrowserConsole logToBrowserConsole
@inject IWizardProcessor WizardProcessor
<h3>TestPage</h3>
@ -95,8 +94,9 @@
};
public List<string> TransferDestinationIgnorList = new List<string>
{
// "Latitude",
// "Longitude"
"Id",
"Created",
"Modified"
};
@ -130,7 +130,7 @@
public async Task SubmitForm(object Result)
{
var transferDestination = await WizardProcessor.ProcessWizardAsync<TransferDestination>(Result.GetType(), Result);
//await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result);
logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}");
}
}

View File

@ -14,7 +14,7 @@
<ItemGroup>
<PackageReference Include="Blazor.AnimateOnScroll" Version="1.1.0" />
<PackageReference Include="BlazorAnimation" Version="2.2.0" />
<PackageReference Include="DevExpress.Blazor" Version="23.2.3" />
<PackageReference Include="DevExpress.Blazor" Version="23.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.0" />
</ItemGroup>

View File

@ -39,25 +39,11 @@ namespace TIAMWebApp.Client.Services
return await http.GetFromJsonAsync<TransferDestination>(url);
}
public async Task<TransferDestination?> CreateTransferDestination(TransferDestinationWizardModel model)
public async Task<bool> CreateTransferDestination(TransferDestinationWizardModel model)
{
var url = $"{Setting.BaseUrl}/{APIUrls.CreateTransferDestination}";
var response = await http.PostAsJsonAsync(url, model);
//var result = new WizardProcessorResult();
//if (response.IsSuccessStatusCode)
//{
// result.IsSucces = true;
// result.ResultJson = await response.Content.ReadAsStringAsync();
//}
if (!response.IsSuccessStatusCode)
return null;
var result = (TransferDestination)(await response.Content.ReadFromJsonAsync(typeof(TransferDestination)))!;
return result;
return response.IsSuccessStatusCode;
}
}
}

View File

@ -16,18 +16,20 @@ namespace TIAMWebApp.Client.Services
this.userDataService = userDataService;
}
public async Task<TModelType?> ProcessWizardAsync<TModelType>(Type type, object data) where TModelType: class
public async Task<string> ProcessWizardAsync(Type type, object data)
{
switch (type.Name)
{
case "TransferDestinationWizardModel":
var result = await transferDataService.CreateTransferDestination((TransferDestinationWizardModel)data);
return result as TModelType;
if (result)
return "Success";
else
return "Failed";
case "ServiceProvider":
return null;
default:
return null;
return "Not implemented";
}
}

View File

@ -58,7 +58,7 @@ namespace TIAMWebApp.Server.Controllers
[Route("GetTransferDestinationByCoordinates")]
public async Task<TransferDestination?> GetTransferDestinationByCoordinates(double latitude, double longitude)
{
return null;// await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Latitude == latitude && x.Longitude == longitude);
return await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Latitude == latitude && x.Longitude == longitude);
}
[AllowAnonymous]
@ -66,7 +66,7 @@ namespace TIAMWebApp.Server.Controllers
[Route("GetTransferDestinationByAddress")]
public async Task<TransferDestination?> GetTransferDestinationByAddress(string address)
{
return null;//await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Address == address);
return await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Address == address);
}
[AllowAnonymous]
@ -86,30 +86,24 @@ namespace TIAMWebApp.Server.Controllers
if (transferDestinationModel != null)
{
var id = Guid.NewGuid();
TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
var Id = Guid.NewGuid();
TransferDestination transferDestination = new TransferDestination(Id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.Latitude, transferDestinationModel.Longitude, transferDestinationModel.Address);
if (string.IsNullOrEmpty(transferDestinationModel.Name) || string.IsNullOrEmpty(transferDestinationModel.AddressString))
if (string.IsNullOrEmpty(transferDestinationModel.Name) || string.IsNullOrEmpty(transferDestinationModel.Address))
{
return BadRequest("Invalid request");
}
else
{
Console.WriteLine($"TransferDestination to be created: {id}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.Name}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.Price}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.PriceType}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.AddressString}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.Description}");
transferDestination.AddressId = Guid.Empty;
transferDestination.Price = 15000;
transferDestination.PriceType = PriceType.Fix;
Console.WriteLine($"TransferDestination to be created: {Id}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.Latitude}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.Longitude}");
Console.WriteLine($"TransferDestination to be created: {transferDestination.Address}");
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
await _transferDestinationDal.CreateTransferDestinationAsync(transferDestination);
return Ok(transferDestination);
return Ok("yes");
}
}

View File

@ -9,6 +9,6 @@ namespace TIAMWebApp.Shared.Application.Interfaces
Task<TransferDestination[]> GetDestinationsAsync();
Task<TransferDestination?> GetTransferDestinationbyCoordinatesAsync(string destinationId);
Task<TransferDestination?> GetTransferDestinationbyAddressAsync(string destinationId);
Task<TransferDestination?> CreateTransferDestination(TransferDestinationWizardModel model);
Task<bool> CreateTransferDestination(TransferDestinationWizardModel model);
}
}

View File

@ -8,7 +8,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
{
public interface IWizardProcessor
{
public Task<TModelType?> ProcessWizardAsync<TModelType>(Type type, object data) where TModelType : class;
public Task<string> ProcessWizardAsync(Type type, object data);
public Task<string> ValidateWizardStepAsync(Type type, string fieldName, object fieldValue);
}

View File

@ -1,8 +0,0 @@
namespace TIAMWebApp.Shared.Application.Interfaces;
public interface IWizardProcessorResult<TModelType>
{
public TModelType Model { get; set; }
public string ResultJson { get; set; }
public bool IsSucces { get; set; }
}

View File

@ -18,24 +18,23 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
[Required(ErrorMessage = "The Destination name should be specified.")]
[DataType(DataType.Text)]
[Display(Name = ResourceKeys.DestinationName, ResourceType = typeof(TIAMResources))]
public string Name { get; set; }
public string? Name { get; set; }
[Required(ErrorMessage = "The Destination info should be specified.")]
[DataType(DataType.MultilineText)]
[Display(Name = ResourceKeys.DestinationInfo, ResourceType = typeof(TIAMResources))]
public string Description { get; set; }
public string? Description { get; set; }
[Required(ErrorMessage = "The address should be specified.")]
[DataType(DataType.Text)]
[Display(Name = ResourceKeys.DestinationAddress, ResourceType = typeof(TIAMResources))]
public string AddressString { get; set; }
//[DataType("Latitude")]
//[Display(Name = "Destination latitude")]
//public double Latitude { get; set; }
//[DataType("Longitude")]
//[Display(Name = "Destination longitude")]
//public double Longitude { get; set; }
public string? Address { get; set; }
[DataType("Latitude")]
[Display(Name = "Destination latitude")]
public double Latitude { get; set; }
[DataType("Longitude")]
[Display(Name = "Destination longitude")]
public double Longitude { get; set; }
public TransferDestinationWizardModel() { }

View File

@ -1,10 +0,0 @@
using TIAMWebApp.Shared.Application.Interfaces;
namespace TIAMWebApp.Shared.Application.Models;
public class WizardProcessorResult<TModel> : IWizardProcessorResult<TModel>
{
public TModel Model { get; set; }
public string ResultJson { get; set; }
public bool IsSucces { get; set; }
}