AddUser, RemoveUser tests, etc...
This commit is contained in:
parent
3dd820d9cd
commit
b871cf51df
|
|
@ -3,12 +3,12 @@
|
|||
<Version>10</Version>
|
||||
<SourceModelProvider>
|
||||
<ConnectionBasedModelProvider>
|
||||
<ConnectionString>Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Persist Security Info=False;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Command Timeout=0</ConnectionString>
|
||||
<ConnectionString>Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Persist Security Info=True;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Command Timeout=0</ConnectionString>
|
||||
</ConnectionBasedModelProvider>
|
||||
</SourceModelProvider>
|
||||
<TargetModelProvider>
|
||||
<ConnectionBasedModelProvider>
|
||||
<ConnectionString>Data Source=185.51.190.197;Initial Catalog=TIAM_PROD;Persist Security Info=True;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Command Timeout=0</ConnectionString>
|
||||
<ConnectionString>Data Source=185.51.190.197;Initial Catalog=TIAM_DEVRELEASE;Persist Security Info=True;User ID=Anata_Development_Team;Pooling=False;Multiple Active Result Sets=False;Connect Timeout=60;Encrypt=True;Trust Server Certificate=True;Command Timeout=0</ConnectionString>
|
||||
</ConnectionBasedModelProvider>
|
||||
</TargetModelProvider>
|
||||
<SchemaCompareSettingsService>
|
||||
|
|
@ -13,6 +13,7 @@ using TIAM.Entities.Products;
|
|||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Entities.Profiles;
|
||||
|
||||
namespace TIAM.Database.Test
|
||||
{
|
||||
|
|
@ -566,6 +567,51 @@ namespace TIAM.Database.Test
|
|||
}
|
||||
|
||||
#endregion EmailMessage
|
||||
}
|
||||
}
|
||||
|
||||
#region User
|
||||
[DataTestMethod]
|
||||
[DataRow(["e31044d7-1771-4a32-8dd9-6f9853ed53c6", "0a831191-70a3-4504-9ec4-c5902affaba7", "8eed080c-d2ce-4cc3-bcfe-2268c220bba7", "addUser_test9432@tiam.hu"])]
|
||||
public async Task AddUserTest(string[] userIdProfileIdAddressIdEmailStrings)
|
||||
{
|
||||
var userId = Guid.Parse(userIdProfileIdAddressIdEmailStrings[0]);
|
||||
var profileId = Guid.Parse(userIdProfileIdAddressIdEmailStrings[1]);
|
||||
var addressId = Guid.Parse(userIdProfileIdAddressIdEmailStrings[2]);
|
||||
var email = userIdProfileIdAddressIdEmailStrings[3];
|
||||
|
||||
var fromAddress = "Budapest, Liszt Ferenc tér";
|
||||
var toAddress = "1211 Budapest, Kossuth Lajos utca 145";
|
||||
//var userProductToCarId = Guid.Parse("97179a87-d99f-4f12-b7b2-75e21aaec6ab");
|
||||
|
||||
await Dal.RemoveUserAsync(userId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
|
||||
|
||||
var user = new User(userId, email, "235664", "dsfglfjg45r34903t3kggvq");
|
||||
//user.ProfileId = profileId;
|
||||
|
||||
var profile = new Profile();
|
||||
profile.Id = profileId;;
|
||||
profile.Name = "Add user test name";
|
||||
|
||||
var address = new Address();
|
||||
address.Id = addressId;
|
||||
address.Latitude = 5362.2341652256;
|
||||
address.Longitude = 5362.2341333317;
|
||||
address.AddressText = "1214 Kossuth Lajos utca 124.";
|
||||
|
||||
user.Profile = profile;
|
||||
user.Profile.Address = address;
|
||||
|
||||
Assert.IsTrue(await Dal.AddUser(user));
|
||||
user = Dal.GetUserById(userId);
|
||||
|
||||
Assert.IsNotNull(user);
|
||||
Assert.IsNotNull(user.Profile);
|
||||
Assert.IsNotNull(user.Profile.Address);
|
||||
|
||||
Assert.IsTrue(await Dal.RemoveUserAsync(userId)); //mielőbb kitöröljük, h ne maradjon szemét a db-ben - J.
|
||||
|
||||
user = Dal.GetUserById(userId);
|
||||
Assert.IsNull(user); //a korábbi törlés miatt NULL kell legyen - J.
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ using TIAM.Database.DbSets.Permissions;
|
|||
using TIAM.Database.DbSets.Products;
|
||||
using TIAM.Database.DbSets.Transfers;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Addresses;
|
||||
using TIAM.Entities.Drivers;
|
||||
using TIAM.Entities.Emails;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Profiles;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Entities.Users;
|
||||
|
|
@ -92,6 +94,27 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
public string? GetUserJsonById(Guid userId) => Session(ctx => ctx.GetUserById(userId)?.ToJson());
|
||||
public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
|
||||
|
||||
public Task<bool> AddUser(User user) => TransactionAsync(ctx => ctx.AddUser(user));
|
||||
|
||||
public Task<bool> AddUser(User user, string profileName, Address address)
|
||||
{
|
||||
return TransactionAsync(ctx =>
|
||||
{
|
||||
var profile = Activator.CreateInstance<Profile>();
|
||||
|
||||
profile.Id = Guid.NewGuid();
|
||||
profile.Name = profileName;
|
||||
profile.Address = address;
|
||||
|
||||
user.Profile= profile;
|
||||
|
||||
return ctx.AddUser(user);
|
||||
});
|
||||
}
|
||||
|
||||
public Task<bool> RemoveUserAsync(User user) => TransactionAsync(ctx => ctx.RemoveUserAsync(user));
|
||||
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUserAsync(userId));
|
||||
|
||||
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
|
||||
|
||||
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ namespace TIAMWebApp.Server.Services
|
|||
public class TransferBackendService
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
public AdminDal _adminDal;
|
||||
private readonly AdminDal _adminDal;
|
||||
|
||||
public TransferBackendService(IConfiguration configuration, AdminDal adminDal)
|
||||
{
|
||||
|
|
@ -42,14 +42,14 @@ namespace TIAMWebApp.Server.Services
|
|||
var price = GetSeatNumberPrice(in tranferDestinationPrice, seatNumber);
|
||||
|
||||
//TODO: ExtraPrice - J.
|
||||
|
||||
//if (baseDestination.Id == fromTransferDestination.Id && )
|
||||
return price;
|
||||
}
|
||||
|
||||
public double GetSeatNumberPrice(in ITransfeDestinationPrices transfeDestinationPrices, in byte seatNumber)
|
||||
=> GetSeatNumberPrice(transfeDestinationPrices.Price, transfeDestinationPrices.Price2, transfeDestinationPrices.Price3, seatNumber);
|
||||
|
||||
public double GetSeatNumberPrice(in double price, in double? price2, in double? price3, in byte seatNumber)
|
||||
public double GetSeatNumberPrice(double price, in double? price2, in double? price3, in byte seatNumber)
|
||||
{
|
||||
return seatNumber switch
|
||||
{
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TIAM.Resources", "TIAMResou
|
|||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DD32C7C2-218C-4148-8FD6-1AB3C824A7D5}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
SqlSchemaCompare_Dev_to_Prod.scmp = SqlSchemaCompare_Dev_to_Prod.scmp
|
||||
SqlSchemaCompare_Dev_to_DevRelease.scmp = SqlSchemaCompare_Dev_to_DevRelease.scmp
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
|
|
|
|||
Loading…
Reference in New Issue