This commit is contained in:
Damien Ostler 2024-01-28 04:12:40 -05:00
parent 65c7a720c4
commit 52bd3cce1d
3 changed files with 22 additions and 16 deletions

View File

@ -19,6 +19,12 @@ public class AdminSellerProfileRequestsController : Controller
_dbContext = dbContext;
}
/// <summary>
/// Gets a list of all of the requests from users to become a seller.
/// </summary>
/// <param name="offset"> The offset to start at.</param>
/// <param name="pageSize"> The amount of records to return.</param>
/// <returns>A list of seller profile requests</returns>
[HttpGet]
[Authorize("read:seller-profile-request")]
[Route("SellerRequests")]
@ -29,6 +35,10 @@ public class AdminSellerProfileRequestsController : Controller
return Ok(result);
}
/// <summary>
/// Gets the amount of requests there are from users to become a seller.
/// </summary>
/// <returns>The number of requests.</returns>
[HttpGet]
[Authorize("read:seller-profile-request")]
[Route("SellerRequests/Count")]
@ -38,6 +48,11 @@ public class AdminSellerProfileRequestsController : Controller
return Ok(result);
}
/// <summary>
/// Accepts a request to become a seller from a user.
/// </summary>
/// <param name="userId">The ID of the user to accept the request for.</param>
/// <returns>The new seller profile.</returns>
[HttpPut]
[Authorize("write:seller-profile-request")]
[Route("SellerRequests/{userId}")]

View File

@ -18,6 +18,7 @@ public class DiscoveryController : Controller
_dbContext = dbContext;
}
[HttpGet]
[Route("Sellers")]
public async Task<IActionResult> GetSellers(string search="",int offset = 0, int pageSize = 10)

View File

@ -53,7 +53,7 @@ public class OrderController : Controller
.FirstOrDefaultAsync(x=>x.Id==int.Parse(orderId));
if (order != null && order.Status == EnumOrderStatus.WaitingForPayment)
{
order.PaymentUrl = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
order.PaymentUrl = null;
}
}
else if (stripeEvent.Type == Events.CheckoutSessionCompleted)
@ -213,23 +213,13 @@ public class OrderController : Controller
return BadRequest("Order is already complete.");
if(order.Status!=EnumOrderStatus.WaitingForPayment)
return BadRequest("Order does not need to be paid for.");
order.TermsAcceptedDate = DateTime.UtcNow;
if (order.Seller.PrepaymentRequired)
{
order.Status = EnumOrderStatus.InProgress;
var url = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
order.PaymentUrl = url;
}
else
{
order.Status = EnumOrderStatus.Completed;
var url = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
order.PaymentUrl = url;
}
if(order.PaymentUrl!=null)
return BadRequest("Order has already has a payment url.");
var url = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
order.PaymentUrl = url;
order = _dbContext.SellerServiceOrders.Update(order).Entity;
await _dbContext.SaveChangesAsync();
var result = order.ToModel();
return Ok(result);
return Ok(order.PaymentUrl);
}
[HttpPut]