fixes
This commit is contained in:
parent
7843108576
commit
1f34a556eb
|
|
@ -130,8 +130,10 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
public Task<bool> RemoveProductAsync(Guid productId) => TransactionAsync(ctx => ctx.RemoveProduct(productId));
|
||||
|
||||
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||
public List<UserProductMapping>? GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
|
||||
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
|
||||
public List<UserProductMapping> GetUserProductMappingByUserId(Guid userId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingsByUserId(userId, autoInclude).ToList());
|
||||
public List<UserProductMapping> GetAllUserProductMappings(bool autoInclude = true) => Session(ctx => ctx.UserProductMappings).ToList();
|
||||
|
||||
|
||||
public List<PermissionContextMapping> GetPermissionContextsView(Guid subjectId, Guid contextId)
|
||||
=> Session(x => x.GetPermissionContextsView(subjectId, contextId).ToList());
|
||||
|
|
|
|||
|
|
@ -239,61 +239,46 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[HttpPost]
|
||||
[Route(APIUrls.GetUserProductMappingsByUserIdRouteName)]
|
||||
[SignalR(SignalRTags.GetUserProductMappingsByUserId)]
|
||||
public async Task<string> GetUserProductMappingsByUserId(Guid userId)
|
||||
public Task<string> GetUserProductMappingsByUserId(Guid userId)
|
||||
{
|
||||
_logger.Info($@"GetUserProductMappingsByUserId called with userId: {userId}");
|
||||
|
||||
var userProductMappings = adminDal.GetAllUserProductMappings();
|
||||
|
||||
var myUserProductMappings = userProductMappings.Where(x => x.UserId == userId).OrderBy(x => x.ProductId).ToList();
|
||||
//put serviceprovider id and name into a dictionary
|
||||
|
||||
return myUserProductMappings.ToJson();
|
||||
return Task.FromResult(adminDal.GetUserProductMappingByUserId(userId).OrderBy(x => x.ProductId).ToJson());
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetUserProductMappingByIdRouteName)]
|
||||
[SignalR(SignalRTags.GetUserProductMappingById)]
|
||||
public async Task<string> GetUserProductMappingById(Guid id)
|
||||
public Task<string> GetUserProductMappingById(Guid id)
|
||||
{
|
||||
_logger.Info($@"GetUserProductMappingsByUserId called with userId: {id}");
|
||||
|
||||
var userProductMappings = adminDal.GetAllUserProductMappings();
|
||||
|
||||
var myUserProductMappings = userProductMappings.Where(x => x.Id == id).ToList();
|
||||
//put serviceprovider id and name into a dictionary
|
||||
|
||||
return myUserProductMappings.ToJson();
|
||||
return Task.FromResult(adminDal.GetUserProductMappingById(id).ToJson());
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route(APIUrls.GetAllUserProductMappingsRouteName)]
|
||||
[SignalR(SignalRTags.GetAllUserProductMappings)]
|
||||
public async Task<string> GetAllUserProductMappings()
|
||||
public Task<string> GetAllUserProductMappings()
|
||||
{
|
||||
_logger.Info($@"GetAllUserProductMappings called");
|
||||
|
||||
|
||||
var serviceProviders = adminDal.GetAllUserProductMappings()!.OrderBy(x => x.ProductId);
|
||||
|
||||
//put serviceprovider id and name into a dictionary
|
||||
|
||||
return serviceProviders.ToJson();
|
||||
return Task.FromResult(serviceProviders.ToJson());
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route(APIUrls.GetCarsForUserProductMappingRouteName + "/{userProductMappingId}")]
|
||||
[SignalR(SignalRTags.GetCarsForUserProductMapping)]
|
||||
public async Task<List<Car>> GetCarsForUserProductMapping(Guid userProductMappingId)
|
||||
public Task<List<Car>> GetCarsForUserProductMapping(Guid userProductMappingId)
|
||||
{
|
||||
_logger.Info($@"GetCarsForUserProductMapping called with userProductMappingId: {userProductMappingId}");
|
||||
|
||||
var cars = adminDal.GetCarByUserProductMappingId(userProductMappingId);
|
||||
|
||||
return cars;
|
||||
return Task.FromResult(cars);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
@ -305,7 +290,6 @@ namespace TIAMWebApp.Server.Controllers
|
|||
_logger.Info($@"GetAllCars called ");
|
||||
|
||||
var cars = await adminDal.GetAllCarsAsync();
|
||||
|
||||
return cars;
|
||||
}
|
||||
|
||||
|
|
@ -347,12 +331,10 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[Tags("Finished", "Cars")]
|
||||
[EndpointSummary("Create car")]
|
||||
[SignalR(SignalRTags.CreateCar)]
|
||||
public async Task<Car> CreateCar(Car car)
|
||||
public async Task<Car?> CreateCar(Car car)
|
||||
{
|
||||
var result = await CarDataChanging(car, TrackingState.Add);
|
||||
if (result)
|
||||
return car;
|
||||
else return null;
|
||||
return result ? car : null;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
@ -361,12 +343,10 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[Tags("Finished", "Cars")]
|
||||
[EndpointSummary("Update car")]
|
||||
[SignalR(SignalRTags.UpdateCar)]
|
||||
public async Task<Car> UpdateCar(Car car)
|
||||
public async Task<Car?> UpdateCar(Car car)
|
||||
{
|
||||
var result = await CarDataChanging(car, TrackingState.Update);
|
||||
if (result)
|
||||
return car;
|
||||
else return null;
|
||||
return result ? car : null;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -384,8 +364,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[Tags("In-Progress", "Product")]
|
||||
[SignalR(SignalRTags.AddProduct)]
|
||||
public async Task<IActionResult> AddProduct([FromBody] Product product)
|
||||
{
|
||||
|
||||
{
|
||||
_logger.Info(@"AddProduct called");
|
||||
|
||||
if (product == null)
|
||||
|
|
@ -394,7 +373,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
var result = adminDal.AddProductAsync(product);
|
||||
var result = await adminDal.AddProductAsync(product);
|
||||
return Ok(product);
|
||||
}
|
||||
}
|
||||
|
|
@ -466,19 +445,12 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[HttpGet]
|
||||
[Route(APIUrls.GetAllProductsRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public async Task<string> GetAllProducts()
|
||||
public Task<string> GetAllProducts()
|
||||
{
|
||||
_logger.Info("GetAllProducts called");
|
||||
|
||||
var products = adminDal.GetProductsJson();
|
||||
if (products != null)
|
||||
{
|
||||
return products;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return Task.FromResult(products);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
|
|||
Loading…
Reference in New Issue