TransferDetinations improvements, fixes, etc...
This commit is contained in:
parent
2751573edd
commit
c3d2c5014a
|
|
@ -21,9 +21,6 @@ public class TransferDestinationDal : DalBase<TransferDestinationDbContext>
|
||||||
|
|
||||||
public Task<bool> CreateTransferDestinationAsync(TransferDestination transferDestination)
|
public Task<bool> CreateTransferDestinationAsync(TransferDestination transferDestination)
|
||||||
{
|
{
|
||||||
//transferDestination.Created = DateTime.UtcNow;
|
|
||||||
//transferDestination.Modified = DateTime.UtcNow;
|
|
||||||
|
|
||||||
if (transferDestination.Id.IsNullOrEmpty())
|
if (transferDestination.Id.IsNullOrEmpty())
|
||||||
transferDestination.Id = Guid.NewGuid();
|
transferDestination.Id = Guid.NewGuid();
|
||||||
|
|
||||||
|
|
@ -31,17 +28,29 @@ public class TransferDestinationDal : DalBase<TransferDestinationDbContext>
|
||||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
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)
|
public Task<bool> UpdateTransferDestinationAsync(TransferDestination transferDestination)
|
||||||
{
|
{
|
||||||
//transferDestination.Modified = DateTime.UtcNow;
|
|
||||||
Context.TransferDestinations.Update(transferDestination);
|
Context.TransferDestinations.Update(transferDestination);
|
||||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
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()
|
public Task<List<TransferDestination>> GetTransferDestinations()
|
||||||
{
|
{
|
||||||
|
|
||||||
return Context.TransferDestinations.ToListAsync();
|
return Context.TransferDestinations.ToListAsync();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -31,4 +31,8 @@
|
||||||
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
<ProjectReference Include="..\TIAM.Core\TIAM.Core.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Emails\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -7,27 +7,49 @@ using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace TIAM.Entities.TransferDestinations
|
namespace TIAM.Entities.TransferDestinations
|
||||||
{
|
{
|
||||||
[Table("TransferDestinations")]
|
public enum PriceType : byte
|
||||||
public class TransferDestination : LocationBase, ITimeStampInfo
|
|
||||||
{
|
{
|
||||||
//[Required(ErrorMessage = "The Username value should be specified.")]
|
NotSet = 5,
|
||||||
public string? Name { get; set; }
|
Fix = 10,
|
||||||
|
Calculated = 15
|
||||||
|
}
|
||||||
|
|
||||||
public string? Description { get; set; }
|
[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 Description { get; set; }
|
||||||
|
|
||||||
|
public double Price { get; set; }
|
||||||
|
public PriceType PriceType { get; set; }
|
||||||
|
|
||||||
|
//TEMPORARY!!!
|
||||||
|
public string AddressString { get; set; }
|
||||||
|
|
||||||
public DateTime Created { get; set; }
|
public DateTime Created { get; set; }
|
||||||
public DateTime Modified { get; set; }
|
public DateTime Modified { get; set; }
|
||||||
|
|
||||||
public TransferDestination() { }
|
public TransferDestination() { }
|
||||||
public TransferDestination(double latitude, double longitude, string address) : this(Guid.NewGuid(), latitude, longitude, address) { }
|
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, double latitude, double longitude, string address) : base(id, latitude, longitude, address) { }
|
||||||
|
|
||||||
public TransferDestination(Guid id, string name, double latitude, double longitude, string address) : this(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;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransferDestination(Guid id, string name, string description, double latitude, double longitude, string address) : this(id, name, latitude, longitude, address)
|
public TransferDestination(Guid id, string name, string description, string addressString) : this(id, name, addressString)
|
||||||
{
|
{
|
||||||
Description = description;
|
Description = description;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,8 @@
|
||||||
};
|
};
|
||||||
public List<string> TransferDestinationIgnorList = new List<string>
|
public List<string> TransferDestinationIgnorList = new List<string>
|
||||||
{
|
{
|
||||||
"Latitude",
|
// "Latitude",
|
||||||
"Longitude"
|
// "Longitude"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Route("GetTransferDestinationByCoordinates")]
|
[Route("GetTransferDestinationByCoordinates")]
|
||||||
public async Task<TransferDestination?> GetTransferDestinationByCoordinates(double latitude, double longitude)
|
public async Task<TransferDestination?> GetTransferDestinationByCoordinates(double latitude, double longitude)
|
||||||
{
|
{
|
||||||
return await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Latitude == latitude && x.Longitude == longitude);
|
return null;// await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Latitude == latitude && x.Longitude == longitude);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
|
@ -66,7 +66,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Route("GetTransferDestinationByAddress")]
|
[Route("GetTransferDestinationByAddress")]
|
||||||
public async Task<TransferDestination?> GetTransferDestinationByAddress(string address)
|
public async Task<TransferDestination?> GetTransferDestinationByAddress(string address)
|
||||||
{
|
{
|
||||||
return await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Address == address);
|
return null;//await _transferDestinationDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.Address == address);
|
||||||
}
|
}
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
|
|
@ -87,19 +87,25 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
var id = Guid.NewGuid();
|
var id = Guid.NewGuid();
|
||||||
TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.Latitude, transferDestinationModel.Longitude, transferDestinationModel.Address);
|
TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(transferDestinationModel.Name) || string.IsNullOrEmpty(transferDestinationModel.Address))
|
if (string.IsNullOrEmpty(transferDestinationModel.Name) || string.IsNullOrEmpty(transferDestinationModel.AddressString))
|
||||||
{
|
{
|
||||||
return BadRequest("Invalid request");
|
return BadRequest("Invalid request");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($"TransferDestination to be created: {id}");
|
Console.WriteLine($"TransferDestination to be created: {id}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.Latitude}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Name}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.Longitude}");
|
Console.WriteLine($"TransferDestination to be created: {transferDestination.Price}");
|
||||||
Console.WriteLine($"TransferDestination to be created: {transferDestination.Address}");
|
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;
|
||||||
|
|
||||||
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||||
await _transferDestinationDal.CreateTransferDestinationAsync(transferDestination);
|
await _transferDestinationDal.CreateTransferDestinationAsync(transferDestination);
|
||||||
|
|
|
||||||
|
|
@ -18,23 +18,24 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
[Required(ErrorMessage = "The Destination name should be specified.")]
|
[Required(ErrorMessage = "The Destination name should be specified.")]
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[Display(Name = ResourceKeys.DestinationName, ResourceType = typeof(TIAMResources))]
|
[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.")]
|
[Required(ErrorMessage = "The Destination info should be specified.")]
|
||||||
[DataType(DataType.MultilineText)]
|
[DataType(DataType.MultilineText)]
|
||||||
[Display(Name = ResourceKeys.DestinationInfo, ResourceType = typeof(TIAMResources))]
|
[Display(Name = ResourceKeys.DestinationInfo, ResourceType = typeof(TIAMResources))]
|
||||||
public string? Description { get; set; }
|
public string Description { get; set; }
|
||||||
|
|
||||||
[Required(ErrorMessage = "The address should be specified.")]
|
[Required(ErrorMessage = "The address should be specified.")]
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[Display(Name = ResourceKeys.DestinationAddress, ResourceType = typeof(TIAMResources))]
|
[Display(Name = ResourceKeys.DestinationAddress, ResourceType = typeof(TIAMResources))]
|
||||||
public string? Address { get; set; }
|
public string AddressString { get; set; }
|
||||||
[DataType("Latitude")]
|
|
||||||
[Display(Name = "Destination latitude")]
|
//[DataType("Latitude")]
|
||||||
public double Latitude { get; set; }
|
//[Display(Name = "Destination latitude")]
|
||||||
[DataType("Longitude")]
|
//public double Latitude { get; set; }
|
||||||
[Display(Name = "Destination longitude")]
|
//[DataType("Longitude")]
|
||||||
public double Longitude { get; set; }
|
//[Display(Name = "Destination longitude")]
|
||||||
|
//public double Longitude { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public TransferDestinationWizardModel() { }
|
public TransferDestinationWizardModel() { }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue