some cleanup
This commit is contained in:
parent
7a68be09fa
commit
2cf6995d33
|
|
@ -1,7 +1,6 @@
|
|||
using AyCode.Core.Logger;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using AyCode.Core.Logger;
|
||||
using AyCode.Utils.Helpers;
|
||||
using TIAM.Database.DataLayers.Auctions;
|
||||
using TIAM.Entities.Auctions;
|
||||
|
||||
|
|
@ -15,8 +14,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
private AuctionDal _auctionDal;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
PasswordHasher hasher = new PasswordHasher();
|
||||
|
||||
|
||||
|
||||
private readonly ILogger<UserAPIController> _logger;
|
||||
|
||||
|
|
@ -24,7 +22,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_auctionDal = auctionDal;
|
||||
}
|
||||
|
||||
|
|
@ -41,42 +39,42 @@ namespace TIAMWebApp.Server.Controllers
|
|||
//else
|
||||
//{
|
||||
//AuctionBidModel? bid = JObject.Parse(SerializedAuctionBidModel.GetRawText()).ToObject<AuctionBidModel>();
|
||||
AuctionBid bid = SerializedAuctionBidModel;
|
||||
AuctionBid finalizedBidModel;
|
||||
|
||||
if(bid != null)
|
||||
{
|
||||
//add userModel to users array
|
||||
//Array.Resize(ref users, users.Length + 1);
|
||||
//users[users.Length - 1] = new UserModel(user.Email, user.PhoneNumber, user.Password);
|
||||
|
||||
var userId = bid.OwnerId;
|
||||
var targetProductId = bid.TargetProductId;
|
||||
string? email = bid?.Email;
|
||||
string? phoneNumber = bid?.PhoneNumber;
|
||||
int bidAmount = bid?.BidAmount ?? 0;
|
||||
bool isValid = false;
|
||||
AuctionBid bid = SerializedAuctionBidModel;
|
||||
AuctionBid finalizedBidModel;
|
||||
|
||||
if(userId == Guid.Empty || string.IsNullOrEmpty(email) || targetProductId==0 || bidAmount == 0)
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info($"Bid to be created: {userId}, {targetProductId}, {email}, {phoneNumber}, {bidAmount}, {isValid}");
|
||||
finalizedBidModel = new AuctionBid(userId, targetProductId, email, phoneNumber, bidAmount);
|
||||
await _auctionDal.CreateBidAsync(finalizedBidModel);
|
||||
return Ok(finalizedBidModel.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (bid != null)
|
||||
{
|
||||
//add userModel to users array
|
||||
//Array.Resize(ref users, users.Length + 1);
|
||||
//users[users.Length - 1] = new UserModel(user.Email, user.PhoneNumber, user.Password);
|
||||
|
||||
var userId = bid.OwnerId;
|
||||
var targetProductId = bid.TargetProductId;
|
||||
string? email = bid?.Email;
|
||||
string? phoneNumber = bid?.PhoneNumber;
|
||||
int bidAmount = bid?.BidAmount ?? 0;
|
||||
bool isValid = false;
|
||||
|
||||
if (userId == Guid.Empty || string.IsNullOrEmpty(email) || targetProductId == 0 || bidAmount == 0)
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Info($"Bid to be created: {userId}, {targetProductId}, {email}, {phoneNumber}, {bidAmount}, {isValid}");
|
||||
finalizedBidModel = new AuctionBid(userId, targetProductId, email, phoneNumber, bidAmount);
|
||||
await _auctionDal.CreateBidAsync(finalizedBidModel);
|
||||
return Ok(finalizedBidModel.Id);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetBids")]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using TIAMWebApp.Shared.Application.Models;
|
|||
namespace TIAMWebApp.Server.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("[controller]")]
|
||||
[Route("api/[controller]")]
|
||||
public class PopulationStructureAPIController : ControllerBase
|
||||
{
|
||||
private static readonly PopulationAgeStructureItem[] PopulationData = new PopulationAgeStructureItem[]
|
||||
|
|
|
|||
|
|
@ -1,17 +1,9 @@
|
|||
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.Admins;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
using TIAM.Entities.Permissions;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.ServiceProviders;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
|
@ -135,7 +127,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[EndpointSummary("Create assigned user to product")]
|
||||
public async Task<IActionResult> CreateUserProductMapping(CreateUserProductMappingModel createUserProductMappingModel)
|
||||
{
|
||||
if(createUserProductMappingModel.ContextId == Guid.Empty || createUserProductMappingModel.UserId == Guid.Empty)
|
||||
if (createUserProductMappingModel.ContextId == Guid.Empty || createUserProductMappingModel.UserId == Guid.Empty)
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
|
|
@ -147,7 +139,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
|
||||
var result = await _adminDal.CreateUserProductMappingAsync(userProductMapping);
|
||||
|
||||
|
||||
|
||||
return Ok(result);
|
||||
|
||||
}
|
||||
|
|
@ -215,7 +207,7 @@ namespace TIAMWebApp.Server.Controllers
|
|||
byte[] byteImage = ms.ToArray();
|
||||
|
||||
var SigBase64 = Convert.ToBase64String(byteImage); // Get Base64
|
||||
|
||||
|
||||
return Ok(SigBase64);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,12 @@
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using TIAM.Entities.TransferDestinations;
|
||||
using TIAM.Database.DbContexts;
|
||||
using AyCode.Interfaces.Messages;
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using System.Text;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Database.DataLayers.TransferDestinations;
|
||||
using AyCode.Interfaces.Messages;
|
||||
using System.Text;
|
||||
using TIAM.Database.DataLayers.Admins;
|
||||
using TIAM.Database.DataLayers.Auctions;
|
||||
using TIAM.Database.DataLayers.TransferDestinations;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAMWebApp.Server.Services;
|
||||
//using TIAM.Database.DataLayers.ServiceProviders;
|
||||
|
||||
|
|
@ -93,7 +84,7 @@ builder.Services.ConfigureApplicationCookie(options =>
|
|||
{
|
||||
options.Cookie.HttpOnly = false;
|
||||
options.ExpireTimeSpan = TimeSpan.FromMinutes(5);
|
||||
options.LoginPath = "/Login";
|
||||
options.LoginPath = "/Login";
|
||||
options.SlidingExpiration = true;
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace TIAMWebApp.Shared.Application.Models
|
||||
{
|
||||
public class APIUrls
|
||||
|
|
@ -12,7 +7,13 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string BaseUrlWithSlash = BaseUrl + "/";
|
||||
public const string BaseUrlWithSlashAndVersion = BaseUrlWithSlash + "v1/";
|
||||
|
||||
public const string UserAPI = BaseUrlWithSlash+"UserAPI";
|
||||
public const string UserAPI = BaseUrlWithSlash + "UserAPI";
|
||||
public const string WeatherForecastAPI = BaseUrlWithSlash + "WeatherForecastAPI";
|
||||
public const string PopulationStructureAPI = BaseUrlWithSlash + "PopulationStructureAPI";
|
||||
public const string TransferDataAPI = BaseUrlWithSlash + "TransferDataAPI";
|
||||
public const string ServiceProviderAPI = BaseUrlWithSlash + "ServiceProviderAPI";
|
||||
public const string UserPermissionAPI = BaseUrlWithSlash + "UserPermissionAPI";
|
||||
|
||||
public const string UserTest = UserAPI + "/test1";
|
||||
public const string GetUserByEmail = UserAPI + "/GetUserByEmail";
|
||||
public const string GetUserById = UserAPI + "/GetUserById";
|
||||
|
|
@ -22,19 +23,21 @@ namespace TIAMWebApp.Shared.Application.Models
|
|||
public const string RefreshToken = UserAPI + "/RefreshToken";
|
||||
|
||||
|
||||
public const string WeatherForecast = "api/WeatherForecastAPI";
|
||||
//public const string WeatherForecast = "api/WeatherForecastAPI";
|
||||
public const string WeatherForecast = WeatherForecastAPI;
|
||||
|
||||
public const string PopulationStructure = "PopulationStructureAPI";
|
||||
//public const string PopulationStructure = "PopulationStructureAPI";
|
||||
public const string PopulationStructure = PopulationStructureAPI;
|
||||
|
||||
public const string GetTransferDestinations = "api/TransferDataAPI/GetTransferDestinations";
|
||||
public const string GetTransferDestinationByCoordinates = "api/TransferDataAPI/GetTransferDestinationByCoordinates";
|
||||
public const string GetTransferDestinationByAddress = "api/TransferDataAPI/GetTransferDestinationByAddress";
|
||||
public const string CreateTransferDestination = "api/TransferDataAPI/CreateTransferDestination";
|
||||
public const string GetTransferDestinations = TransferDataAPI+"/GetTransferDestinations";
|
||||
public const string GetTransferDestinationByCoordinates = TransferDataAPI+"/GetTransferDestinationByCoordinates";
|
||||
public const string GetTransferDestinationByAddress = TransferDataAPI+"/GetTransferDestinationByAddress";
|
||||
public const string CreateTransferDestination = 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;
|
||||
public const string GetServiceProvidersByOwnerId = ServiceProviderAPI+"/GetServiceProvidersByOwnerId";
|
||||
public const string GetQRCodeByProductId = ServiceProviderAPI+"/GetQRCodeByProductId";
|
||||
public const string AddProductRouteName = "/AddProduct";
|
||||
public const string AddProductRouteUrl = ServiceProviderAPI + AddProductRouteName;
|
||||
|
||||
//AssingedUsers
|
||||
public const string CreateAssignedUser = "api/ServiceProviderAPI/CreateAssignedUser";
|
||||
|
|
|
|||
Loading…
Reference in New Issue