auction bleh, interface restructuring
This commit is contained in:
parent
c8e7eed670
commit
33f41e4003
|
|
@ -5,8 +5,8 @@ using System.ComponentModel.DataAnnotations.Schema;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Entities.Users;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Auctions
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Permissions;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using TIAM.Core;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Products;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Entities.Locations;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Entities.Interfaces;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
|
||||
namespace TIAM.Entities.Users;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TIAMSharedUI.Pages.Components
|
||||
{
|
||||
public partial class AuctionComponent
|
||||
{
|
||||
[Parameter]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
|
||||
<h2>Hello @UserId.ToString()</h2>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-12, col-sm-6">
|
||||
|
|
@ -11,6 +10,5 @@
|
|||
</div>
|
||||
|
||||
@code {
|
||||
[Parameter]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,23 @@ namespace TIAMSharedUI.Pages.Components
|
|||
{
|
||||
[Parameter]
|
||||
public int AuctionItemId { get; set; }
|
||||
[Parameter]
|
||||
public int TargetAuctionId { get; set; }
|
||||
[Parameter]
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
public string IsLoading { get; set; } = "";
|
||||
|
||||
public int currentStep = 0;
|
||||
|
||||
public AuctionBidModel auctionBidModel = new();
|
||||
|
||||
public string status = "";
|
||||
public Guid sUserId = Guid.Empty;
|
||||
|
||||
public void NextStep()
|
||||
{
|
||||
currentStep++;
|
||||
currentStep++;
|
||||
}
|
||||
public void PreviousStep()
|
||||
{
|
||||
|
|
@ -31,7 +39,12 @@ namespace TIAMSharedUI.Pages.Components
|
|||
{
|
||||
IsLoading = "loaded!";
|
||||
base.OnInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
public void AddStatus(string message)
|
||||
{
|
||||
status += message + "\n";
|
||||
}
|
||||
|
||||
public void SubmitBid()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -7,14 +7,27 @@
|
|||
<img src=@url class="card-img-top" style="margin: 0 auto;" alt="...">
|
||||
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body mb-3">
|
||||
<h5 class="card-title"><h3>Item @AuctionItemId.ToString()</h3></h5>
|
||||
<p class="card-text">@IsLoading</p>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item">An item</li>
|
||||
<li class="list-group-item">A second item</li>
|
||||
<li class="list-group-item">A third item</li>
|
||||
@{
|
||||
if(auctionBidModel.Email != null)
|
||||
{
|
||||
<li class="list-group-item">@auctionBidModel.Email</li>
|
||||
}
|
||||
if(auctionBidModel.OwnerId != Guid.Empty)
|
||||
{
|
||||
<li class="list-group-item">@auctionBidModel.OwnerId</li>
|
||||
}
|
||||
if(auctionBidModel.PhoneNumber != null)
|
||||
{
|
||||
<li class="list-group-item">@auctionBidModel.PhoneNumber</li>
|
||||
}
|
||||
}
|
||||
<li class="list-group-item">Minimum: 25 000</li>
|
||||
<li class="list-group-item">20 000 Ft</li>
|
||||
</ul>
|
||||
<div class="card-body">
|
||||
<form class="p-3 mt-3">
|
||||
|
|
@ -22,7 +35,7 @@
|
|||
@switch (currentStep)
|
||||
{
|
||||
case 0:
|
||||
<AuctionStep0 onNext="NextStep" />
|
||||
<AuctionStep0 @bind-AuctionBidModel="auctionBidModel" TargetProductId=@TargetAuctionId onNext="NextStep" />
|
||||
;
|
||||
break;
|
||||
case 1:
|
||||
|
|
|
|||
|
|
@ -1,29 +1,41 @@
|
|||
@using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
@using TIAMWebApp.Shared.Application.Interfaces;
|
||||
@using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
@using TIAMWebApp.Shared.Application.Models;
|
||||
@inject ISessionService sessionService;
|
||||
|
||||
|
||||
|
||||
<EditForm Model="@auctionBidModel" OnValidSubmit="GoToNextStep">
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
<h3>Step 1</h3>
|
||||
<div class="form-field d-flex align-items-center">
|
||||
|
||||
|
||||
<DxButton Click="GoToNextStep">
|
||||
|
||||
|
||||
<button class="btn btn-primary mt-3" type="submit">
|
||||
<span class="@spinnerClass"></span>
|
||||
Licitálok!
|
||||
</DxButton>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</button>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</EditForm>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
|
||||
[Parameter]
|
||||
public AuctionBidModel auctionBidModel { get; set; }
|
||||
[Parameter]
|
||||
public int TargetProductId { get; set; }
|
||||
[Parameter]
|
||||
public EventCallback<string> onNext { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<AuctionBidModel> auctionBidModelChanged { get; set; }
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
|
||||
private string spinnerClass = "";
|
||||
|
||||
|
|
@ -31,7 +43,11 @@
|
|||
{
|
||||
spinnerClass = "spinner-border spinner-border-sm";
|
||||
await Task.Delay(500);
|
||||
spinnerClass = "";
|
||||
auctionBidModel.Id = Guid.NewGuid();
|
||||
auctionBidModel.OwnerId = sessionService.User.UserId;
|
||||
auctionBidModel.TargetProductId = TargetProductId;
|
||||
spinnerClass = "";
|
||||
await auctionBidModelChanged.InvokeAsync(auctionBidModel);
|
||||
await onNext.InvokeAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
@using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
@using TIAMWebApp.Shared.Application.Models;
|
||||
@using TIAMWebApp.Shared.Application.Interfaces;
|
||||
@inject ISessionService sessionService;
|
||||
|
||||
<EditForm Model="@auctionBidModel" OnValidSubmit="GoToNextStep">
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
|
|
@ -7,7 +10,7 @@
|
|||
<div class="form-field d-flex align-items-center">
|
||||
|
||||
|
||||
<DxMaskedInput @bind-Value="@auctionBidModel.Email"
|
||||
<DxMaskedInput @bind-Value="@Email"
|
||||
Id="Email"
|
||||
CssClass="cw-320"
|
||||
Mask="@EmailMask"
|
||||
|
|
@ -32,10 +35,9 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public AuctionBidModel auctionBidModel { get; set; }
|
||||
public AuctionBidModel? auctionBidModel { get; set; }
|
||||
|
||||
//[Parameter]
|
||||
//public string Email { get; set; }
|
||||
public string Email { get; set; } = "test@test.com";
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> onNext { get; set; }
|
||||
|
|
@ -56,10 +58,16 @@
|
|||
{
|
||||
spinnerClass = "spinner-border spinner-border-sm";
|
||||
await Task.Delay(500);
|
||||
spinnerClass = "";
|
||||
auctionBidModel.Id = Guid.NewGuid();
|
||||
auctionBidModel.Email = Email;
|
||||
spinnerClass = "";
|
||||
await auctionBidModelChanged.InvokeAsync(auctionBidModel);
|
||||
await onNext.InvokeAsync();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Email = sessionService.User.Email;
|
||||
await base.OnInitializedAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +1,7 @@
|
|||
@using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
@using TIAMWebApp.Shared.Application.Models;
|
||||
<h3>Step 2: Phone Number</h3>
|
||||
<EditForm Model="@regModel" OnValidSubmit="GoToNextStep">
|
||||
|
||||
|
||||
<EditForm Model="@auctionBidModel" OnValidSubmit="GoToNextStep">
|
||||
|
||||
<DataAnnotationsValidator />
|
||||
|
||||
|
|
@ -10,7 +9,7 @@
|
|||
<div class="form-field d-flex align-items-center">
|
||||
|
||||
|
||||
<DxMaskedInput @bind-Value="regModel.PhoneNumber"
|
||||
<DxMaskedInput @bind-Value="auctionBidModel.PhoneNumber"
|
||||
Id="PhoneNumber"
|
||||
Mask="\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*(\d{1,2})"
|
||||
MaskMode="@MaskMode.RegEx">
|
||||
|
|
@ -21,7 +20,7 @@
|
|||
|
||||
|
||||
</div>
|
||||
<ValidationMessage For="@(() => regModel.PhoneNumber)" />
|
||||
<ValidationMessage For="@(() => auctionBidModel.PhoneNumber)" />
|
||||
|
||||
<a class="btn btn-primary mt-3" @onclick="GoToPreviousStep">Previous</a>
|
||||
<button class="btn btn-primary mt-3" type="submit">
|
||||
|
|
@ -35,16 +34,16 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public RegistrationModel regModel { get; set; }
|
||||
public AuctionBidModel? auctionBidModel { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<RegistrationModel> onNext { get; set; }
|
||||
public EventCallback<string> onNext { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<RegistrationModel> onPrev { get; set; }
|
||||
public EventCallback<string> onPrev { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<RegistrationModel> RegModelChanged { get; set; }
|
||||
public EventCallback<AuctionBidModel> auctionBidModelChanged { get; set; }
|
||||
|
||||
char Placeholder = '_';
|
||||
|
||||
|
|
@ -55,7 +54,7 @@
|
|||
spinnerClass = "spinner-border spinner-border-sm";
|
||||
await Task.Delay(500);
|
||||
spinnerClass = "";
|
||||
await RegModelChanged.InvokeAsync(regModel);
|
||||
await auctionBidModelChanged.InvokeAsync(auctionBidModel);
|
||||
await onNext.InvokeAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
@using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
@using System.Globalization;
|
||||
@using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
@using TIAMWebApp.Shared.Application.Models;
|
||||
<h3>Step 3: Password</h3>
|
||||
<EditForm Model="@regModel" OnValidSubmit="SubmitRegistration">
|
||||
<EditForm Model="@auctionBidModel" OnValidSubmit="SubmitRegistration">
|
||||
|
||||
|
||||
|
||||
|
|
@ -10,15 +12,16 @@
|
|||
<div class="form-field d-flex align-items-center">
|
||||
|
||||
|
||||
<DxTextBox @bind-Text="@regModel.Password"
|
||||
Id="Password"
|
||||
Password="true"
|
||||
CssClass="cw-320" />
|
||||
<DxMaskedInput @bind-Value="@auctionBidModel.BidAmount"
|
||||
CssClass="cw-320"
|
||||
Mask="@NumericMask.WholeNumber">
|
||||
<DxNumericMaskProperties Culture="@CultureInfo.GetCultureInfo("en-US")" />
|
||||
</DxMaskedInput>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
<ValidationMessage For="@(() => regModel.Password)" />
|
||||
<ValidationMessage For="@(() => auctionBidModel.BidAmount)" />
|
||||
|
||||
<a class="btn btn-primary mt-3" @onclick="GoToPreviousStep">Previous</a>
|
||||
<button class="btn btn-primary mt-3" type="submit">
|
||||
|
|
@ -31,13 +34,13 @@
|
|||
|
||||
@code {
|
||||
[Parameter]
|
||||
public RegistrationModel regModel { get; set; }
|
||||
public AuctionBidModel auctionBidModel { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<RegistrationModel> RegModelChanged { get; set; }
|
||||
public EventCallback<AuctionBidModel> AuctionBidModelChanged { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<RegistrationModel> onPrev { get; set; }
|
||||
public EventCallback<string> onPrev { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback onSubmit { get; set; }
|
||||
|
|
@ -51,7 +54,7 @@
|
|||
await Task.Delay(500);
|
||||
spinnerClass = "";
|
||||
|
||||
await RegModelChanged.InvokeAsync(regModel);
|
||||
await AuctionBidModelChanged.InvokeAsync(auctionBidModel);
|
||||
await onSubmit.InvokeAsync();
|
||||
}
|
||||
|
||||
|
|
@ -60,5 +63,10 @@
|
|||
|
||||
await onPrev.InvokeAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,11 +41,7 @@
|
|||
Transfer
|
||||
</NavLink>
|
||||
</div>
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="auction">
|
||||
Auction
|
||||
</NavLink>
|
||||
</div>
|
||||
|
||||
<div class="nav-item px-3">
|
||||
<NavLink class="nav-link" href="swagger">
|
||||
API
|
||||
|
|
|
|||
|
|
@ -0,0 +1,168 @@
|
|||
using DevExpress.Office.Crypto;
|
||||
using DevExpress.Xpo.DB;
|
||||
using DevExpress.XtraPrinting;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.Json;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||
using TIAMWebApp.Server.Models;
|
||||
using System.Text;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using AyCode.Utils.Helpers;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAMWebApp.Server.ModelsTIAMWebApp.Shared.Application.Models;
|
||||
using TIAMWebApp.Shared.Application.Utility;
|
||||
using TIAM.Entities.Auctions;
|
||||
|
||||
namespace TIAMWebApp.Server.Controllers
|
||||
{
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
public class EmailAPIController : ControllerBase
|
||||
{
|
||||
private AuctionDal _auctionDal;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IWebHostEnvironment _webHostEnvironment;
|
||||
PasswordHasher hasher = new PasswordHasher();
|
||||
|
||||
|
||||
private readonly ILogger<UserAPIController> _logger;
|
||||
|
||||
public EmailAPIController(ILogger<UserAPIController> logger, IConfiguration configuration, IWebHostEnvironment webHostEnvironment, AuctionDal auctionDal)
|
||||
{
|
||||
_logger = logger;
|
||||
_configuration = configuration;
|
||||
_webHostEnvironment = webHostEnvironment;
|
||||
_auctionDal = auctionDal;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route("SendEmail")]
|
||||
public async Task<IActionResult> SendEmail([FromBody] AuctionBid SerializedAuctionBidModel)
|
||||
{
|
||||
Console.WriteLine("CreateBid called");
|
||||
//if (string.IsNullOrEmpty(SerializedAuctionBidModel.GetRawText()))
|
||||
//{
|
||||
// return BadRequest("SerializedAuctionBidModel is required");
|
||||
//}
|
||||
//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;
|
||||
|
||||
if(userId == Guid.Empty || string.IsNullOrEmpty(email) || targetProductId==0 || bidAmount == 0)
|
||||
{
|
||||
return BadRequest("Invalid request");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"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")]
|
||||
public Task<List<AuctionBid>> GetBids()
|
||||
{
|
||||
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
|
||||
//return users;
|
||||
return _auctionDal.GetBids();
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route("GetBidsByEmail")]
|
||||
public async Task<List<AuctionBid>> GetUserByEmail(string email)
|
||||
{
|
||||
return await _auctionDal.GetBidsByEmail(email);
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpPost]
|
||||
[Route("ValidateBid")]
|
||||
public async Task<IActionResult> ValidateBid([FromBody] AuctionBid SerializedAuctionBidModel)
|
||||
{
|
||||
Console.WriteLine("ValidateBid called");
|
||||
//var validateBid = JObject.Parse(SerializedAuctionBidModel.GetRawText()).ToObject<AuctionBidModel>();
|
||||
|
||||
//check if bid exists
|
||||
AuctionBid? dbBid = null;
|
||||
|
||||
//Console.WriteLine(validateBid?.Id);
|
||||
Console.WriteLine(SerializedAuctionBidModel?.Id);
|
||||
//if (validateBid != null)
|
||||
if (SerializedAuctionBidModel != null)
|
||||
{
|
||||
//dbBid = await _auctionDal.GetBidById(validateBid.Id);
|
||||
dbBid = await _auctionDal.GetBidById(SerializedAuctionBidModel.Id);
|
||||
}
|
||||
|
||||
//check if password is valid
|
||||
//bool isValidUser = await _userManager.CheckPasswordAsync(userModel, authenticateUser.Password);
|
||||
|
||||
//mocking
|
||||
if (dbBid is null)
|
||||
{
|
||||
return Unauthorized("Not found in DB");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//if (dbBid.Email == validateBid?.Email)
|
||||
if (dbBid.Email == SerializedAuctionBidModel?.Email)
|
||||
{
|
||||
Console.WriteLine("Bid is valid");
|
||||
dbBid.IsValid = true;
|
||||
//Update userModel with refreshToken!!
|
||||
await _auctionDal.UpdateBidAsync(dbBid);
|
||||
return Ok(dbBid.IsValid);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
return Unauthorized("Emails not matching");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -12,6 +12,7 @@
|
|||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="7.0.10" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.13" />
|
||||
<PackageReference Include="Microsoft.OpenApi" Version="1.6.11" />
|
||||
<PackageReference Include="SendGrid" Version="9.28.1" />
|
||||
<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" />
|
||||
|
|
|
|||
Loading…
Reference in New Issue