Merge branch 'master' of http://git2.aycode.com/Adam/TourIAm
This commit is contained in:
commit
41b084ade4
|
|
@ -8,7 +8,7 @@ using AyCode.Database.DataLayers.Users;
|
|||
using AyCode.Utils.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Database.DataLayers.ServiceProviders;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Database.DbContexts.Admins;
|
||||
using TIAM.Database.DbContexts.ServiceProviders;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
using AyCode.Database.DbSets.Users;
|
||||
using AyCode.Models.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.DataLayers.ServiceProviders;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DbContexts.Admins;
|
||||
using TIAM.Database.DbSets.Permissions;
|
||||
using TIAM.Database.DbSets.Products;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Products.DTOs;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAM.Models.Dtos.Users;
|
||||
|
|
@ -20,6 +23,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
}
|
||||
|
||||
public TransferDestination? GetTransferDestinationById(Guid transferDestinationId, bool autoInclude = false) => Session(ctx=>ctx.TransferDestinations.FirstOrDefault(x=>x.Id == transferDestinationId));
|
||||
public string? GetTransferDestinationJsonById(Guid transferDestinationId) => Session(ctx => ctx.TransferDestinations.FirstOrDefault(x => x.Id == transferDestinationId)?.ToJson());
|
||||
|
||||
public User? GetUserById(Guid userId, bool autoInclude = false) => Session(x => x.GetUserById(userId, autoInclude));
|
||||
public User? GetUserByEmail(string email, bool autoInclude = false) => Session(x => x.GetUserByEmail(email, autoInclude));
|
||||
|
|
@ -32,6 +36,7 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
|
||||
|
||||
public Product? GetProductById(Guid contextId) => Session(x => x.GetProductById(contextId));
|
||||
public Task<bool> AddProduct(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
|
||||
|
||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(x => x.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||
|
||||
|
|
@ -45,43 +50,440 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
=> Session(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
|
||||
|
||||
public Task<List<PermissionContextMapping>> GetPermissionContextsViewByContextIdAsync(Guid contextId)
|
||||
=> SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
|
||||
=> SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
|
||||
|
||||
//public Task<List<User>> GetUsersAsync()
|
||||
//{
|
||||
// return Context.Users.ToListAsync();
|
||||
//}
|
||||
//15. (IServiceProviderDataService) Create service provider
|
||||
public Task<bool> CreateServiceProviderAsync(TiamServiceProvider serviceProvider)
|
||||
{
|
||||
Context.CreateServiceProvider(serviceProvider);
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
|
||||
//public Task<User?> GetUserByEmailAsync(string email)
|
||||
//{
|
||||
// Console.WriteLine($"Getting user from db {email}");
|
||||
// var emailLower = email.ToLower();
|
||||
// return Context.Users.SingleOrDefaultAsync(x=>x.EmailAddress.ToLower() == emailLower);
|
||||
//}
|
||||
public bool CreateProductAsync(Product product)
|
||||
{
|
||||
Context.CreateProduct(product);
|
||||
Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
|
||||
var _result = Context.SaveChangesAsync();
|
||||
return _result.Result > 0;
|
||||
}
|
||||
|
||||
//public Task<bool> CreateUserAsync(User user)
|
||||
//{
|
||||
// user.Created = DateTime.UtcNow;
|
||||
// user.Modified = DateTime.UtcNow;
|
||||
// Context.Users.Add(user);
|
||||
// Console.WriteLine($"Saving user to db {user.Id}, {user.EmailAddress}, {user.PhoneNumber}, {user.Password}");
|
||||
// return Context.SaveChangesAsync().ContinueWith(x=>x.Result > 0);
|
||||
//}
|
||||
public Task<List<TiamServiceProvider>> GetServiceProvidersAsync()
|
||||
{
|
||||
return Context.ServiceProviders.ToListAsync();
|
||||
}
|
||||
|
||||
public virtual Task<TiamServiceProvider?> GetServiceProviderByIdAsync(Guid id)
|
||||
{
|
||||
Console.WriteLine($"Getting serviceProvider from db {id}");
|
||||
return Context.ServiceProviders.SingleOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
|
||||
{
|
||||
Context.UserProductMappings.Add(userProductMapping);
|
||||
Console.WriteLine($"Saving userProductMapping to db {userProductMapping.Id}, {userProductMapping.ProductId}, {userProductMapping.UserId}");
|
||||
return Context.SaveChangesAsync().ContinueWith(x => userProductMapping);
|
||||
}
|
||||
|
||||
#region ServiceProviders
|
||||
|
||||
//14. (IserviceProviderDataService) Update service provider
|
||||
public Task<bool> UpdateServiceProviderAsync(TiamServiceProvider serviceProvider)
|
||||
{
|
||||
var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
|
||||
if (dbServiceProvider != null)
|
||||
{
|
||||
dbServiceProvider = serviceProvider;
|
||||
Context.ServiceProviders.Update(dbServiceProvider);
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("ServiceProvider not found");
|
||||
}
|
||||
}
|
||||
|
||||
//13. (IserviceProviderDataService) delete service provider
|
||||
public Task<bool> DeleteServiceProviderAsync(Guid id)
|
||||
{
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == id);
|
||||
if (dbServiceProvider != null)
|
||||
{
|
||||
//get products for this provider
|
||||
var products = Context.Products.Where(x => x.ServiceProviderId == id).ToList();
|
||||
|
||||
/*foreach (var productItem in products)
|
||||
{
|
||||
//delete products
|
||||
var permissionContextMappings = Context.PermissionContextMappings.Where(x => x.ContextId == productItem.Id).ToList();
|
||||
//iterate through every row
|
||||
foreach (var item in permissionContextMappings)
|
||||
{
|
||||
|
||||
if (item.SubjectType == (int)PermissionContextMappingSubjectType.Group)
|
||||
{
|
||||
//get users in the permissiongroup
|
||||
var permissionGroupUserMapping = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == item.Id).ToList();
|
||||
//remove every row (users) from permissiongroup
|
||||
foreach (var user in permissionGroupUserMapping)
|
||||
{
|
||||
Context.PermissionGroupUserMappings.Remove(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
//remove permissioncontextmappings
|
||||
Context.PermissionContextMappings.RemoveRange(permissionContextMappings);
|
||||
}*/
|
||||
Context.Products.RemoveRange(products);
|
||||
Context.ServiceProviders.Remove(dbServiceProvider);
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//17. (IServiceProviderDataService) get service provider by ownerId
|
||||
public Task<List<TiamServiceProvider>> GetServiceProvidersByOwnerIdAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PermissionTypes
|
||||
|
||||
|
||||
//10. (IPermissionService) create permission type
|
||||
public Task<bool> CreatePermissionsTypeAsync(PermissionsType permissionsType)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var existingPermission = Context.PermissionsTypes
|
||||
.FirstOrDefault(x => x.PermissionName == permissionsType.PermissionName)?.PermissionName;
|
||||
|
||||
if (existingPermission == null)
|
||||
{
|
||||
//get all the permissiontypes for this context
|
||||
var permissionTypes = new List<PermissionsType>();
|
||||
var nextBitValue = 0.0;
|
||||
permissionTypes = Context.PermissionsTypes
|
||||
.Where(x => x.ContextId == permissionsType.ContextId)
|
||||
.ToList();
|
||||
|
||||
//get the max value of the permissiontypes
|
||||
if (permissionTypes != null)
|
||||
{
|
||||
//next bit value is the power of two of the count of the permissiontypes
|
||||
nextBitValue = Math.Pow(2, permissionTypes.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextBitValue = Math.Pow(2, 0);
|
||||
}
|
||||
permissionsType.PermissionBit = (int)nextBitValue;
|
||||
Context.PermissionsTypes.Add(permissionsType);
|
||||
Context.SaveChanges();
|
||||
transaction.Commit();
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
|
||||
}
|
||||
|
||||
//11. (IPermissionService) get permission types for context
|
||||
public Task<List<PermissionsType>>? GetPermissionTypesByContextIdAsync(Guid contextId)
|
||||
{
|
||||
return Context.PermissionsTypes.Where(x => x.ContextId == contextId).ToListAsync();
|
||||
}
|
||||
|
||||
public Task<int> GetPermissionFromPermissionType(PermissionsType pType)
|
||||
{
|
||||
if (Context.PermissionsTypes.FirstOrDefault(x => x.Id == pType.Id) != null)
|
||||
{
|
||||
return Task.FromResult(pType.PermissionBit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PermissionMappings
|
||||
|
||||
public Task<List<AssignedPermissionModel>> GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId(Guid contextId)
|
||||
{
|
||||
List<AssignedPermissionModel> result = new List<AssignedPermissionModel>();
|
||||
|
||||
var UserProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToListAsync();
|
||||
|
||||
if (UserProductMappings.Result != null)
|
||||
{
|
||||
foreach (var item in UserProductMappings.Result)
|
||||
{
|
||||
var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToListAsync();
|
||||
if (mappingRow.Result == null)
|
||||
{
|
||||
//user has no permission but is assigned... must be banned
|
||||
|
||||
}
|
||||
else if (mappingRow.Result.Count > 1)
|
||||
{
|
||||
//user has been assigned more than onece to same context
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var mapping in mappingRow.Result)
|
||||
{
|
||||
result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var AssingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToListAsync();
|
||||
|
||||
if (AssingedGroups.Result != null)
|
||||
{
|
||||
foreach (var group in AssingedGroups.Result)
|
||||
{
|
||||
var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToListAsync();
|
||||
if (mappingRow.Result == null)
|
||||
{
|
||||
//group has no permission but is assigned...
|
||||
|
||||
}
|
||||
else if (mappingRow.Result.Count > 1)
|
||||
{
|
||||
//group has been assigned more than onece to same context
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var mapping in mappingRow.Result)
|
||||
{
|
||||
result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
foreach (var row in result)
|
||||
{
|
||||
Console.WriteLine($"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}");
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//12. (IPermissionService) get permission groups for context
|
||||
public Task<List<PermissionContextMapping>> GetPermissionsForContextByContextIdAsync(Guid contextId)
|
||||
{
|
||||
List<PermissionContextMapping> permissionContextMappings = new List<PermissionContextMapping>();
|
||||
//get all Groups where the contextId is the same
|
||||
var groups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).Select(x => x.Id).ToHashSet();
|
||||
permissionContextMappings = Context.PermissionContextMappings.Where(x => groups.Contains(x.SubjectId)).ToList();
|
||||
|
||||
//foreach (var item in groups.Result)
|
||||
//{
|
||||
// //get permissioncontextmapping for the group if there is, so we know what permissions the group has
|
||||
// var pCm = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == item.Id);
|
||||
// permissionContextMappings.Add(pCm);
|
||||
//}
|
||||
return Task.FromResult(permissionContextMappings);
|
||||
}
|
||||
|
||||
//9. (IPermissionService) add user to permission group
|
||||
public Task<bool> AddUserToPermissionGroupAsync(Guid permissionGroupId, Guid userId)
|
||||
{
|
||||
bool result = false;
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
//do we need to check if PermissionContextMappingId exists?
|
||||
var permissionGroupUserMapping = new PermissionGroupUserMapping(userId, permissionGroupId);
|
||||
Context.PermissionGroupUserMappings.Add(permissionGroupUserMapping);
|
||||
Context.SaveChanges();
|
||||
transaction.Commit();
|
||||
result = true;
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//8. (IPermissionService) create permission group
|
||||
public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, TiamServiceProvider serviceProvider)
|
||||
{
|
||||
bool result = false;
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var existingPermissionGroup = Context.PermissionGroups.FirstOrDefault(x => x.GroupName == permissionGroup.GroupName)?.GroupName;
|
||||
if (existingPermissionGroup == null)
|
||||
{
|
||||
//create permission type 1 for the group
|
||||
var permissionType = new PermissionsType(serviceProvider.Id, "View");
|
||||
Context.CreatePermissionsType(permissionType);
|
||||
|
||||
//Create PermissionContextMapping for the group
|
||||
|
||||
//create Id for the group
|
||||
Guid Id = Guid.NewGuid();
|
||||
permissionGroup.Id = Id;
|
||||
var permissionContextMapping = new PermissionContextMapping(serviceProvider.Id, Id, PermissionContextMappingSubjectType.Group, 1, true);
|
||||
Context.CreatePermissionContextMapping(permissionContextMapping);
|
||||
Context.CreatePermissionGroup(permissionGroup);
|
||||
Context.SaveChanges();
|
||||
transaction.Commit();
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//group with same name already exists
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
public List<UserProductMapping> GetUserProductMappingsInPermissionGroupByGroupId(Guid groupId)
|
||||
{
|
||||
return Context.GetUserProductMappingsByPermissionGroupId(groupId).ToList();
|
||||
//List<UserProductMapping> userProductMappings = new List<UserProductMapping>();
|
||||
|
||||
////let's get the permissioncontextmapping for the group
|
||||
//var pCm = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == groupId);
|
||||
//Guid pCmId = pCm.Id;
|
||||
|
||||
////let's get the permissiongroupusermappings for the permissioncontextmapping
|
||||
//var pGum = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == pCmId).ToList();
|
||||
//if (pGum.Count > 0)
|
||||
//{
|
||||
// foreach (var group in pGum)
|
||||
// {
|
||||
// userProductMappings.Add(Context.UserProductMappings.FirstOrDefault(x => x.Id == group.UserProductMappingId));
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
//return Task.FromResult(userProductMappings);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Products
|
||||
|
||||
//* 20. (IServiceProviderDataService) Update product
|
||||
public Product UpdateProduct(Product product)
|
||||
{
|
||||
|
||||
var prod = Context.UpdateProduct(product);
|
||||
Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
|
||||
Context.SaveChanges();
|
||||
return prod;
|
||||
}
|
||||
|
||||
//* 21. (IServiceProviderDataService) delete product
|
||||
public Task<bool> DeleteProductByIdAsync(Guid productId)
|
||||
{
|
||||
return TransactionAsync(ctx =>
|
||||
{
|
||||
ctx.DeleteProductById(productId);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
//4. (IPermissionService) AssignPermissionToUserForContextAsync
|
||||
public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission)
|
||||
{
|
||||
var _assIgnedUser = Context.UserProductMappings.FirstOrDefault(x => x.Id == userProductMapping.Id);
|
||||
|
||||
if (_assIgnedUser != null)
|
||||
{
|
||||
//user exists
|
||||
var _permissionInt = GetPermissionFromPermissionType(permission);
|
||||
|
||||
var permissionContextMapping = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == userProductMapping.Id);
|
||||
var currentPermissions = permissionContextMapping.Permissions;
|
||||
var newPermissions = currentPermissions + _permissionInt.Result;
|
||||
permissionContextMapping.Permissions = newPermissions;
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//user does not exist, let's create it
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region UserProductMappings
|
||||
|
||||
//23. (IServiceProviderDataService) Get Assigned Users By ProductId
|
||||
public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId)
|
||||
{
|
||||
return Context.UserProductMappings.Where(x => x.ProductId == productId).ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
//24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
|
||||
public Task RemoveUserProductMappingsByContextId(Guid productId)
|
||||
{
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var userProductMappings = Context.UserProductMappings.Where(x => x.ProductId == productId).ToList();
|
||||
//remove userProductMappings
|
||||
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//25. (IServiceProviderDataService) Remove Assigned from product by userProductMappingId
|
||||
public Task<bool> RemoveUserProductMappingAsync(UserProductMapping userProductMapping, bool removeFromGroups)
|
||||
{
|
||||
return TransactionAsync(ctx =>
|
||||
{
|
||||
var result = false;
|
||||
var userProductMappingToRemove = ctx.UserProductMappings.FirstOrDefault(x => x.Id == userProductMapping.Id);
|
||||
|
||||
//remove userProductMappings
|
||||
if (userProductMappingToRemove == null) return false;
|
||||
|
||||
|
||||
if (removeFromGroups)
|
||||
{
|
||||
//remove permissiongroupusermappings
|
||||
ctx.RemoveAssingedUserFromPermissionGroups(userProductMappingToRemove.Id);
|
||||
}
|
||||
|
||||
ctx.UserProductMappings.Remove(userProductMappingToRemove);
|
||||
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
//public Task<bool> UpdateUserAsync(User user)
|
||||
//{
|
||||
// var existingUser = Context.Users.FirstOrDefault(u => u.EmailAddress == user.EmailAddress);
|
||||
// if (existingUser != null)
|
||||
// {
|
||||
// //user.Modified = DateTime.UtcNow; //ezt nem kell megadni, a háttérben ezt magától megcsinálja a DbContextBase - J.
|
||||
// existingUser = user;
|
||||
// Context.Users.Update(existingUser);
|
||||
// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// throw new Exception("User not found");
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,202 @@
|
|||
using AyCode.Interfaces.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAM.Database.DbContexts.Admins;
|
||||
using TIAM.Database.DbContexts.ServiceProviders;
|
||||
using TIAM.Database.DbSets.Permissions;
|
||||
using TIAM.Database.DbSets.Products;
|
||||
using TIAM.Database.DbSets.Users;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DataLayers.Admins
|
||||
{
|
||||
public static class AdminDalDbContextExtension
|
||||
{
|
||||
public static string ToJson<T>(this T source) where T : class, IEntity
|
||||
{
|
||||
JsonSerializerSettings options = new()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(source, options);
|
||||
}
|
||||
|
||||
public static string ToJson<T>(this IQueryable<T> source) where T : class, IEntity
|
||||
{
|
||||
JsonSerializerSettings options = new()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
|
||||
return JsonConvert.SerializeObject(source, options);
|
||||
}
|
||||
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IAdminDbContext ctx, Guid permissionGroupId)
|
||||
{
|
||||
return ctx.UserProductMappings
|
||||
.Where(user => ctx.PermissionGroupUserMappings
|
||||
.Where(x => x.PermissionGroupId == permissionGroupId)
|
||||
.Select(x => x.SubjectId)
|
||||
.Contains(user.Id));
|
||||
}
|
||||
|
||||
public static void CleanUpAndRemoveUserProductMappings(this IAdminDbContext ctx, IEnumerable<UserProductMapping> userProductMappings)
|
||||
{
|
||||
foreach (var userProductMapping in userProductMappings)
|
||||
{
|
||||
ctx.CleanUpAndRemoveAssignedUser(userProductMapping);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CleanUpAndRemoveAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping)
|
||||
{
|
||||
ctx.RemoveContextMappingBySubjectId(userProductMapping.Id);
|
||||
ctx.RemoveAssingedUserFromPermissionGroups(userProductMapping.Id);
|
||||
|
||||
ctx.UserProductMappings.Remove(userProductMapping);
|
||||
}
|
||||
|
||||
public static bool CleanUpAndRemoveUserProductMappings(this IAdminDbContext ctx, Guid userProductMappingId)
|
||||
{
|
||||
var userProductMapping = ctx.GetUserProductMappingById(userProductMappingId);
|
||||
|
||||
if (userProductMapping == null) return false;
|
||||
|
||||
ctx.CleanUpAndRemoveAssignedUser(userProductMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static UserProductMapping UpdateUserProductMapping(this IAdminDbContext context, UserProductMapping userProductMapping)
|
||||
{
|
||||
if (userProductMapping == null) return null;
|
||||
var existingUserProductMapping = context.UserProductMappings.FirstOrDefault(u => u.Id == userProductMapping.Id);
|
||||
if (existingUserProductMapping == null) return null;
|
||||
existingUserProductMapping.Id = userProductMapping.Id;
|
||||
existingUserProductMapping.UserId = userProductMapping.UserId;
|
||||
existingUserProductMapping.ProductId = userProductMapping.ProductId;
|
||||
|
||||
return existingUserProductMapping;
|
||||
|
||||
}
|
||||
|
||||
public static Product UpdateProduct(this IAdminDbContext ctx, Product product)
|
||||
{
|
||||
if (product == null) return null;
|
||||
|
||||
var existingProduct = ctx.Products.FirstOrDefault(u => u.Id == product.Id);
|
||||
if (existingProduct == null) return null;
|
||||
|
||||
existingProduct.Name = product.Name;
|
||||
existingProduct.ServiceProviderId = product.ServiceProviderId;
|
||||
existingProduct.Description = product.Description;
|
||||
existingProduct.Price = product.Price;
|
||||
existingProduct.JsonDetails = product.JsonDetails;
|
||||
//existingProduct.UserMediaId = product.UserMediaId;
|
||||
existingProduct.ProductType = product.ProductType;
|
||||
|
||||
|
||||
|
||||
return existingProduct;
|
||||
}
|
||||
|
||||
public static void DeleteProductById(this IAdminDbContext ctx, Guid productId)
|
||||
{
|
||||
var product = ctx.Products.FirstOrDefault(u => u.Id == productId);
|
||||
if (product == null) return;
|
||||
|
||||
ctx.CleanUpAndRemoveUserProductMappings(ctx.GetUserProductMappingsByProductId(productId));
|
||||
ctx.Products.Remove(product);
|
||||
}
|
||||
|
||||
public static bool CreatePermissionGroup(this IAdminDbContext ctx, PermissionGroup permissionGroup)
|
||||
{
|
||||
if (permissionGroup == null) return false;
|
||||
|
||||
ctx.PermissionGroups.Add(permissionGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CreatePermissionContextMapping(this IAdminDbContext ctx, PermissionContextMapping permissionContextMapping)
|
||||
{
|
||||
if (permissionContextMapping == null) return false;
|
||||
|
||||
ctx.PermissionContextMappings.Add(permissionContextMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CreatePermissionGroupUserMapping(this IAdminDbContext ctx, PermissionGroupUserMapping permissionGroupUserMapping)
|
||||
{
|
||||
if (permissionGroupUserMapping == null) return false;
|
||||
|
||||
ctx.PermissionGroupUserMappings.Add(permissionGroupUserMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CreatePermissionsType(this IAdminDbContext ctx, PermissionsType permissionType)
|
||||
{
|
||||
if (permissionType == null) return false;
|
||||
|
||||
ctx.PermissionsTypes.Add(permissionType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CreateProduct(this IAdminDbContext ctx, Product myproduct)
|
||||
{
|
||||
if (myproduct == null) return false;
|
||||
//Automatically add assigneduser for owner
|
||||
TiamServiceProvider? productOwner = ctx.ServiceProviders.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId);
|
||||
if (productOwner == null) return false;
|
||||
var userProductMapping = new UserProductMapping(myproduct.Id, productOwner.OwnerId);
|
||||
ctx.CreateAssignedUser(userProductMapping);
|
||||
ctx.AddProduct(myproduct);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CreateAssignedUser(this IAdminDbContext ctx, UserProductMapping userProductMapping)
|
||||
{
|
||||
if (userProductMapping == null) return false;
|
||||
|
||||
ctx.UserProductMappings.Add(userProductMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static TiamServiceProvider CreateServiceProvider(this IAdminDbContext ctx, TiamServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider == null) return null;
|
||||
|
||||
ctx.ServiceProviders.Add(serviceProvider);
|
||||
var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId);
|
||||
ctx.CreateAssignedUser(userProductMapping);
|
||||
return serviceProvider;
|
||||
}
|
||||
|
||||
public static TiamServiceProvider UpdateServiceProvider(this IAdminDbContext ctx, TiamServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider == null) return null;
|
||||
|
||||
var existingServiceProvider = ctx.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
|
||||
if (existingServiceProvider == null) return null;
|
||||
|
||||
existingServiceProvider.Name = serviceProvider.Name;
|
||||
existingServiceProvider.OwnerId = serviceProvider.OwnerId;
|
||||
return existingServiceProvider;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -23,538 +23,416 @@ using Newtonsoft.Json;
|
|||
|
||||
namespace TIAM.Database.DataLayers.ServiceProviders
|
||||
{
|
||||
public class ServiceProviderDal : DalBase<ServiceProviderDbContext>
|
||||
{
|
||||
|
||||
public ServiceProviderDal() : base()
|
||||
{
|
||||
}
|
||||
|
||||
public ServiceProviderDal(ServiceProviderDbContext _object)
|
||||
{
|
||||
}
|
||||
|
||||
//public TransferDestination? GetTransferDestinationById(Guid transferDestinationId, bool autoInclude = false) => Session(ctx=>ctx.TransferDestinations.FirstOrDefault(x=>x.Id == transferDestinationId));
|
||||
|
||||
//public User? GetUserById(Guid userId, bool autoInclude = false) => Session(x => x.GetUserById(userId, autoInclude));
|
||||
//public User? GetUserByEmail(string email, bool autoInclude = false) => Session(x => x.GetUserByEmail(email, autoInclude));
|
||||
|
||||
//public UserModelDto? GetUserModelDtoById(Guid userId) => Session(x => x.GetUserModelDtoById(userId));
|
||||
//public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId) => SessionAsync(x => x.GetUserModelDtoById(userId));
|
||||
//public UserModelDto? GetUserModelDtoByEmail(string email) => Session(x => x.GetUserModelDtoByEmail(email));
|
||||
|
||||
//public string? GetUserJsonById(Guid userId) => Session(ctx => ctx.GetUserById(userId)?.ToJson());
|
||||
//public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
|
||||
|
||||
|
||||
//public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(x => x.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||
|
||||
#region ServiceProviders
|
||||
|
||||
//16. (IServiceProviderDataService) get all service providers
|
||||
public Task<List<TiamServiceProvider>> GetServiceProvidersAsync()
|
||||
{
|
||||
return Context.ServiceProviders.ToListAsync();
|
||||
}
|
||||
|
||||
//18. (IServiceProviderDataService) get serviceProvider by Id
|
||||
public virtual Task<TiamServiceProvider?> GetServiceProviderByIdAsync(Guid id)
|
||||
{
|
||||
Console.WriteLine($"Getting serviceProvider from db {id}");
|
||||
return Context.ServiceProviders.SingleOrDefaultAsync(x => x.Id == id);
|
||||
}
|
||||
|
||||
//15. (IServiceProviderDataService) Create service provider
|
||||
public Task<bool> CreateServiceProviderAsync(TiamServiceProvider serviceProvider)
|
||||
{
|
||||
|
||||
Context.CreateServiceProvider(serviceProvider);
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
|
||||
}
|
||||
|
||||
//14. (IserviceProviderDataService) Update service provider
|
||||
public Task<bool> UpdateServiceProviderAsync(TiamServiceProvider serviceProvider)
|
||||
{
|
||||
var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
|
||||
if (dbServiceProvider != null)
|
||||
{
|
||||
dbServiceProvider = serviceProvider;
|
||||
Context.ServiceProviders.Update(dbServiceProvider);
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("ServiceProvider not found");
|
||||
}
|
||||
}
|
||||
|
||||
//13. (IserviceProviderDataService) delete service provider
|
||||
public Task<bool> DeleteServiceProviderAsync(Guid id)
|
||||
{
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == id);
|
||||
if (dbServiceProvider != null)
|
||||
{
|
||||
//get products for this provider
|
||||
var products = Context.Products.Where(x => x.ServiceProviderId == id).ToList();
|
||||
|
||||
/*foreach (var productItem in products)
|
||||
{
|
||||
//delete products
|
||||
var permissionContextMappings = Context.PermissionContextMappings.Where(x => x.ContextId == productItem.Id).ToList();
|
||||
//iterate through every row
|
||||
foreach (var item in permissionContextMappings)
|
||||
{
|
||||
|
||||
if (item.SubjectType == (int)PermissionContextMappingSubjectType.Group)
|
||||
{
|
||||
//get users in the permissiongroup
|
||||
var permissionGroupUserMapping = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == item.Id).ToList();
|
||||
//remove every row (users) from permissiongroup
|
||||
foreach (var user in permissionGroupUserMapping)
|
||||
{
|
||||
Context.PermissionGroupUserMappings.Remove(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
//remove permissioncontextmappings
|
||||
Context.PermissionContextMappings.RemoveRange(permissionContextMappings);
|
||||
}*/
|
||||
Context.Products.RemoveRange(products);
|
||||
Context.ServiceProviders.Remove(dbServiceProvider);
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//17. (IServiceProviderDataService) get service provider by ownerId
|
||||
public Task<List<TiamServiceProvider>> GetServiceProvidersByOwnerIdAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PermissionTypes
|
||||
|
||||
|
||||
//10. (IPermissionService) create permission type
|
||||
public Task<bool> CreatePermissionsTypeAsync(PermissionsType permissionsType)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var existingPermission = Context.PermissionsTypes
|
||||
.FirstOrDefault(x => x.PermissionName == permissionsType.PermissionName)?.PermissionName;
|
||||
|
||||
if (existingPermission == null)
|
||||
{
|
||||
//get all the permissiontypes for this context
|
||||
var permissionTypes = new List<PermissionsType>();
|
||||
var nextBitValue = 0.0;
|
||||
permissionTypes = Context.PermissionsTypes
|
||||
.Where(x => x.ContextId == permissionsType.ContextId)
|
||||
.ToList();
|
||||
|
||||
//get the max value of the permissiontypes
|
||||
if (permissionTypes != null)
|
||||
{
|
||||
//next bit value is the power of two of the count of the permissiontypes
|
||||
nextBitValue = Math.Pow(2, permissionTypes.Count);
|
||||
}
|
||||
else
|
||||
{
|
||||
nextBitValue = Math.Pow(2, 0);
|
||||
}
|
||||
permissionsType.PermissionBit = (int)nextBitValue;
|
||||
Context.PermissionsTypes.Add(permissionsType);
|
||||
Context.SaveChanges();
|
||||
transaction.Commit();
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = false;
|
||||
}
|
||||
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
|
||||
}
|
||||
|
||||
//11. (IPermissionService) get permission types for context
|
||||
public Task<List<PermissionsType>>? GetPermissionTypesByContextIdAsync(Guid contextId)
|
||||
{
|
||||
return Context.PermissionsTypes.Where(x => x.ContextId == contextId).ToListAsync();
|
||||
}
|
||||
|
||||
public Task<int> GetPermissionFromPermissionType(PermissionsType pType)
|
||||
{
|
||||
if (Context.PermissionsTypes.FirstOrDefault(x => x.Id == pType.Id) != null)
|
||||
{
|
||||
return Task.FromResult(pType.PermissionBit);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Task.FromResult(0);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region PermissionMappings
|
||||
|
||||
//public List<PermissionContextMapping> GetPermissionContextsView(Guid subjectId, Guid contextId)
|
||||
// => Session(x => x.GetPermissionContextsView(subjectId, contextId).ToList());
|
||||
|
||||
//public List<PermissionContextMapping> GetPermissionContextsViewBySubjectId(Guid contextId)
|
||||
// => Session(x => x.GetPermissionContextsViewBySubjectId(contextId).ToList());
|
||||
|
||||
//public List<PermissionContextMapping> GetPermissionContextsViewByContextId(Guid contextId)
|
||||
// => Session(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
|
||||
|
||||
//public Task<List<PermissionContextMapping>> GetPermissionContextsViewByContextIdAsync(Guid contextId)
|
||||
// => SessionAsync(x => x.GetPermissionContextsViewByContextId(contextId).ToList());
|
||||
|
||||
//3. (IPermissionService) get permissions of assigned users and groups
|
||||
public Task<List<AssignedPermissionModel>> GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId(Guid contextId)
|
||||
{
|
||||
List<AssignedPermissionModel> result = new List<AssignedPermissionModel>();
|
||||
|
||||
var UserProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToListAsync();
|
||||
|
||||
if (UserProductMappings.Result != null)
|
||||
{
|
||||
foreach (var item in UserProductMappings.Result)
|
||||
{
|
||||
var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToListAsync();
|
||||
if (mappingRow.Result == null)
|
||||
{
|
||||
//user has no permission but is assigned... must be banned
|
||||
|
||||
}
|
||||
else if (mappingRow.Result.Count > 1)
|
||||
{
|
||||
//user has been assigned more than onece to same context
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var mapping in mappingRow.Result)
|
||||
{
|
||||
result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
var AssingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToListAsync();
|
||||
|
||||
if (AssingedGroups.Result != null)
|
||||
{
|
||||
foreach (var group in AssingedGroups.Result)
|
||||
{
|
||||
var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToListAsync();
|
||||
if (mappingRow.Result == null)
|
||||
{
|
||||
//group has no permission but is assigned...
|
||||
|
||||
}
|
||||
else if (mappingRow.Result.Count > 1)
|
||||
{
|
||||
//group has been assigned more than onece to same context
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var mapping in mappingRow.Result)
|
||||
{
|
||||
result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
foreach (var row in result)
|
||||
{
|
||||
Console.WriteLine($"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}");
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//12. (IPermissionService) get permission groups for context
|
||||
public Task<List<PermissionContextMapping>> GetPermissionsForContextByContextIdAsync(Guid contextId)
|
||||
{
|
||||
List<PermissionContextMapping> permissionContextMappings = new List<PermissionContextMapping>();
|
||||
//get all Groups where the contextId is the same
|
||||
var groups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).Select(x => x.Id).ToHashSet();
|
||||
permissionContextMappings = Context.PermissionContextMappings.Where(x => groups.Contains(x.SubjectId)).ToList();
|
||||
|
||||
//foreach (var item in groups.Result)
|
||||
//{
|
||||
// //get permissioncontextmapping for the group if there is, so we know what permissions the group has
|
||||
// var pCm = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == item.Id);
|
||||
// permissionContextMappings.Add(pCm);
|
||||
//}
|
||||
return Task.FromResult(permissionContextMappings);
|
||||
}
|
||||
|
||||
//9. (IPermissionService) add user to permission group
|
||||
public Task<bool> AddUserToPermissionGroupAsync(Guid permissionGroupId, Guid userId)
|
||||
{
|
||||
bool result = false;
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
//do we need to check if PermissionContextMappingId exists?
|
||||
var permissionGroupUserMapping = new PermissionGroupUserMapping(userId, permissionGroupId);
|
||||
Context.PermissionGroupUserMappings.Add(permissionGroupUserMapping);
|
||||
Context.SaveChanges();
|
||||
transaction.Commit();
|
||||
result = true;
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
//8. (IPermissionService) create permission group
|
||||
public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, TiamServiceProvider serviceProvider)
|
||||
{
|
||||
bool result = false;
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var existingPermissionGroup = Context.PermissionGroups.FirstOrDefault(x => x.GroupName == permissionGroup.GroupName)?.GroupName;
|
||||
if (existingPermissionGroup == null)
|
||||
{
|
||||
//create permission type 1 for the group
|
||||
var permissionType = new PermissionsType(serviceProvider.Id, "View");
|
||||
Context.CreatePermissionsType(permissionType);
|
||||
|
||||
//Create PermissionContextMapping for the group
|
||||
|
||||
//create Id for the group
|
||||
Guid Id = Guid.NewGuid();
|
||||
permissionGroup.Id = Id;
|
||||
var permissionContextMapping = new PermissionContextMapping(serviceProvider.Id, Id, PermissionContextMappingSubjectType.Group, 1, true);
|
||||
Context.CreatePermissionContextMapping(permissionContextMapping);
|
||||
Context.CreatePermissionGroup(permissionGroup);
|
||||
Context.SaveChanges();
|
||||
transaction.Commit();
|
||||
result = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//group with same name already exists
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
return Task.FromResult(result);
|
||||
}
|
||||
|
||||
public List<UserProductMapping> GetUserProductMappingsInPermissionGroupByGroupId(Guid groupId)
|
||||
{
|
||||
return Context.GetUserProductMappingsByPermissionGroupId(groupId).ToList();
|
||||
//List<UserProductMapping> userProductMappings = new List<UserProductMapping>();
|
||||
|
||||
////let's get the permissioncontextmapping for the group
|
||||
//var pCm = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == groupId);
|
||||
//Guid pCmId = pCm.Id;
|
||||
|
||||
////let's get the permissiongroupusermappings for the permissioncontextmapping
|
||||
//var pGum = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == pCmId).ToList();
|
||||
//if (pGum.Count > 0)
|
||||
//{
|
||||
// foreach (var group in pGum)
|
||||
// {
|
||||
// userProductMappings.Add(Context.UserProductMappings.FirstOrDefault(x => x.Id == group.UserProductMappingId));
|
||||
// }
|
||||
|
||||
//}
|
||||
|
||||
//return Task.FromResult(userProductMappings);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Products
|
||||
|
||||
//public Product? GetProductById(Guid contextId) => Session(x => x.GetProductById(contextId));
|
||||
|
||||
//* 19. (IServiceProviderDataService) Create product
|
||||
public bool CreateProductAsync(Product product)
|
||||
{
|
||||
Context.CreateProduct(product);
|
||||
Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
|
||||
var _result = Context.SaveChangesAsync();
|
||||
return _result.Result > 0;
|
||||
}
|
||||
|
||||
//* 20. (IServiceProviderDataService) Update product
|
||||
public Product UpdateProduct(Product product)
|
||||
{
|
||||
|
||||
var prod = Context.UpdateProduct(product);
|
||||
Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
|
||||
Context.SaveChanges();
|
||||
return prod;
|
||||
}
|
||||
|
||||
//* 21. (IServiceProviderDataService) delete product
|
||||
public Task<bool> DeleteProductByIdAsync(Guid productId)
|
||||
{
|
||||
return TransactionAsync(ctx =>
|
||||
{
|
||||
ctx.DeleteProductById(productId);
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
//4. (IPermissionService) AssignPermissionToUserForContextAsync
|
||||
public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission)
|
||||
{
|
||||
var _assIgnedUser = Context.UserProductMappings.FirstOrDefault(x => x.Id == userProductMapping.Id);
|
||||
|
||||
if (_assIgnedUser != null)
|
||||
{
|
||||
//user exists
|
||||
var _permissionInt = GetPermissionFromPermissionType(permission);
|
||||
|
||||
var permissionContextMapping = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == userProductMapping.Id);
|
||||
var currentPermissions = permissionContextMapping.Permissions;
|
||||
var newPermissions = currentPermissions + _permissionInt.Result;
|
||||
permissionContextMapping.Permissions = newPermissions;
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
//user does not exist, let's create it
|
||||
return Task.FromResult(false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region UserProductMappings
|
||||
|
||||
//22. (IServiceProviderDataService) Create userProductMapping
|
||||
public Task<UserProductMapping> CreateUserProductMappingAsync(UserProductMapping userProductMapping)
|
||||
{
|
||||
Context.UserProductMappings.Add(userProductMapping);
|
||||
Console.WriteLine($"Saving userProductMapping to db {userProductMapping.Id}, {userProductMapping.ProductId}, {userProductMapping.UserId}");
|
||||
return Context.SaveChangesAsync().ContinueWith(x => userProductMapping);
|
||||
}
|
||||
|
||||
//23. (IServiceProviderDataService) Get Assigned Users By ProductId
|
||||
public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId)
|
||||
{
|
||||
return Context.UserProductMappings.Where(x => x.ProductId == productId).ToListAsync();
|
||||
}
|
||||
|
||||
|
||||
//24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
|
||||
public Task RemoveUserProductMappingsByContextId(Guid productId)
|
||||
{
|
||||
using (var transaction = Context.Database.BeginTransaction())
|
||||
{
|
||||
var userProductMappings = Context.UserProductMappings.Where(x => x.ProductId == productId).ToList();
|
||||
//remove userProductMappings
|
||||
|
||||
return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//25. (IServiceProviderDataService) Remove Assigned from product by userProductMappingId
|
||||
public Task<bool> RemoveUserProductMappingAsync(UserProductMapping userProductMapping, bool removeFromGroups)
|
||||
{
|
||||
return TransactionAsync(ctx =>
|
||||
{
|
||||
var result = false;
|
||||
var userProductMappingToRemove = ctx.UserProductMappings.FirstOrDefault(x => x.Id == userProductMapping.Id);
|
||||
|
||||
//remove userProductMappings
|
||||
if (userProductMappingToRemove == null) return false;
|
||||
|
||||
|
||||
if (removeFromGroups)
|
||||
{
|
||||
//remove permissiongroupusermappings
|
||||
ctx.RemoveAssingedUserFromPermissionGroups(userProductMappingToRemove.Id);
|
||||
}
|
||||
|
||||
ctx.UserProductMappings.Remove(userProductMappingToRemove);
|
||||
|
||||
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
//public Task RemoveUserProductMappingByUserIdAsync(Guid userProductMappingId)
|
||||
//{
|
||||
// return TransactionAsync(ctx =>
|
||||
// {
|
||||
// var userProductMapping = ctx.UserProductMappings.FirstOrDefault(x => x.Id == userProductMappingId);
|
||||
// //remove userProductMappings
|
||||
// if (userProductMapping == null) return false;
|
||||
|
||||
// //CleanUp
|
||||
// //remove permissioncontextmappings
|
||||
// ctx.RemoveUserProductMappingContextMappingBySubjectId(userProductMappingId);
|
||||
// //remove permissiongroupusermappings
|
||||
// ctx.RemoveAssingedUserFromAllProductPermissionGroups(userProductMappingId);
|
||||
|
||||
// return true;
|
||||
// });
|
||||
//}
|
||||
|
||||
//public Task RemoveUserProductMappingContextMappingByUserProductMappingId(Guid userProductMappingId)
|
||||
//{
|
||||
// using (var transaction = Context.Database.BeginTransaction())
|
||||
// {
|
||||
// PermissionContextMapping? contextMapping = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == userProductMappingId);
|
||||
// //remove userProductMappings
|
||||
// if(contextMapping != null)
|
||||
// {
|
||||
// Context.PermissionContextMappings.Remove(contextMapping);
|
||||
// }
|
||||
// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//public Task RemoveAssingedUserFromAllProductPermissionGroups(Guid userProductMappingId)
|
||||
//{
|
||||
// using (var transaction = Context.Database.BeginTransaction())
|
||||
// {
|
||||
// var permissionGroupUserMapping = Context.PermissionGroupUserMappings.Where(x => x.UserProductMappingId == userProductMappingId);
|
||||
// //remove userProductMappings
|
||||
|
||||
// if (permissionGroupUserMapping != null)
|
||||
// {
|
||||
// foreach (var item in permissionGroupUserMapping)
|
||||
// {
|
||||
// Context.PermissionGroupUserMappings.Remove(item);
|
||||
// }
|
||||
// }
|
||||
// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
//public class ServiceProviderDal : DalBase<ServiceProviderDbContext>
|
||||
//{
|
||||
|
||||
// public ServiceProviderDal() : base()
|
||||
// {
|
||||
// }
|
||||
|
||||
// public ServiceProviderDal(ServiceProviderDbContext _object)
|
||||
// {
|
||||
// }
|
||||
|
||||
//// #region ServiceProviders
|
||||
|
||||
//// //14. (IserviceProviderDataService) Update service provider
|
||||
//// public Task<bool> UpdateServiceProviderAsync(TiamServiceProvider serviceProvider)
|
||||
//// {
|
||||
//// var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
|
||||
//// if (dbServiceProvider != null)
|
||||
//// {
|
||||
//// dbServiceProvider = serviceProvider;
|
||||
//// Context.ServiceProviders.Update(dbServiceProvider);
|
||||
//// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// throw new Exception("ServiceProvider not found");
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// //13. (IserviceProviderDataService) delete service provider
|
||||
//// public Task<bool> DeleteServiceProviderAsync(Guid id)
|
||||
//// {
|
||||
//// using (var transaction = Context.Database.BeginTransaction())
|
||||
//// {
|
||||
//// var dbServiceProvider = Context.ServiceProviders.FirstOrDefault(u => u.Id == id);
|
||||
//// if (dbServiceProvider != null)
|
||||
//// {
|
||||
//// //get products for this provider
|
||||
//// var products = Context.Products.Where(x => x.ServiceProviderId == id).ToList();
|
||||
|
||||
//// /*foreach (var productItem in products)
|
||||
//// {
|
||||
//// //delete products
|
||||
//// var permissionContextMappings = Context.PermissionContextMappings.Where(x => x.ContextId == productItem.Id).ToList();
|
||||
//// //iterate through every row
|
||||
//// foreach (var item in permissionContextMappings)
|
||||
//// {
|
||||
|
||||
//// if (item.SubjectType == (int)PermissionContextMappingSubjectType.Group)
|
||||
//// {
|
||||
//// //get users in the permissiongroup
|
||||
//// var permissionGroupUserMapping = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == item.Id).ToList();
|
||||
//// //remove every row (users) from permissiongroup
|
||||
//// foreach (var user in permissionGroupUserMapping)
|
||||
//// {
|
||||
//// Context.PermissionGroupUserMappings.Remove(user);
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
//// //remove permissioncontextmappings
|
||||
//// Context.PermissionContextMappings.RemoveRange(permissionContextMappings);
|
||||
//// }*/
|
||||
//// Context.Products.RemoveRange(products);
|
||||
//// Context.ServiceProviders.Remove(dbServiceProvider);
|
||||
//// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// return Task.FromResult(false);
|
||||
//// }
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// //17. (IServiceProviderDataService) get service provider by ownerId
|
||||
//// public Task<List<TiamServiceProvider>> GetServiceProvidersByOwnerIdAsync()
|
||||
//// {
|
||||
//// throw new NotImplementedException();
|
||||
|
||||
//// }
|
||||
|
||||
//// #endregion
|
||||
|
||||
//// #region PermissionTypes
|
||||
|
||||
|
||||
//// //10. (IPermissionService) create permission type
|
||||
//// public Task<bool> CreatePermissionsTypeAsync(PermissionsType permissionsType)
|
||||
//// {
|
||||
//// bool result = false;
|
||||
|
||||
//// using (var transaction = Context.Database.BeginTransaction())
|
||||
//// {
|
||||
//// var existingPermission = Context.PermissionsTypes
|
||||
//// .FirstOrDefault(x => x.PermissionName == permissionsType.PermissionName)?.PermissionName;
|
||||
|
||||
//// if (existingPermission == null)
|
||||
//// {
|
||||
//// //get all the permissiontypes for this context
|
||||
//// var permissionTypes = new List<PermissionsType>();
|
||||
//// var nextBitValue = 0.0;
|
||||
//// permissionTypes = Context.PermissionsTypes
|
||||
//// .Where(x => x.ContextId == permissionsType.ContextId)
|
||||
//// .ToList();
|
||||
|
||||
//// //get the max value of the permissiontypes
|
||||
//// if (permissionTypes != null)
|
||||
//// {
|
||||
//// //next bit value is the power of two of the count of the permissiontypes
|
||||
//// nextBitValue = Math.Pow(2, permissionTypes.Count);
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// nextBitValue = Math.Pow(2, 0);
|
||||
//// }
|
||||
//// permissionsType.PermissionBit = (int)nextBitValue;
|
||||
//// Context.PermissionsTypes.Add(permissionsType);
|
||||
//// Context.SaveChanges();
|
||||
//// transaction.Commit();
|
||||
//// result = true;
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// result = false;
|
||||
//// }
|
||||
|
||||
//// }
|
||||
//// return Task.FromResult(result);
|
||||
|
||||
//// }
|
||||
|
||||
//// //11. (IPermissionService) get permission types for context
|
||||
//// public Task<List<PermissionsType>>? GetPermissionTypesByContextIdAsync(Guid contextId)
|
||||
//// {
|
||||
//// return Context.PermissionsTypes.Where(x => x.ContextId == contextId).ToListAsync();
|
||||
//// }
|
||||
|
||||
//// public Task<int> GetPermissionFromPermissionType(PermissionsType pType)
|
||||
//// {
|
||||
//// if (Context.PermissionsTypes.FirstOrDefault(x => x.Id == pType.Id) != null)
|
||||
//// {
|
||||
//// return Task.FromResult(pType.PermissionBit);
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// return Task.FromResult(0);
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// #endregion
|
||||
|
||||
//// #region PermissionMappings
|
||||
|
||||
//// public Task<List<AssignedPermissionModel>> GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId(Guid contextId)
|
||||
//// {
|
||||
//// List<AssignedPermissionModel> result = new List<AssignedPermissionModel>();
|
||||
|
||||
//// var UserProductMappings = Context.UserProductMappings.Where(x => x.ProductId == contextId).ToListAsync();
|
||||
|
||||
//// if (UserProductMappings.Result != null)
|
||||
//// {
|
||||
//// foreach (var item in UserProductMappings.Result)
|
||||
//// {
|
||||
//// var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == item.Id).ToListAsync();
|
||||
//// if (mappingRow.Result == null)
|
||||
//// {
|
||||
//// //user has no permission but is assigned... must be banned
|
||||
|
||||
//// }
|
||||
//// else if (mappingRow.Result.Count > 1)
|
||||
//// {
|
||||
//// //user has been assigned more than onece to same context
|
||||
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// foreach (var mapping in mappingRow.Result)
|
||||
//// {
|
||||
//// result.Add(new AssignedPermissionModel(item.ProductId, item.Id, mapping.SubjectType, item.UserId.ToString(), mapping.Permissions));
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// var AssingedGroups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).ToListAsync();
|
||||
|
||||
//// if (AssingedGroups.Result != null)
|
||||
//// {
|
||||
//// foreach (var group in AssingedGroups.Result)
|
||||
//// {
|
||||
//// var mappingRow = Context.PermissionContextMappings.Where(x => x.SubjectId == group.Id).ToListAsync();
|
||||
//// if (mappingRow.Result == null)
|
||||
//// {
|
||||
//// //group has no permission but is assigned...
|
||||
|
||||
//// }
|
||||
//// else if (mappingRow.Result.Count > 1)
|
||||
//// {
|
||||
//// //group has been assigned more than onece to same context
|
||||
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// foreach (var mapping in mappingRow.Result)
|
||||
//// {
|
||||
//// result.Add(new AssignedPermissionModel(group.OwnerId, group.Id, mapping.SubjectType, group.GroupName, mapping.Permissions));
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// }
|
||||
//// }
|
||||
//// foreach (var row in result)
|
||||
//// {
|
||||
//// Console.WriteLine($"GetPermissionsOfUserProductMappingsAndGroupsAsyncByContextId: {row.ContextId}, {row.SubjectId}, {row.SubjectType}, {row.Name}, {row.PermissionsValue}");
|
||||
//// }
|
||||
//// return Task.FromResult(result);
|
||||
//// }
|
||||
|
||||
|
||||
|
||||
//// //12. (IPermissionService) get permission groups for context
|
||||
//// public Task<List<PermissionContextMapping>> GetPermissionsForContextByContextIdAsync(Guid contextId)
|
||||
//// {
|
||||
//// List<PermissionContextMapping> permissionContextMappings = new List<PermissionContextMapping>();
|
||||
//// //get all Groups where the contextId is the same
|
||||
//// var groups = Context.PermissionGroups.Where(x => x.OwnerId == contextId).Select(x => x.Id).ToHashSet();
|
||||
//// permissionContextMappings = Context.PermissionContextMappings.Where(x => groups.Contains(x.SubjectId)).ToList();
|
||||
|
||||
//// //foreach (var item in groups.Result)
|
||||
//// //{
|
||||
//// // //get permissioncontextmapping for the group if there is, so we know what permissions the group has
|
||||
//// // var pCm = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == item.Id);
|
||||
//// // permissionContextMappings.Add(pCm);
|
||||
//// //}
|
||||
//// return Task.FromResult(permissionContextMappings);
|
||||
//// }
|
||||
|
||||
//// //9. (IPermissionService) add user to permission group
|
||||
//// public Task<bool> AddUserToPermissionGroupAsync(Guid permissionGroupId, Guid userId)
|
||||
//// {
|
||||
//// bool result = false;
|
||||
//// using (var transaction = Context.Database.BeginTransaction())
|
||||
//// {
|
||||
//// //do we need to check if PermissionContextMappingId exists?
|
||||
//// var permissionGroupUserMapping = new PermissionGroupUserMapping(userId, permissionGroupId);
|
||||
//// Context.PermissionGroupUserMappings.Add(permissionGroupUserMapping);
|
||||
//// Context.SaveChanges();
|
||||
//// transaction.Commit();
|
||||
//// result = true;
|
||||
//// }
|
||||
//// return Task.FromResult(result);
|
||||
//// }
|
||||
|
||||
//// //8. (IPermissionService) create permission group
|
||||
//// public Task<bool> CreatePermissionGroupAsync(PermissionGroup permissionGroup, TiamServiceProvider serviceProvider)
|
||||
//// {
|
||||
//// bool result = false;
|
||||
//// using (var transaction = Context.Database.BeginTransaction())
|
||||
//// {
|
||||
//// var existingPermissionGroup = Context.PermissionGroups.FirstOrDefault(x => x.GroupName == permissionGroup.GroupName)?.GroupName;
|
||||
//// if (existingPermissionGroup == null)
|
||||
//// {
|
||||
//// //create permission type 1 for the group
|
||||
//// var permissionType = new PermissionsType(serviceProvider.Id, "View");
|
||||
//// Context.CreatePermissionsType(permissionType);
|
||||
|
||||
//// //Create PermissionContextMapping for the group
|
||||
|
||||
//// //create Id for the group
|
||||
//// Guid Id = Guid.NewGuid();
|
||||
//// permissionGroup.Id = Id;
|
||||
//// var permissionContextMapping = new PermissionContextMapping(serviceProvider.Id, Id, PermissionContextMappingSubjectType.Group, 1, true);
|
||||
//// Context.CreatePermissionContextMapping(permissionContextMapping);
|
||||
//// Context.CreatePermissionGroup(permissionGroup);
|
||||
//// Context.SaveChanges();
|
||||
//// transaction.Commit();
|
||||
//// result = true;
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// //group with same name already exists
|
||||
//// result = false;
|
||||
//// }
|
||||
//// }
|
||||
//// return Task.FromResult(result);
|
||||
//// }
|
||||
|
||||
//// public List<UserProductMapping> GetUserProductMappingsInPermissionGroupByGroupId(Guid groupId)
|
||||
//// {
|
||||
//// return Context.GetUserProductMappingsByPermissionGroupId(groupId).ToList();
|
||||
//// //List<UserProductMapping> userProductMappings = new List<UserProductMapping>();
|
||||
|
||||
//// ////let's get the permissioncontextmapping for the group
|
||||
//// //var pCm = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == groupId);
|
||||
//// //Guid pCmId = pCm.Id;
|
||||
|
||||
//// ////let's get the permissiongroupusermappings for the permissioncontextmapping
|
||||
//// //var pGum = Context.PermissionGroupUserMappings.Where(x => x.PermissionContextMappingId == pCmId).ToList();
|
||||
//// //if (pGum.Count > 0)
|
||||
//// //{
|
||||
//// // foreach (var group in pGum)
|
||||
//// // {
|
||||
//// // userProductMappings.Add(Context.UserProductMappings.FirstOrDefault(x => x.Id == group.UserProductMappingId));
|
||||
//// // }
|
||||
|
||||
//// //}
|
||||
|
||||
//// //return Task.FromResult(userProductMappings);
|
||||
//// }
|
||||
|
||||
//// #endregion
|
||||
|
||||
//// #region Products
|
||||
|
||||
//// //* 20. (IServiceProviderDataService) Update product
|
||||
//// public Product UpdateProduct(Product product)
|
||||
//// {
|
||||
|
||||
//// var prod = Context.UpdateProduct(product);
|
||||
//// Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
|
||||
//// Context.SaveChanges();
|
||||
//// return prod;
|
||||
//// }
|
||||
|
||||
//// //* 21. (IServiceProviderDataService) delete product
|
||||
//// public Task<bool> DeleteProductByIdAsync(Guid productId)
|
||||
//// {
|
||||
//// return TransactionAsync(ctx =>
|
||||
//// {
|
||||
//// ctx.DeleteProductById(productId);
|
||||
|
||||
//// return true;
|
||||
//// });
|
||||
//// }
|
||||
|
||||
//// //4. (IPermissionService) AssignPermissionToUserForContextAsync
|
||||
//// public Task<bool> AssignPermissionToUserForContextAsync(UserProductMapping userProductMapping, PermissionsType permission)
|
||||
//// {
|
||||
//// var _assIgnedUser = Context.UserProductMappings.FirstOrDefault(x => x.Id == userProductMapping.Id);
|
||||
|
||||
//// if (_assIgnedUser != null)
|
||||
//// {
|
||||
//// //user exists
|
||||
//// var _permissionInt = GetPermissionFromPermissionType(permission);
|
||||
|
||||
//// var permissionContextMapping = Context.PermissionContextMappings.FirstOrDefault(x => x.SubjectId == userProductMapping.Id);
|
||||
//// var currentPermissions = permissionContextMapping.Permissions;
|
||||
//// var newPermissions = currentPermissions + _permissionInt.Result;
|
||||
//// permissionContextMapping.Permissions = newPermissions;
|
||||
//// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
//// }
|
||||
//// else
|
||||
//// {
|
||||
//// //user does not exist, let's create it
|
||||
//// return Task.FromResult(false);
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// #endregion
|
||||
|
||||
|
||||
//// #region UserProductMappings
|
||||
|
||||
//// //23. (IServiceProviderDataService) Get Assigned Users By ProductId
|
||||
//// public Task<List<UserProductMapping>> GetUserProductMappingsByProductIdAsync(Guid productId)
|
||||
//// {
|
||||
//// return Context.UserProductMappings.Where(x => x.ProductId == productId).ToListAsync();
|
||||
//// }
|
||||
|
||||
|
||||
//// //24 . (IServiceProviderDataService) Remove Assigned Users By Product Id
|
||||
//// public Task RemoveUserProductMappingsByContextId(Guid productId)
|
||||
//// {
|
||||
//// using (var transaction = Context.Database.BeginTransaction())
|
||||
//// {
|
||||
//// var userProductMappings = Context.UserProductMappings.Where(x => x.ProductId == productId).ToList();
|
||||
//// //remove userProductMappings
|
||||
|
||||
//// return Context.SaveChangesAsync().ContinueWith(x => x.Result > 0);
|
||||
|
||||
//// }
|
||||
//// }
|
||||
|
||||
//// //25. (IServiceProviderDataService) Remove Assigned from product by userProductMappingId
|
||||
//// public Task<bool> RemoveUserProductMappingAsync(UserProductMapping userProductMapping, bool removeFromGroups)
|
||||
//// {
|
||||
//// return TransactionAsync(ctx =>
|
||||
//// {
|
||||
//// var result = false;
|
||||
//// var userProductMappingToRemove = ctx.UserProductMappings.FirstOrDefault(x => x.Id == userProductMapping.Id);
|
||||
|
||||
//// //remove userProductMappings
|
||||
//// if (userProductMappingToRemove == null) return false;
|
||||
|
||||
|
||||
//// if (removeFromGroups)
|
||||
//// {
|
||||
//// //remove permissiongroupusermappings
|
||||
//// ctx.RemoveAssingedUserFromPermissionGroups(userProductMappingToRemove.Id);
|
||||
//// }
|
||||
|
||||
//// ctx.UserProductMappings.Remove(userProductMappingToRemove);
|
||||
|
||||
|
||||
//// return result;
|
||||
//// });
|
||||
//// }
|
||||
|
||||
|
||||
//// #endregion
|
||||
|
||||
////}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,189 +15,143 @@ using TIAM.Entities.Products;
|
|||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Database.DataLayers.ServiceProviders;
|
||||
//namespace TIAM.Database.DataLayers.ServiceProviders;
|
||||
|
||||
public static class ServiceProviderDalExtension
|
||||
{
|
||||
public static string ToJson<T>(this T source) where T : class, IEntity
|
||||
{
|
||||
JsonSerializerSettings options = new()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
//public static class ServiceProviderDalExtension
|
||||
//{
|
||||
// //public static string ToJson<T>(this T source) where T : class, IEntity
|
||||
// //{
|
||||
// // JsonSerializerSettings options = new()
|
||||
// // {
|
||||
// // ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
// // NullValueHandling = NullValueHandling.Ignore
|
||||
// // };
|
||||
|
||||
return JsonConvert.SerializeObject(source, options);
|
||||
}
|
||||
// // return JsonConvert.SerializeObject(source, options);
|
||||
// //}
|
||||
|
||||
public static string ToJson<T>(this IQueryable<T> source) where T : class, IEntity
|
||||
{
|
||||
JsonSerializerSettings options = new()
|
||||
{
|
||||
ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
NullValueHandling = NullValueHandling.Ignore
|
||||
};
|
||||
// //public static string ToJson<T>(this IQueryable<T> source) where T : class, IEntity
|
||||
// //{
|
||||
// // JsonSerializerSettings options = new()
|
||||
// // {
|
||||
// // ReferenceLoopHandling = ReferenceLoopHandling.Ignore,
|
||||
// // NullValueHandling = NullValueHandling.Ignore
|
||||
// // };
|
||||
|
||||
return JsonConvert.SerializeObject(source, options);
|
||||
}
|
||||
// // return JsonConvert.SerializeObject(source, options);
|
||||
// //}
|
||||
|
||||
public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IServiceProviderDbContext ctx, Guid permissionGroupId)
|
||||
{
|
||||
return ctx.UserProductMappings
|
||||
.Where(user => ctx.PermissionGroupUserMappings
|
||||
.Where(x => x.PermissionGroupId == permissionGroupId)
|
||||
.Select(x => x.SubjectId)
|
||||
.Contains(user.Id));
|
||||
}
|
||||
// //public static IQueryable<UserProductMapping> GetUserProductMappingsByPermissionGroupId(this IServiceProviderDbContext ctx, Guid permissionGroupId)
|
||||
// //{
|
||||
// // return ctx.UserProductMappings
|
||||
// // .Where(user => ctx.PermissionGroupUserMappings
|
||||
// // .Where(x => x.PermissionGroupId == permissionGroupId)
|
||||
// // .Select(x => x.SubjectId)
|
||||
// // .Contains(user.Id));
|
||||
// //}
|
||||
|
||||
public static void CleanUpAndRemoveUserProductMappings(this IServiceProviderDbContext ctx, IEnumerable<UserProductMapping> userProductMappings)
|
||||
{
|
||||
foreach (var userProductMapping in userProductMappings)
|
||||
{
|
||||
ctx.CleanUpAndRemoveAssignedUser(userProductMapping);
|
||||
}
|
||||
}
|
||||
// //public static void CleanUpAndRemoveUserProductMappings(this IServiceProviderDbContext ctx, IEnumerable<UserProductMapping> userProductMappings)
|
||||
// //{
|
||||
// // foreach (var userProductMapping in userProductMappings)
|
||||
// // {
|
||||
// // ctx.CleanUpAndRemoveAssignedUser(userProductMapping);
|
||||
// // }
|
||||
// //}
|
||||
|
||||
public static void CleanUpAndRemoveAssignedUser(this IServiceProviderDbContext ctx, UserProductMapping userProductMapping)
|
||||
{
|
||||
ctx.RemoveContextMappingBySubjectId(userProductMapping.Id);
|
||||
ctx.RemoveAssingedUserFromPermissionGroups(userProductMapping.Id);
|
||||
// //public static void CleanUpAndRemoveAssignedUser(this IServiceProviderDbContext ctx, UserProductMapping userProductMapping)
|
||||
// //{
|
||||
// // ctx.RemoveContextMappingBySubjectId(userProductMapping.Id);
|
||||
// // ctx.RemoveAssingedUserFromPermissionGroups(userProductMapping.Id);
|
||||
|
||||
ctx.UserProductMappings.Remove(userProductMapping);
|
||||
}
|
||||
// // ctx.UserProductMappings.Remove(userProductMapping);
|
||||
// //}
|
||||
|
||||
public static bool CleanUpAndRemoveUserProductMappings(this IServiceProviderDbContext ctx, Guid userProductMappingId)
|
||||
{
|
||||
var userProductMapping = ctx.GetUserProductMappingById(userProductMappingId);
|
||||
// //public static bool CleanUpAndRemoveUserProductMappings(this IServiceProviderDbContext ctx, Guid userProductMappingId)
|
||||
// //{
|
||||
// // var userProductMapping = ctx.GetUserProductMappingById(userProductMappingId);
|
||||
|
||||
if (userProductMapping == null) return false;
|
||||
// // if (userProductMapping == null) return false;
|
||||
|
||||
ctx.CleanUpAndRemoveAssignedUser(userProductMapping);
|
||||
// // ctx.CleanUpAndRemoveAssignedUser(userProductMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
// // return true;
|
||||
// //}
|
||||
|
||||
public static bool CreateAssignedUser(this IServiceProviderDbContext ctx, UserProductMapping userProductMapping)
|
||||
{
|
||||
if (userProductMapping == null) return false;
|
||||
// //public static UserProductMapping UpdateUserProductMapping(this IServiceProviderDbContext context, UserProductMapping userProductMapping)
|
||||
// //{
|
||||
// // if(userProductMapping == null) return null;
|
||||
// // var existingUserProductMapping = context.UserProductMappings.FirstOrDefault(u => u.Id == userProductMapping.Id);
|
||||
// // if (existingUserProductMapping == null) return null;
|
||||
// // existingUserProductMapping.Id = userProductMapping.Id;
|
||||
// // existingUserProductMapping.UserId = userProductMapping.UserId;
|
||||
// // existingUserProductMapping.ProductId = userProductMapping.ProductId;
|
||||
|
||||
ctx.UserProductMappings.Add(userProductMapping);
|
||||
// // return existingUserProductMapping;
|
||||
|
||||
return true;
|
||||
}
|
||||
// //}
|
||||
|
||||
public static UserProductMapping UpdateUserProductMapping(this IServiceProviderDbContext context, UserProductMapping userProductMapping)
|
||||
{
|
||||
if(userProductMapping == null) return null;
|
||||
var existingUserProductMapping = context.UserProductMappings.FirstOrDefault(u => u.Id == userProductMapping.Id);
|
||||
if (existingUserProductMapping == null) return null;
|
||||
existingUserProductMapping.Id = userProductMapping.Id;
|
||||
existingUserProductMapping.UserId = userProductMapping.UserId;
|
||||
existingUserProductMapping.ProductId = userProductMapping.ProductId;
|
||||
// //public static Product UpdateProduct(this IServiceProviderDbContext ctx, Product product)
|
||||
// //{
|
||||
// // if (product == null) return null;
|
||||
|
||||
return existingUserProductMapping;
|
||||
// // var existingProduct = ctx.Products.FirstOrDefault(u => u.Id == product.Id);
|
||||
// // if (existingProduct == null) return null;
|
||||
|
||||
}
|
||||
|
||||
public static bool CreateProduct(this IServiceProviderDbContext ctx, Product myproduct)
|
||||
{
|
||||
if (myproduct == null) return false;
|
||||
//Automatically add assigneduser for owner
|
||||
TiamServiceProvider? productOwner = ctx.ServiceProviders.FirstOrDefault(x => x.Id == myproduct.ServiceProviderId);
|
||||
if(productOwner == null) return false;
|
||||
var userProductMapping = new UserProductMapping(myproduct.Id, productOwner.OwnerId);
|
||||
ctx.CreateAssignedUser(userProductMapping);
|
||||
ctx.AddProduct(myproduct);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Product UpdateProduct(this IServiceProviderDbContext ctx, Product product)
|
||||
{
|
||||
if (product == null) return null;
|
||||
|
||||
var existingProduct = ctx.Products.FirstOrDefault(u => u.Id == product.Id);
|
||||
if (existingProduct == null) return null;
|
||||
|
||||
existingProduct.Name = product.Name;
|
||||
existingProduct.ServiceProviderId = product.ServiceProviderId;
|
||||
existingProduct.Description = product.Description;
|
||||
existingProduct.Price = product.Price;
|
||||
existingProduct.JsonDetails = product.JsonDetails;
|
||||
//existingProduct.UserMediaId = product.UserMediaId;
|
||||
existingProduct.ProductType = product.ProductType;
|
||||
// // existingProduct.Name = product.Name;
|
||||
// // existingProduct.ServiceProviderId = product.ServiceProviderId;
|
||||
// // existingProduct.Description = product.Description;
|
||||
// // existingProduct.Price = product.Price;
|
||||
// // existingProduct.JsonDetails = product.JsonDetails;
|
||||
// // //existingProduct.UserMediaId = product.UserMediaId;
|
||||
// // existingProduct.ProductType = product.ProductType;
|
||||
|
||||
|
||||
|
||||
return existingProduct;
|
||||
}
|
||||
// // return existingProduct;
|
||||
// //}
|
||||
|
||||
public static void DeleteProductById(this IServiceProviderDbContext ctx, Guid productId)
|
||||
{
|
||||
var product = ctx.Products.FirstOrDefault(u => u.Id == productId);
|
||||
if (product == null) return;
|
||||
// //public static void DeleteProductById(this IServiceProviderDbContext ctx, Guid productId)
|
||||
// //{
|
||||
// // var product = ctx.Products.FirstOrDefault(u => u.Id == productId);
|
||||
// // if (product == null) return;
|
||||
|
||||
ctx.CleanUpAndRemoveUserProductMappings(ctx.GetUserProductMappingsByProductId(productId));
|
||||
ctx.Products.Remove(product);
|
||||
}
|
||||
// // ctx.CleanUpAndRemoveUserProductMappings(ctx.GetUserProductMappingsByProductId(productId));
|
||||
// // ctx.Products.Remove(product);
|
||||
// //}
|
||||
|
||||
public static bool CreatePermissionGroup(this IServiceProviderDbContext ctx, PermissionGroup permissionGroup)
|
||||
{
|
||||
if (permissionGroup == null) return false;
|
||||
// //public static bool CreatePermissionGroup(this IServiceProviderDbContext ctx, PermissionGroup permissionGroup)
|
||||
// //{
|
||||
// // if (permissionGroup == null) return false;
|
||||
|
||||
ctx.PermissionGroups.Add(permissionGroup);
|
||||
// // ctx.PermissionGroups.Add(permissionGroup);
|
||||
|
||||
return true;
|
||||
}
|
||||
// // return true;
|
||||
// //}
|
||||
|
||||
public static bool CreatePermissionContextMapping(this IServiceProviderDbContext ctx, PermissionContextMapping permissionContextMapping)
|
||||
{
|
||||
if (permissionContextMapping == null) return false;
|
||||
// //public static bool CreatePermissionContextMapping(this IServiceProviderDbContext ctx, PermissionContextMapping permissionContextMapping)
|
||||
// //{
|
||||
// // if (permissionContextMapping == null) return false;
|
||||
|
||||
ctx.PermissionContextMappings.Add(permissionContextMapping);
|
||||
// // ctx.PermissionContextMappings.Add(permissionContextMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
// // return true;
|
||||
// //}
|
||||
|
||||
public static bool CreatePermissionGroupUserMapping(this IServiceProviderDbContext ctx, PermissionGroupUserMapping permissionGroupUserMapping)
|
||||
{
|
||||
if (permissionGroupUserMapping == null) return false;
|
||||
// //public static bool CreatePermissionGroupUserMapping(this IServiceProviderDbContext ctx, PermissionGroupUserMapping permissionGroupUserMapping)
|
||||
// //{
|
||||
// // if (permissionGroupUserMapping == null) return false;
|
||||
|
||||
ctx.PermissionGroupUserMappings.Add(permissionGroupUserMapping);
|
||||
// // ctx.PermissionGroupUserMappings.Add(permissionGroupUserMapping);
|
||||
|
||||
return true;
|
||||
}
|
||||
// // return true;
|
||||
// //}
|
||||
|
||||
public static bool CreatePermissionsType(this IServiceProviderDbContext ctx, PermissionsType permissionType)
|
||||
{
|
||||
if (permissionType == null) return false;
|
||||
// //public static bool CreatePermissionsType(this IServiceProviderDbContext ctx, PermissionsType permissionType)
|
||||
// //{
|
||||
// // if (permissionType == null) return false;
|
||||
|
||||
ctx.PermissionsTypes.Add(permissionType);
|
||||
// // ctx.PermissionsTypes.Add(permissionType);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static TiamServiceProvider CreateServiceProvider(this IServiceProviderDbContext ctx, TiamServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider == null) return null;
|
||||
|
||||
ctx.ServiceProviders.Add(serviceProvider);
|
||||
var userProductMapping = new UserProductMapping(serviceProvider.Id, serviceProvider.OwnerId);
|
||||
ctx.CreateAssignedUser(userProductMapping);
|
||||
return serviceProvider;
|
||||
}
|
||||
|
||||
public static TiamServiceProvider UpdateServiceProvider(this IServiceProviderDbContext ctx, TiamServiceProvider serviceProvider)
|
||||
{
|
||||
if (serviceProvider == null) return null;
|
||||
|
||||
var existingServiceProvider = ctx.ServiceProviders.FirstOrDefault(u => u.Id == serviceProvider.Id);
|
||||
if (existingServiceProvider == null) return null;
|
||||
|
||||
existingServiceProvider.Name = serviceProvider.Name;
|
||||
existingServiceProvider.OwnerId = serviceProvider.OwnerId;
|
||||
return existingServiceProvider;
|
||||
}
|
||||
}
|
||||
// // return true;
|
||||
// //}
|
||||
//}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
using System.Net.Http.Json;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||
|
||||
namespace TIAMMobileApp.Services
|
||||
{
|
||||
|
||||
public class TransferDataService : ITransferDataService
|
||||
{
|
||||
private readonly HttpClient http;
|
||||
|
||||
public TransferDataService(HttpClient http)
|
||||
{
|
||||
this.http = http;
|
||||
}
|
||||
|
||||
public async Task<TransferDestination?> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// calls the TransferDataAPI to get the list of destinations
|
||||
public async Task<TransferDestination[]?> GetDestinationsAsync()
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinations}";
|
||||
return await http.GetFromJsonAsync<TransferDestination[]>(url);
|
||||
}
|
||||
|
||||
public Task<TransferDestination> GetTransferDestinationbyAddressAsync(string destinationId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<TransferDestination?> GetTransferDestinationbyCoordinatesAsync(string destinationId)
|
||||
{
|
||||
var url = $"{Setting.BaseUrl}/{APIUrls.GetTransferDestinationByCoordinates}";
|
||||
return await http.GetFromJsonAsync<TransferDestination>(url);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,6 +52,8 @@
|
|||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -11,11 +11,13 @@
|
|||
<link rel="stylesheet" href="_content/TIAMSharedUI/css/bootstrap/bootstrap.min.css" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" rel="stylesheet" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css" rel="stylesheet" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
|
||||
<link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.min.css" asp-append-version="true" rel="stylesheet" />
|
||||
<link href="_content/TIAMSharedUI/css/app.css" rel="stylesheet" />
|
||||
<link href="TIAMMobileApp.styles.css" rel="stylesheet" />
|
||||
<link href="_content/TIAMSharedUI/css/animate.css" rel="stylesheet" />
|
||||
<link href="_content/TIAMSharedUI/css/TourIAm.css" rel="stylesheet" />
|
||||
</head>
|
||||
|
||||
|
|
@ -32,7 +34,7 @@
|
|||
</div>
|
||||
|
||||
<script src="_framework/blazor.webview.js" autostart="false"></script>
|
||||
<script src="_content/BlazorAnimation/blazorAnimationInterop.js"></script>
|
||||
<script src="_content/TIAMSharedUI/blazorAnimationInterop.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
|
||||
|
||||
|
|
|
|||
|
|
@ -420,6 +420,15 @@ namespace TIAM.Resources {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Transfer destination object.
|
||||
/// </summary>
|
||||
public static string TransferDestination {
|
||||
get {
|
||||
return ResourceManager.GetString("TransferDestination", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to New destination.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -237,6 +237,9 @@
|
|||
<data name="Test" xml:space="preserve">
|
||||
<value>Müxik!</value>
|
||||
</data>
|
||||
<data name="TransferDestination" xml:space="preserve">
|
||||
<value>Transzfer uticél</value>
|
||||
</data>
|
||||
<data name="TransferDestinationTitle" xml:space="preserve">
|
||||
<value>Új uticél</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -237,6 +237,9 @@
|
|||
<data name="Test" xml:space="preserve">
|
||||
<value>This works!</value>
|
||||
</data>
|
||||
<data name="TransferDestination" xml:space="preserve">
|
||||
<value>Transfer destination object</value>
|
||||
</data>
|
||||
<data name="TransferDestinationTitle" xml:space="preserve">
|
||||
<value>New destination</value>
|
||||
</data>
|
||||
|
|
|
|||
|
|
@ -16,10 +16,25 @@
|
|||
@inject HttpClient http;
|
||||
<h3>AppLaunch</h3>
|
||||
|
||||
@{
|
||||
if (string.IsNullOrWhiteSpace(TrackingId))
|
||||
{
|
||||
TrackingId = "";
|
||||
<p>Loading...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<p>Loading with trackingId: @TrackingId</p>
|
||||
}
|
||||
}
|
||||
|
||||
Loading....
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public string TrackingId { get; set; }
|
||||
|
||||
string userDetailsStr;
|
||||
string locale;
|
||||
|
||||
|
|
@ -42,7 +57,7 @@ Loading....
|
|||
|
||||
logToBrowserConsole = new LogToBrowserConsole(JSRuntime);
|
||||
//wait for 5 seconds
|
||||
await Task.Delay(0001);
|
||||
await Task.Delay(1000);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(userDetailsStr))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ namespace TIAMSharedUI.Pages.Components
|
|||
IsLoggedIn = sessionService.IsAuthenticated;
|
||||
await PopupMessageBox.ShowAsync("AuthComponent", "Initialized", null, null, null, PopupMessageBox.ButtonOk);
|
||||
|
||||
if (await PopupMessageBox.Show("Cancel", "Cancel this stuff",
|
||||
PopupMessageBox.ButtonNo, PopupMessageBox.ButtonYes) == PopupMessageBox.ButtonNo)
|
||||
{
|
||||
//if (await PopupMessageBox.Show("Cancel", "Cancel this stuff",
|
||||
//PopupMessageBox.ButtonNo, PopupMessageBox.ButtonYes) == PopupMessageBox.ButtonNo)
|
||||
//{
|
||||
//Something is cancelled
|
||||
//args.Cancel = true;
|
||||
}
|
||||
//}
|
||||
componentUpdateService.CallRequestRefresh();
|
||||
StateHasChanged();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
@page "/index"
|
||||
@using AyCode.Interfaces.StorageHandlers;
|
||||
@using BlazorAnimation
|
||||
@using Newtonsoft.Json;
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide;
|
||||
|
|
@ -21,58 +22,61 @@
|
|||
<AuthComponent />
|
||||
<div class="container" style="align-content: center;">
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
|
||||
<h1>@localizer.GetString("Index.Title")</h1>
|
||||
<h2>@localizer.GetString("Index.Subtitle")</h2>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
|
||||
|
||||
<NavLink class="nav-link col-md-6 col-lg-4 col-12" href="transfer">
|
||||
<div class="card my-3 my-card text-white">
|
||||
<img class="card-img" src="_content/TIAMSharedUI/images/m_transfer.jpg" alt="Card image">
|
||||
<div class="card-img-overlay">
|
||||
|
||||
<h3 class="card-title">@localizer.GetString("Index.Transfer")</h3>
|
||||
|
||||
<p class="card-text">@localizer.GetString("Index.Transfer.Desc")</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</NavLink>
|
||||
|
||||
<NavLink class="nav-link col-md-6 col-lg-4 col-12" href="tours">
|
||||
<div class="card my-3 my-card text-white">
|
||||
<img class="card-img" src="_content/TIAMSharedUI/images/m_tour.jpg" alt="Card image">
|
||||
<div class="card-img-overlay">
|
||||
<h3 class="card-title">@localizer.GetString("Index.Tours")</h3>
|
||||
<p class="card-text">@localizer.GetString("Index.Tours.Desc")</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</NavLink>
|
||||
|
||||
<NavLink class="nav-link col-md-6 col-lg-4 col-12" href="clubcards">
|
||||
<div class="card my-3 my-card text-white">
|
||||
<img class="card-img" src="_content/TIAMSharedUI/images/m_restaurant.jpg" alt="Card image">
|
||||
<div class="card-img-overlay">
|
||||
<h3 class="card-title">@localizer.GetString("Index.Clubcards")</h3>
|
||||
<p class="card-text">@localizer.GetString("Index.Clubcards.Desc")</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</NavLink>
|
||||
<div class="row">
|
||||
|
||||
<NavLink class="nav-link col-md-6 col-lg-4 col-12" href="transfer">
|
||||
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card m-3 my-card text-white">
|
||||
<img class="card-img" src="_content/TIAMSharedUI/images/m_transfer.jpg" alt="Card image">
|
||||
<div class="card-img-overlay">
|
||||
|
||||
<h3 class="card-title">@localizer.GetString("Index.Transfer")</h3>
|
||||
|
||||
<p class="card-text">@localizer.GetString("Index.Transfer.Desc")</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</NavLink>
|
||||
<NavLink class="nav-link col-md-6 col-lg-4 col-12" href="tours">
|
||||
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card m-3 my-card text-white">
|
||||
<img class="card-img" src="_content/TIAMSharedUI/images/m_tour.jpg" alt="Card image">
|
||||
<div class="card-img-overlay">
|
||||
<h3 class="card-title">@localizer.GetString("Index.Tours")</h3>
|
||||
<p class="card-text">@localizer.GetString("Index.Tours.Desc")</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</NavLink>
|
||||
<NavLink class="nav-link col-md-6 col-lg-4 col-12" href="clubcards">
|
||||
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card m-3 my-card text-white">
|
||||
<img class="card-img" src="_content/TIAMSharedUI/images/m_restaurant.jpg" alt="Card image">
|
||||
<div class="card-img-overlay">
|
||||
<h3 class="card-title">@localizer.GetString("Index.Clubcards")</h3>
|
||||
<p class="card-text">@localizer.GetString("Index.Clubcards.Desc")</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
@using TIAMSharedUI.Shared
|
||||
@using BlazorAnimation
|
||||
@using TIAMSharedUI.Shared
|
||||
@using TIAMWebApp.Shared.Application.Models;
|
||||
@using TIAMWebApp.Shared.Application.Interfaces;
|
||||
@using TIAMSharedUI.Pages.User;
|
||||
|
|
@ -8,225 +9,273 @@
|
|||
<div class="row py-3">
|
||||
|
||||
<div class=" col-12 col-xl-3">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Hotel details</span>
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Hotel details</span>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<!--h6 class="mb-0"> <a href="#">All settings</a> </h6-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<div class="flex-fill">
|
||||
<h4 class="bold">Your QR code</h4>
|
||||
<p class="text-muted"> Use this in printed material, to gain referrals</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="api/pictures/1" download="data:image/png;base64,@ImageSource" target="_top">
|
||||
|
||||
<img class="align-self-center img-fluid"
|
||||
src="data:image/png;base64,@ImageSource" width="128" />
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<!--h6 class="mb-0"> <a href="#">All settings</a> </h6-->
|
||||
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
<h4> Hotel name: <span class="small text-muted"> Example hotel </span></h4>
|
||||
<h4> Address: <span class="small text-muted"> Budapest, Minta u. 46 </span></h4>
|
||||
<h4> Phone number: <span class="small text-muted"> +36 1 123 4567</span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<div class="flex-fill">
|
||||
<h4 class="bold">Your QR code</h4>
|
||||
<p class="text-muted"> Use this in printed material, to gain referrals</p>
|
||||
</div>
|
||||
<div>
|
||||
<img class="align-self-center img-fluid"
|
||||
src="_content/TIAMSharedUI/images/myqr.png" width="128">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
<h4> Hotel name: <span class="small text-muted"> Example hotel </span></h4>
|
||||
<h4> Address: <span class="small text-muted"> Budapest, Minta u. 46 </span></h4>
|
||||
<h4> Phone number: <span class="small text-muted"> +36 1 123 4567</span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</div>
|
||||
<div class=" col-12 col-xl-3">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">My orders</span>
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">My orders</span>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="/user/transfers">All transfers</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
|
||||
<DxGrid Data="@OrderData">
|
||||
<Columns>
|
||||
<DxGridDataColumn FieldName="Date" DisplayFormat="D" MinWidth="100">
|
||||
<CellDisplayTemplate>
|
||||
<a class="d-block text-left" href="transferdetails">@context.Value</a>
|
||||
</CellDisplayTemplate>
|
||||
|
||||
</DxGridDataColumn>
|
||||
<DxGridDataColumn FieldName="Income" Width="15%" />
|
||||
<DxGridDataColumn FieldName="TransactionId" Width="15%" />
|
||||
<DxGridDataColumn FieldName="Status" Width="10%" />
|
||||
</Columns>
|
||||
</DxGrid>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="/user/transfers">All transfers</a> </h6>
|
||||
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<h4> Some <span class="small text-muted"> conclusion </span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
</Animation>
|
||||
</div>
|
||||
<div class=" col-12 col-xl-3">
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Messagess</span>
|
||||
|
||||
<DxGrid Data="@OrderData">
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="#">All messages</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
|
||||
|
||||
|
||||
<div class="media text-muted pt-3">
|
||||
<!--img src="https://bootdey.com/img/Content/avatar/avatar7.png" alt="" class="mr-2 rounded" width="32" height="32"-->
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
<div class="media text-muted pt-3">
|
||||
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
<div class="media text-muted pt-3">
|
||||
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
<div class="media text-muted pt-3">
|
||||
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</div>
|
||||
|
||||
<div class=" col-12 col-xl-3">
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Panel title</span>
|
||||
<p class="text-muted mb-0">Subtitle</p>
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="#">All details</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<div class="flex-fill">
|
||||
<h5 class="bold">Some info</h5>
|
||||
<p class="text-muted"> Budapest, Dózsa György út 35, 1146</p>
|
||||
</div>
|
||||
<div>
|
||||
<!--img class="align-self-center img-fluid"
|
||||
src="https://mdbcdn.b-cdn.net/img/Photos/Horizontal/E-commerce/Products/6.webp" width="250"-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ul id="progressbar-1" class="mx-0 mt-0 mb-5 px-0 pt-0 pb-4">
|
||||
<li class="step0 active" id="step1">
|
||||
<span style="margin-left: 22px; margin-top: 12px;">PLACED</span>
|
||||
</li>
|
||||
<li class="step0 active text-center" id="step2"><span>WAITING FOR PICK UP</span></li>
|
||||
<li class="step0 text-muted text-end" id="step3">
|
||||
<span style="margin-right: 22px;">FINISHED</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<h4> Some <span class="small text-muted"> conclusion </span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</div>
|
||||
<div class=" col-12">
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Affiliates</span>
|
||||
<p class="text-muted mb-0">Details</p>
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="#">All details</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
|
||||
<style>
|
||||
.dxbl-grid {
|
||||
--dxbl-grid-font-family: inherit;
|
||||
--dxbl-grid-font-size: 0.75rem;
|
||||
--dxbl-grid-line-height: 1.4285;
|
||||
--dxbl-grid-min-width: 240px;
|
||||
--dxbl-grid-bg: #e7e6f7;
|
||||
--dxbl-grid-color: #58457b;
|
||||
}
|
||||
</style>
|
||||
|
||||
<DxGrid Data="@Data">
|
||||
<Columns>
|
||||
<DxGridDataColumn FieldName="Date" DisplayFormat="D" MinWidth="100">
|
||||
<CellDisplayTemplate>
|
||||
<a class="d-block text-left" href="transferdetails">@context.Value</a>
|
||||
</CellDisplayTemplate>
|
||||
|
||||
</DxGridDataColumn>
|
||||
<DxGridDataColumn FieldName="Income" Width="15%" />
|
||||
<DxGridDataColumn FieldName="TransactionId" Width="15%" />
|
||||
<DxGridDataColumn FieldName="Status" Width="10%" />
|
||||
<DxGridDataColumn FieldName="CompanyName" AllowSort="true" />
|
||||
<DxGridDataColumn FieldName="ContactName" />
|
||||
<DxGridDataColumn FieldName="ContactTitle" Width="3%" />
|
||||
<DxGridDataColumn FieldName="Country" Width="10%" />
|
||||
<DxGridDataColumn FieldName="City" Width="10%" />
|
||||
<DxGridDataColumn FieldName="Address" />
|
||||
<DxGridDataColumn FieldName="Phone" Width="10%" />
|
||||
</Columns>
|
||||
</DxGrid>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<h4> Some <span class="small text-muted"> conclusion </span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" col-12 col-xl-3">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Hotel details</span>
|
||||
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="#">All settings</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" col-12 col-xl-3">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Panel title</span>
|
||||
<p class="text-muted mb-0">Subtitle</p>
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="#">All details</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<div class="flex-fill">
|
||||
<h5 class="bold">Some info</h5>
|
||||
<p class="text-muted"> Budapest, Dózsa György út 35, 1146</p>
|
||||
</div>
|
||||
<div>
|
||||
<!--img class="align-self-center img-fluid"
|
||||
src="https://mdbcdn.b-cdn.net/img/Photos/Horizontal/E-commerce/Products/6.webp" width="250"-->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<ul id="progressbar-1" class="mx-0 mt-0 mb-5 px-0 pt-0 pb-4">
|
||||
<li class="step0 active" id="step1">
|
||||
<span style="margin-left: 22px; margin-top: 12px;">PLACED</span>
|
||||
</li>
|
||||
<li class="step0 active text-center" id="step2"><span>WAITING FOR PICK UP</span></li>
|
||||
<li class="step0 text-muted text-end" id="step3">
|
||||
<span style="margin-right: 22px;">FINISHED</span>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="d-flex flex-row mb-4 pb-2">
|
||||
<h4> Some <span class="small text-muted"> conclusion </span></h4>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class=" col-12">
|
||||
<div class="card mycard card-admin" style="border-radius: 16px;">
|
||||
<div class="card-header py-2 px-4">
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<div>
|
||||
<span class="fw-bold text-body">Affiliates</span>
|
||||
<p class="text-muted mb-0">Details</p>
|
||||
</div>
|
||||
<div>
|
||||
<h6 class="mb-0"> <a href="#">All details</a> </h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body card-admin-body py-2 px-4">
|
||||
|
||||
<style>
|
||||
.dxbl-grid {
|
||||
--dxbl-grid-font-family: inherit;
|
||||
--dxbl-grid-font-size: 0.75rem;
|
||||
--dxbl-grid-line-height: 1.4285;
|
||||
--dxbl-grid-min-width: 240px;
|
||||
--dxbl-grid-bg: #e7e6f7;
|
||||
--dxbl-grid-color: #58457b;
|
||||
}
|
||||
</style>
|
||||
|
||||
<DxGrid Data="@Data">
|
||||
<Columns>
|
||||
<DxGridDataColumn FieldName="CompanyName" AllowSort="true" />
|
||||
<DxGridDataColumn FieldName="ContactName" />
|
||||
<DxGridDataColumn FieldName="ContactTitle" Width="3%" />
|
||||
<DxGridDataColumn FieldName="Country" Width="10%" />
|
||||
<DxGridDataColumn FieldName="City" Width="10%" />
|
||||
<DxGridDataColumn FieldName="Address" />
|
||||
<DxGridDataColumn FieldName="Phone" Width="10%" />
|
||||
</Columns>
|
||||
</DxGrid>
|
||||
|
||||
</div>
|
||||
<div class="card-footer py-2 px-4">
|
||||
<div class="d-flex justify-content-between">
|
||||
|
||||
<a href="#!">Modify</a>
|
||||
<div class="border-start h-100"></div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Animation>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using SkiaSharp;
|
||||
using System;
|
||||
using System.Buffers.Text;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
|
@ -21,6 +23,9 @@ namespace TIAMSharedUI.Pages.User
|
|||
[Inject]
|
||||
IUserDataService UserDataService { get; set; }
|
||||
|
||||
[Inject]
|
||||
IServiceProviderDataService ServiceProviderDataService { get; set; }
|
||||
|
||||
object? OrderData { get; set; }
|
||||
object? AffiliateData { get; set; }
|
||||
|
||||
|
|
@ -29,6 +34,8 @@ namespace TIAMSharedUI.Pages.User
|
|||
bool isUserLoggedIn;
|
||||
int userType = 0;
|
||||
|
||||
public string ImageSource { get; set; } = "";
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -98,6 +105,9 @@ namespace TIAMSharedUI.Pages.User
|
|||
Phone = s.Phone
|
||||
};
|
||||
});
|
||||
|
||||
//SKBitmap bitmap = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
|
||||
ImageSource = await ServiceProviderDataService.GetQRCodeByProductIdAsync(Guid.NewGuid());
|
||||
}
|
||||
[Parameter] public bool ShowSeriesPointMarkers { get; set; }
|
||||
[Parameter] public bool ShowSeriesLabels { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
<div class="card-body card-admin-body py-2 px-4">
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
|
||||
|
||||
|
||||
<div class="media text-muted pt-3">
|
||||
<!--img src="https://bootdey.com/img/Content/avatar/avatar7.png" alt="" class="mr-2 rounded" width="32" height="32"-->
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
<div class="media text-muted pt-3">
|
||||
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
<div class="media text-muted pt-3">
|
||||
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
<div class="media text-muted pt-3">
|
||||
|
||||
<p class="media-body pb-3 mb-0 small lh-125 border-bottom border-gray">
|
||||
<strong class="d-block text-gray-dark">username</strong>
|
||||
Donec id elit non mi porta gravida at eget metus...
|
||||
</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TIAMSharedUI.Pages.User
|
||||
{
|
||||
public partial class Messages
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
@page "/user/profile"
|
||||
|
||||
<div class="text-center m-5">
|
||||
<h1>Profile</h1>
|
||||
<h2 style="font-size:small">Have a nice day!</h2>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<ProfileComponent></ProfileComponent>
|
||||
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,171 @@
|
|||
<h3>ProfileComponent</h3>
|
||||
|
||||
|
||||
|
||||
<div class="row flex-lg-nowrap">
|
||||
<div class="col-12 col-lg-auto mb-3" style="width: 200px;">
|
||||
<div class="card mycard p-3">
|
||||
<div class="e-navlist e-navlist--active-bg">
|
||||
<ul class="nav">
|
||||
<li class="nav-item"><a class="nav-link px-2 active" href="#"><i class="fa fa-fw fa-bar-chart mr-1"></i><span>Overview</span></a></li>
|
||||
<li class="nav-item"><a class="nav-link px-2" href="https://www.bootdey.com/snippets/view/bs4-crud-users" target="__blank"><i class="fa fa-fw fa-th mr-1"></i><span>CRUD</span></a></li>
|
||||
<li class="nav-item"><a class="nav-link px-2" href="https://www.bootdey.com/snippets/view/bs4-edit-profile-page" target="__blank"><i class="fa fa-fw fa-cog mr-1"></i><span>Settings</span></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<div class="card mycard">
|
||||
<div class="card-body">
|
||||
<div class="e-profile">
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-auto mb-3">
|
||||
<div class="mx-auto" style="width: 140px;">
|
||||
<div class="d-flex justify-content-center align-items-center rounded" style="height: 140px; background-color: rgb(233, 236, 239);">
|
||||
<span style="color: rgb(166, 168, 170); font: bold 8pt Arial;">140x140</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col d-flex flex-column flex-sm-row justify-content-between mb-3">
|
||||
<div class="text-center text-sm-left mb-2 mb-sm-0">
|
||||
<h4 class="pt-sm-2 pb-1 mb-0 text-nowrap">John Smith</h4>
|
||||
<p class="mb-0">johnny.s</p>
|
||||
<div class="text-muted"><small>Last seen 2 hours ago</small></div>
|
||||
<div class="mt-2">
|
||||
<button class="btn btn-primary" type="button">
|
||||
<i class="fa fa-fw fa-camera"></i>
|
||||
<span>Change Photo</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center text-sm-right">
|
||||
<span class="badge badge-secondary">administrator</span>
|
||||
<div class="text-muted"><small>Joined 09 Dec 2017</small></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="nav nav-tabs">
|
||||
<li class="nav-item"><a href="" class="active nav-link">Settings</a></li>
|
||||
</ul>
|
||||
<div class="tab-content pt-3">
|
||||
<div class="tab-pane active">
|
||||
<form class="form" novalidate="">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>Full Name</label>
|
||||
<input class="form-control" type="text" name="name" placeholder="John Smith" value="John Smith">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>Username</label>
|
||||
<input class="form-control" type="text" name="username" placeholder="johnny.s" value="johnny.s">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>Email</label>
|
||||
<input class="form-control" type="text" placeholder="user@example.com">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col mb-3">
|
||||
<div class="form-group">
|
||||
<label>About</label>
|
||||
<textarea class="form-control" rows="5" placeholder="My Bio"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12 col-sm-6 mb-3">
|
||||
<div class="mb-2"><b>Change Password</b></div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>Current Password</label>
|
||||
<input class="form-control" type="password" placeholder="••••••">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>New Password</label>
|
||||
<input class="form-control" type="password" placeholder="••••••">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>Confirm <span class="d-none d-xl-inline">Password</span></label>
|
||||
<input class="form-control" type="password" placeholder="••••••">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-sm-5 offset-sm-1 mb-3">
|
||||
<div class="mb-2"><b>Keeping in Touch</b></div>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<label>Email Notifications</label>
|
||||
<div class="custom-controls-stacked px-2">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="notifications-blog" checked="">
|
||||
<label class="custom-control-label" for="notifications-blog">Blog posts</label>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="notifications-news" checked="">
|
||||
<label class="custom-control-label" for="notifications-news">Newsletter</label>
|
||||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="notifications-offers" checked="">
|
||||
<label class="custom-control-label" for="notifications-offers">Personal Offers</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col d-flex justify-content-end">
|
||||
<button class="btn btn-primary" type="submit">Save Changes</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 mb-3">
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title font-weight-bold">Support</h6>
|
||||
<p class="card-text">Get fast, free help from our friendly assistants.</p>
|
||||
<button type="button" class="btn btn-primary">Contact Us</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,104 @@
|
|||
@page "/user/destinations"
|
||||
@using AyCode.Models.Messages
|
||||
@using TIAM.Entities.ServiceProviders
|
||||
@using TIAM.Resources
|
||||
@using TIAMSharedUI.Pages.Components
|
||||
@using TIAMSharedUI.Shared
|
||||
@using TIAMWebApp.Shared.Application.Models
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.Messages
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@layout AdminLayout
|
||||
@inject LogToBrowserConsole logToBrowserConsole
|
||||
@inject IStringLocalizer<TIAMResources> localizer
|
||||
<PageTitle>Transfers</PageTitle>
|
||||
|
||||
<div class="text-center m-5">
|
||||
<h1>Destination management</h1>
|
||||
<h2 style="font-size:small">Manage transfers here!</h2>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class=" col-12">
|
||||
<h3>@localizer.GetString("TransferDestination")</h3>
|
||||
|
||||
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
<div class="align-self-end pl-2 pb-2">
|
||||
<DxButton Text="Column Chooser"
|
||||
RenderStyle="ButtonRenderStyle.Secondary"
|
||||
IconCssClass="btn-column-chooser"
|
||||
Click="ColumnChooserButton_Click" />
|
||||
</div>
|
||||
<DxGrid @ref="Grid"
|
||||
Data="TransferData"
|
||||
PageSize="8"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
CustomizeElement="Grid_CustomizeElement"
|
||||
CustomizeEditModel="Grid_CustomizeEditModel"
|
||||
EditModelSaving="Grid_EditModelSaving"
|
||||
DataItemDeleting="Grid_DataItemDeleting"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.ColumnsContainer"
|
||||
KeyboardNavigationEnabled="true"
|
||||
ShowFilterRow="true">
|
||||
<Columns>
|
||||
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
|
||||
<DxGridDataColumn FieldName="Id" MinWidth="80" Width="20%" Visible="false" />
|
||||
<DxGridDataColumn FieldName="Name" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" Width="20%">
|
||||
<CellDisplayTemplate>
|
||||
@{
|
||||
var keyField = context.Value;
|
||||
<a class="d-block text-left" href="transferdetails">@context.Value</a>
|
||||
}
|
||||
</CellDisplayTemplate>
|
||||
</DxGridDataColumn>
|
||||
<DxGridDataColumn FieldName="Description" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" Width="20%" />
|
||||
<DxGridDataColumn FieldName="AddressString" MinWidth="80" Width="20%" />
|
||||
<DxGridDataColumn FieldName="Price" MinWidth="80" Width="20%" />
|
||||
|
||||
|
||||
</Columns>
|
||||
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
@{
|
||||
var transfer = (TransferDestinationWizardModel)EditFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationName) ColSpanMd="6">
|
||||
@EditFormContext.GetEditor("Name")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Destination) ColSpanMd="6">
|
||||
@EditFormContext.GetEditor("Destination")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
|
||||
@EditFormContext.GetEditor("AddressString")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.Price) ColSpanMd="6">
|
||||
@EditFormContext.GetEditor("Price")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
</DxGrid>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class=" col-12 col-xl-6">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
using DevExpress.Blazor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Interfaces;
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
|
||||
namespace TIAMSharedUI.Pages.User
|
||||
{
|
||||
public partial class TransferDestinations
|
||||
{
|
||||
|
||||
IGrid Grid { get; set; }
|
||||
//object? TransferData { get; set; }
|
||||
|
||||
public TransferDestinationWizardModel myModel = new TransferDestinationWizardModel();
|
||||
|
||||
bool PopupVisible { get; set; }
|
||||
public List<string> ignoreList = new List<string>
|
||||
{
|
||||
"ReceiverId"
|
||||
};
|
||||
|
||||
public MessageWizardModel messageWizardModel = new MessageWizardModel();
|
||||
|
||||
[Inject]
|
||||
public ITransferDataService transferDataService { get; set; }
|
||||
|
||||
|
||||
object? TransferData = new TransferDestinationWizardModel[]
|
||||
{
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Liszt Ferenc Airport", "International airport of Budapest", "1185, Budapest, Liszt Ferenc Repülőtér" ),
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Buda Castle", "Historical site in the heart of Budapest", "1014 Budapest, Szent György tér 2" ),
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Hungarian National Museum", "Historical site in the heart of Budapest", "1088 Budapest, Múzeum krt. 14-16" ),
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Parliament of Hungary", "Historical site in the heart of Budapest", "1055 Budapest, Kossuth Lajos tér 1-3" ),
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Heroes square", "Historical site in the heart of Budapest", "1146 Budapest, Hősök tere" ),
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Gellert Hill", "Historical site in the heart of Budapest", "1118 Budapest, Gellérthegy" ),
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), "Margaret Island", "Historical site in the heart of Budapest", "1138 Budapest, Margitsziget" ),
|
||||
};
|
||||
|
||||
object? TransferDataFromDb = new TransferDestinationWizardModel[] { };
|
||||
|
||||
void CancelCreateClick()
|
||||
{
|
||||
|
||||
|
||||
PopupVisible = false;
|
||||
}
|
||||
void EulaPopupClosed()
|
||||
{
|
||||
//cancel clicked
|
||||
|
||||
}
|
||||
void EulaPopupClosing(PopupClosingEventArgs args)
|
||||
{
|
||||
//myModel = new TransferWizardModel();
|
||||
messageWizardModel = new MessageWizardModel();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public async Task SubmitForm(object Result)
|
||||
{
|
||||
//await WizardProcessor.ProcessWizardAsync(Result.GetType(), Result);
|
||||
logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}");
|
||||
}
|
||||
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
//if (firstRender)
|
||||
// await Grid.StartEditRowAsync(0);
|
||||
}
|
||||
|
||||
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (e.IsNew)
|
||||
{
|
||||
var newDestination = (TransferDestinationWizardModel)e.EditModel;
|
||||
newDestination.Id = Guid.NewGuid().ToString();
|
||||
newDestination.Name = "ghjgkg hkgh ghjkghgkjgh";
|
||||
newDestination.Description = "ghjgkg hkgh ghjkghgkjgh";
|
||||
newDestination.AddressString = "ghjgkg hkgh ghjkghgkjgh";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
|
||||
{
|
||||
if (e.IsNew)
|
||||
{
|
||||
//add new row to grid
|
||||
myModel = (TransferDestinationWizardModel)e.EditModel;
|
||||
//add mymodel to transferData array
|
||||
TransferData = ((TransferDestinationWizardModel[])TransferData).Append(myModel);
|
||||
|
||||
//add new orderData to orderData array
|
||||
logToBrowserConsole.LogToBC("New orderData added");
|
||||
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
logToBrowserConsole.LogToBC("orderData updated");
|
||||
//modify transferData where transferData.Id == e.EditModel.Id
|
||||
//get transfer from TransferData by Id
|
||||
|
||||
foreach (var transferToModify in (TransferDestinationWizardModel[])TransferData)
|
||||
{
|
||||
myModel = (TransferDestinationWizardModel)e.EditModel;
|
||||
|
||||
if (transferToModify.Id == myModel.Id)
|
||||
{
|
||||
myModel = (TransferDestinationWizardModel)e.EditModel;
|
||||
transferToModify.Name = myModel.Name;
|
||||
transferToModify.Description = myModel.Description;
|
||||
transferToModify.AddressString = myModel.AddressString;
|
||||
transferToModify.Price = myModel.Price;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
|
||||
|
||||
await UpdateDataAsync();
|
||||
}
|
||||
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
|
||||
{
|
||||
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
|
||||
//remove orderData from orderData array
|
||||
logToBrowserConsole.LogToBC("orderData deleted");
|
||||
//await UpdateDataAsync();
|
||||
}
|
||||
async Task UpdateDataAsync()
|
||||
{
|
||||
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
|
||||
//refresh grid
|
||||
logToBrowserConsole.LogToBC("orderData grid refreshed");
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
base.OnInitialized();
|
||||
var a = await transferDataService.GetDestinationsAsync();
|
||||
logToBrowserConsole.LogToBC($"TransferDataFromDb: {((TransferDestinationWizardModel[])TransferDataFromDb).Length}");
|
||||
foreach (var item in a)
|
||||
{
|
||||
//add new transferwizardmodel to transferData array
|
||||
TransferDataFromDb = ((TransferDestinationWizardModel[])TransferDataFromDb).Append(
|
||||
new TransferDestinationWizardModel(Guid.NewGuid(), item.Name, item.Description, item.AddressString));
|
||||
logToBrowserConsole.LogToBC($"TransferDataFromDb: {item.Name}");
|
||||
}
|
||||
}
|
||||
|
||||
void ColumnChooserButton_Click()
|
||||
{
|
||||
Grid.ShowColumnChooser();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<header class="pb-5">
|
||||
|
||||
@using BlazorAnimation
|
||||
<header class="pb-5">
|
||||
<Animation Effect="@Effect.FadeIn" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div id="owl-demo" class="owl-carousel owl-theme">
|
||||
|
||||
<div class="item d-flex align-items-center"><img src="https://images.unsplash.com/photo-1551867633-194f125bddfa?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" class="my-auto" alt="The Last of us"></div>
|
||||
|
|
@ -7,7 +8,7 @@
|
|||
<div class="item d-flex align-items-center"><img src="https://images.unsplash.com/photo-1507622560124-621e26755fb8?auto=format&fit=crop&q=80&w=2070&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D" class="my-auto" alt="Mirror Edge"></div>
|
||||
|
||||
</div>
|
||||
|
||||
</Animation>
|
||||
<!--div id="carouselExampleCaptions" class="carousel slide" data-bs-ride="carousel">
|
||||
<div class="carousel-indicators">
|
||||
<button type="button" data-bs-target="#carouselExampleCaptions" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,12 @@
|
|||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="user/cards">
|
||||
Cards
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" @onclick="()=>expandSysAdminNav = !expandSysAdminNav">
|
||||
<span class="oi oi-list-rich" aria-hidden="true"></span> System Admin
|
||||
|
|
@ -55,6 +61,11 @@
|
|||
Transfers
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="user/destinations">
|
||||
Destinations
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
}
|
||||
|
|
@ -73,7 +84,7 @@
|
|||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="user/serviceprovider">
|
||||
<NavLink class="nav-link" href="user/serviceprovider/5453-a87f77787d-khj899">
|
||||
Manage
|
||||
</NavLink>
|
||||
</div>
|
||||
|
|
@ -94,8 +105,8 @@
|
|||
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="account">
|
||||
Account
|
||||
<NavLink class="nav-link" href="user/profile">
|
||||
Profile
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,9 @@ select:focus-visible {
|
|||
.my-sidebar {
|
||||
/*background-color: #c6d2ed;*/
|
||||
/*background-color: #E3D0D8;*/
|
||||
background-color: #d8dcef;
|
||||
/*background-color: #d8dcef;*/
|
||||
background-color: #fbfbfb8f;
|
||||
|
||||
min-width: 200px;
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 1.8 MiB |
|
|
@ -10,6 +10,8 @@
|
|||
<PackageReference Include="Blazored.LocalStorage" Version="4.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" PrivateAssets="all" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
<link href="_content/TIAMSharedUI/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.carousel.min.css" rel="stylesheet" />
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/assets/owl.theme.default.css" rel="stylesheet" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/OwlCarousel2/2.3.4/owl.carousel.min.js"></script>
|
||||
<link href="_content/DevExpress.Blazor.Themes/blazing-berry.bs5.min.css" asp-append-version="true" rel="stylesheet" />
|
||||
|
|
@ -16,7 +17,7 @@
|
|||
<link href="_content/TIAMSharedUI/css/animate.css" rel="stylesheet" />
|
||||
<link href="_content/TIAMSharedUI/css/TourIAm.css" rel="stylesheet" />
|
||||
<link rel="icon" type="image/png" href="_content/TIAMSharedUI/favicon.png" />
|
||||
<link href="TIAMWebApp.Client.styles.css" rel="stylesheet" />
|
||||
<link href="TIAMWebApp.Client.styles.css" rel="stylesheet" />
|
||||
|
||||
</head>
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 18 KiB |
|
|
@ -1,8 +1,15 @@
|
|||
using DevExpress.Drawing;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using QRCoder;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp.Views.Desktop;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Text.Json;
|
||||
using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
|
|
@ -17,15 +24,15 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[Route("api/[controller]")]
|
||||
public class ServiceProviderAPIController : ControllerBase
|
||||
{
|
||||
private ServiceProviderDal _serviceProviderDal;
|
||||
private AdminDal _adminDal;
|
||||
|
||||
private readonly ILogger<ServiceProviderAPIController> _logger;
|
||||
|
||||
public ServiceProviderAPIController(ILogger<ServiceProviderAPIController> logger, ServiceProviderDal serviceProviderDal)
|
||||
public ServiceProviderAPIController(ILogger<ServiceProviderAPIController> logger, AdminDal adminDal)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
_serviceProviderDal = serviceProviderDal;
|
||||
_adminDal = adminDal;
|
||||
}
|
||||
|
||||
//15.
|
||||
|
|
@ -67,7 +74,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
Console.WriteLine($"ServiceProvider to be created: {id}, {name}, {ownerId}");
|
||||
|
||||
await _serviceProviderDal.CreateServiceProviderAsync(new TiamServiceProvider(id, name, ownerId));
|
||||
await _adminDal.CreateServiceProviderAsync(new TiamServiceProvider(id, name, ownerId));
|
||||
}
|
||||
}
|
||||
return Ok("yes");
|
||||
|
|
@ -86,7 +93,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
{
|
||||
//var users = await _serviceProviderDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
|
||||
//return users;
|
||||
return _serviceProviderDal.GetServiceProvidersAsync();
|
||||
return _adminDal.GetServiceProvidersAsync();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -98,7 +105,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
{
|
||||
Console.WriteLine($"GetServiceProviderById called with id: {id}");
|
||||
|
||||
return await _serviceProviderDal.GetServiceProviderByIdAsync(id);
|
||||
return await _adminDal.GetServiceProviderByIdAsync(id);
|
||||
}
|
||||
|
||||
//17.
|
||||
|
|
@ -111,7 +118,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
{
|
||||
Console.WriteLine($"GetServiceProvidersByOwnerId called with ownerId: {ownerId}");
|
||||
|
||||
var serviceProviders = await _serviceProviderDal.GetServiceProvidersAsync();
|
||||
var serviceProviders = await _adminDal.GetServiceProvidersAsync();
|
||||
|
||||
//return serviceProviders.Where(x => x.OwnerId == ownerId).ToList();
|
||||
var myServiceproviders = serviceProviders.Where(x => x.OwnerId == ownerId).ToDictionary(x => x.Id, x => x.Name);
|
||||
|
|
@ -138,7 +145,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
UserProductMapping userProductMapping = new UserProductMapping(createUserProductMappingModel.ContextId, createUserProductMappingModel.ContextId);
|
||||
|
||||
var result = await _serviceProviderDal.CreateUserProductMappingAsync(userProductMapping);
|
||||
var result = await _adminDal.CreateUserProductMappingAsync(userProductMapping);
|
||||
|
||||
|
||||
return Ok(result);
|
||||
|
|
@ -156,7 +163,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
Dictionary<Guid, string> userProductMappingDictionary = new Dictionary<Guid, string>();
|
||||
|
||||
var serviceProviders = await _serviceProviderDal.GetServiceProvidersAsync();
|
||||
var serviceProviders = await _adminDal.GetServiceProvidersAsync();
|
||||
|
||||
var myServiceproviders = serviceProviders.Where(x => x.Id == serviceProviderId).ToDictionary(x => x.Id, x => x.Name);
|
||||
//put serviceprovider id and name into a dictionary
|
||||
|
|
@ -165,22 +172,54 @@ namespace TIAMWebApp.Server.Controllers
|
|||
}
|
||||
|
||||
[HttpPost]
|
||||
[Route("CreateProduct")]
|
||||
[Route(APIUrls.AddProductRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public async Task<IActionResult> CreateProduct([FromBody] Product product)
|
||||
public async Task<IActionResult> AddProduct([FromBody] Product product)
|
||||
{
|
||||
Console.WriteLine("CreateProduct called");
|
||||
Console.WriteLine("AddProduct called");
|
||||
if (product == null)
|
||||
{
|
||||
return BadRequest("Product is required");
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = _serviceProviderDal.CreateProductAsync(product);
|
||||
var result = _adminDal.AddProduct(product);
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route("GetQRCodeByProductId")]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public async Task<IActionResult> GetQRCodeByProductId([FromBody] Guid productId)
|
||||
{
|
||||
Console.WriteLine("GetQRCode called");
|
||||
if (productId == Guid.Empty)
|
||||
{
|
||||
return BadRequest("Product is required");
|
||||
}
|
||||
else
|
||||
{
|
||||
//var result = _serviceProviderDal.GetQRCodeAsync(productId);
|
||||
|
||||
QRCodeGenerator qrGenerator = new QRCodeGenerator();
|
||||
QRCodeData qrCodeData = qrGenerator.CreateQrCode($"https://touriam.com/{productId}", QRCodeGenerator.ECCLevel.Q);
|
||||
QRCode qrCode = new QRCode(qrCodeData);
|
||||
//Bitmap qrCodeImage = qrCode.GetGraphic(20);
|
||||
string rootpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "assets");
|
||||
Bitmap qrCodeImage = qrCode.GetGraphic(20, Color.DarkMagenta, Color.White, (Bitmap)Bitmap.FromFile(rootpath + "/myimage.png"));
|
||||
Console.WriteLine($"qrCodeLogo: {rootpath}/myimage.png");
|
||||
MemoryStream ms = new MemoryStream();
|
||||
qrCodeImage.Save(ms, ImageFormat.Jpeg);
|
||||
byte[] byteImage = ms.ToArray();
|
||||
|
||||
var SigBase64 = Convert.ToBase64String(byteImage); // Get Base64
|
||||
|
||||
return Ok(SigBase64);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,8 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Text.Json;
|
||||
using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
|
|
@ -18,15 +19,15 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[Route("api/[controller]")]
|
||||
public class UserPermissionAPIController : ControllerBase
|
||||
{
|
||||
private ServiceProviderDal _serviceProviderDal;
|
||||
private AdminDal _adminDal;
|
||||
|
||||
private readonly ILogger<UserPermissionAPIController> _logger;
|
||||
|
||||
public UserPermissionAPIController(ILogger<UserPermissionAPIController> logger, ServiceProviderDal serviceProviderDal)
|
||||
public UserPermissionAPIController(ILogger<UserPermissionAPIController> logger, AdminDal adminDal)
|
||||
{
|
||||
_logger = logger;
|
||||
|
||||
_serviceProviderDal = serviceProviderDal;
|
||||
_adminDal = adminDal;
|
||||
}
|
||||
|
||||
//1. create a permission to be assigned to users to access a context
|
||||
|
|
@ -69,7 +70,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
Console.WriteLine($"GetPermissionsForContextByContextId called with contextId: {contextId}");
|
||||
Dictionary<Guid, int> permissionsDictionary = new Dictionary<Guid, int>();
|
||||
var permissions = await _serviceProviderDal.GetPermissionsForContextByContextIdAsync(contextId);
|
||||
var permissions = await _adminDal.GetPermissionsForContextByContextIdAsync(contextId);
|
||||
return Ok(permissions);
|
||||
}
|
||||
}
|
||||
|
|
@ -88,7 +89,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
var response = await _serviceProviderDal.AssignPermissionToUserForContextAsync(assignPermissionModel.UserProductMapping, assignPermissionModel.PermissionsType);
|
||||
var response = await _adminDal.AssignPermissionToUserForContextAsync(assignPermissionModel.UserProductMapping, assignPermissionModel.PermissionsType);
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
|
|
@ -123,7 +124,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
else
|
||||
{
|
||||
PermissionsType permissionType = new PermissionsType(contextId, name);
|
||||
var response = await _serviceProviderDal.CreatePermissionsTypeAsync(permissionType);
|
||||
var response = await _adminDal.CreatePermissionsTypeAsync(permissionType);
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ using AyCode.Interfaces.Messages;
|
|||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Database.DataLayers.Auctions;
|
||||
using TIAMWebApp.Server.Services;
|
||||
using TIAM.Database.DataLayers.ServiceProviders;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ builder.Services.AddRazorPages();
|
|||
builder.Services.AddScoped<UserDal>();
|
||||
builder.Services.AddScoped<AdminDal>();
|
||||
builder.Services.AddScoped<AuctionDal>();
|
||||
builder.Services.AddScoped<ServiceProviderDal>();
|
||||
//builder.Services.AddScoped<ServiceProviderDal>();
|
||||
builder.Services.AddScoped<TransferDestinationDal>();
|
||||
|
||||
builder.Services.AddSwaggerGen(swagger =>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.11" />
|
||||
<PackageReference Include="QRCoderNetCore" Version="1.0.0" />
|
||||
<PackageReference Include="SendGrid" Version="9.28.1" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Interfaces
|
||||
{
|
||||
|
|
@ -48,5 +49,8 @@ namespace TIAMWebApp.Shared.Application.Interfaces
|
|||
//24. (IServiceProviderDataService) Remove Assigned Users from Product
|
||||
public Task RemoveUserProductMappingsByContextIdAsync(Guid productId);
|
||||
|
||||
//25. (IServiceProviderDataService) Get QRCode by ProductId
|
||||
public Task<string> GetQRCodeByProductIdAsync(Guid productId);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,13 +8,19 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
{
|
||||
public class APIUrls
|
||||
{
|
||||
public const string UserTest = "api/UserAPI/test1";
|
||||
public const string GetUserByEmail = "api/UserAPI/GetUserByEmail";
|
||||
public const string GetUserById = "api/UserAPI/GetUserById";
|
||||
public const string GetUsers = "api/UserAPI/GetUsers";
|
||||
public const string AuthenticateUser = "api/UserAPI/AuthenticateUser";
|
||||
public const string CreateUser = "api/UserAPI/CreateUser";
|
||||
public const string RefreshToken = "/api/UserAPI/RefreshToken";
|
||||
public const string BaseUrl = "api";
|
||||
public const string BaseUrlWithSlash = BaseUrl + "/";
|
||||
public const string BaseUrlWithSlashAndVersion = BaseUrlWithSlash + "v1/";
|
||||
|
||||
public const string UserAPI = BaseUrlWithSlash+"UserAPI";
|
||||
public const string UserTest = UserAPI + "/test1";
|
||||
public const string GetUserByEmail = UserAPI + "/GetUserByEmail";
|
||||
public const string GetUserById = UserAPI + "/GetUserById";
|
||||
public const string GetUsers = UserAPI + "/GetUsers";
|
||||
public const string AuthenticateUser = UserAPI + "/AuthenticateUser";
|
||||
public const string CreateUser = UserAPI + "/CreateUser";
|
||||
public const string RefreshToken = UserAPI + "/RefreshToken";
|
||||
|
||||
|
||||
public const string WeatherForecast = "api/WeatherForecastAPI";
|
||||
|
||||
|
|
@ -26,6 +32,9 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string CreateTransferDestination = "api/TransferDataAPI/CreateTransferDestination";
|
||||
|
||||
public const string GetServiceProvidersByOwnerId = "api/ServiceProviderAPI/GetServiceProvidersByOwnerId";
|
||||
public const string GetQRCodeByProductId = "api/ServiceProviderAPI/GetQRCodeByProductId";
|
||||
public const string AddProductRouteName = "AddProduct";
|
||||
public const string AddProductRouteUrl = "api/ServiceProviderAPI/"+AddProductRouteName;
|
||||
|
||||
//AssingedUsers
|
||||
public const string CreateAssignedUser = "api/ServiceProviderAPI/CreateAssignedUser";
|
||||
|
|
|
|||
|
|
@ -13,6 +13,9 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
|||
{
|
||||
public class TransferDestinationWizardModel
|
||||
{
|
||||
[DataType(DataType.Text)]
|
||||
[Display(Name = ResourceKeys.TransferDestinationId, ResourceType = typeof(TIAMResources))]
|
||||
public string Id { get; set; }
|
||||
|
||||
//[Required(ErrorMessage = "The Username value should be specified.")]
|
||||
[Required(ErrorMessage = "The Destination name should be specified.")]
|
||||
|
|
@ -30,6 +33,11 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
|||
[Display(Name = ResourceKeys.DestinationAddress, ResourceType = typeof(TIAMResources))]
|
||||
public string AddressString { get; set; }
|
||||
|
||||
[Required(ErrorMessage = "The price should be specified.")]
|
||||
[DataType("Price")]
|
||||
[Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
|
||||
public double? Price { get; set; }
|
||||
|
||||
//[DataType("Latitude")]
|
||||
//[Display(Name = "Destination latitude")]
|
||||
//public double Latitude { get; set; }
|
||||
|
|
@ -39,11 +47,17 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
|||
|
||||
|
||||
public TransferDestinationWizardModel() { }
|
||||
public TransferDestinationWizardModel(double latitude, double longitude, string address) : this(Guid.NewGuid(), latitude, longitude, address) { }
|
||||
public TransferDestinationWizardModel(Guid id, double latitude, double longitude, string address) { }
|
||||
public TransferDestinationWizardModel(Guid id, string name, double latitude, double longitude, string address) { }
|
||||
public TransferDestinationWizardModel(Guid id, string name, string description, double latitude, double longitude, string address)
|
||||
|
||||
public TransferDestinationWizardModel(string name, string description, string address) :this(Guid.NewGuid(), name, description, address)
|
||||
{ }
|
||||
public TransferDestinationWizardModel(Guid id, string name, string description, string address)
|
||||
{
|
||||
|
||||
Id = id.ToString();
|
||||
Name = name;
|
||||
Description = description;
|
||||
AddressString = address;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
|||
|
||||
[DataType("Price")]
|
||||
[Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
|
||||
public int? Price { get; set;}
|
||||
public double? Price { get; set;}
|
||||
|
||||
[DataType("Driver")]
|
||||
[Display(Name = ResourceKeys.Driver, ResourceType = typeof(TIAMResources))]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using AyCode.Interfaces.StorageHandlers;
|
||||
using Microsoft.JSInterop;
|
||||
using SkiaSharp;
|
||||
using System.Net.Http.Json;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Entities.Products;
|
||||
|
|
@ -111,6 +112,22 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public async Task<string> GetQRCodeByProductIdAsync(Guid productId)
|
||||
{
|
||||
|
||||
|
||||
var url = APIUrls.GetQRCodeByProductId;
|
||||
var response = await http.PostAsJsonAsync(url, productId);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var result = await response.Content.ReadAsStringAsync();
|
||||
logToBrowserConsole.LogToBC("SKBitmap width: " + result);
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ using TIAMWebApp.Shared.Application.Models.ClientSide;
|
|||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||
using TIAMWebApp.Shared.Application.Utility;
|
||||
|
||||
namespace TIAMWebApp.Client.Services
|
||||
namespace TIAMWebApp.Shared.Application.Services
|
||||
{
|
||||
public class TransferDataService : ITransferDataService
|
||||
{
|
||||
|
|
@ -19,6 +19,8 @@
|
|||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.JSInterop" Version="8.0.0" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.7" />
|
||||
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@
|
|||
|
||||
//wizard
|
||||
public const string TransferDestinationTitle = "TransferDestinationTitle";
|
||||
public const string TransferDestinationId = "TransferDestinationId";
|
||||
|
||||
public const string DestinationName = "DestinationName";
|
||||
public const string DestinationInfo = "DestinationInfo";
|
||||
public const string DestinationAddress = "DestinationAddress";
|
||||
|
|
|
|||
Loading…
Reference in New Issue