mirror of
				https://github.com/D4M13N-D3V/art_platform.git
				synced 2025-10-31 17:45:39 +00:00 
			
		
		
		
	added admin api controllers
This commit is contained in:
		
							parent
							
								
									21ff5e4b77
								
							
						
					
					
						commit
						c264397edf
					
				| @ -1,13 +1,17 @@ | |||||||
|  | using ArtPlatform.API.Extensions; | ||||||
| using ArtPlatform.Database; | using ArtPlatform.Database; | ||||||
|  | using ArtPlatform.Database.Entities; | ||||||
|  | using ArtPlatform.Database.Enums; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Microsoft.EntityFrameworkCore; | ||||||
| 
 | 
 | ||||||
| namespace ArtPlatform.API.Controllers; | namespace ArtPlatform.API.Controllers; | ||||||
| 
 | 
 | ||||||
| [ApiController] | [ApiController] | ||||||
| [Authorize("admin")] | [Authorize("admin")] | ||||||
| [Route("api/admin/[controller]")]
 | [Route("api/admin/[controller]")]
 | ||||||
| public class AdminOrdersController | public class AdminOrdersController:ControllerBase | ||||||
| { | { | ||||||
|     private readonly ApplicationDbContext _dbContext; |     private readonly ApplicationDbContext _dbContext; | ||||||
| 
 | 
 | ||||||
| @ -17,44 +21,74 @@ public class AdminOrdersController | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     public Task<IActionResult> GetOrders(string search="", int offset = 0, int pageSize = 10) |     public async Task<IActionResult> GetOrders(string search="", int offset = 0, int pageSize = 10) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var orders = _dbContext.SellerServiceOrders.Include(x=>x.Seller).ThenInclude(x=>x.User).Include(x=>x.Buyer) | ||||||
|  |             .Where(x=>x.Seller.User.DisplayName.Contains(search)  | ||||||
|  |                       || x.Seller.User.Email.Contains(search)  | ||||||
|  |                       || x.Buyer.DisplayName.Contains(search)  | ||||||
|  |                       || x.Buyer.Email.Contains(search)) | ||||||
|  |             .Skip(offset).Take(pageSize).ToList(); | ||||||
|  |         return Ok(orders); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("Count")] |     [HttpGet("Count")] | ||||||
|     public Task<IActionResult> GetOrdersCount(string search="") |     public async Task<IActionResult> GetOrdersCount(string search="") | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var result = _dbContext.SellerServiceOrders.Include(x=>x.Seller).ThenInclude(x=>x.User).Include(x=>x.Buyer) | ||||||
|  |             .Where(x=>x.Seller.User.DisplayName.Contains(search)  | ||||||
|  |                       || x.Seller.User.Email.Contains(search)  | ||||||
|  |                       || x.Buyer.DisplayName.Contains(search)  | ||||||
|  |                       || x.Buyer.Email.Contains(search)) | ||||||
|  |             .Count(); | ||||||
|  |         return Ok(result); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("{orderId:int}")] |     [HttpGet("{orderId:int}")] | ||||||
|     public Task<IActionResult> GetOrder(int orderId) |     public async Task<IActionResult> GetOrder(int orderId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var order = await _dbContext.SellerServiceOrders.Include(x=>x.Seller).ThenInclude(x=>x.User).Include(x=>x.Buyer) | ||||||
|  |             .FirstOrDefaultAsync(x=>x.Id==orderId); | ||||||
|  | 
 | ||||||
|  |         if (order == null) | ||||||
|  |             return NotFound("Order not found."); | ||||||
|  |          | ||||||
|  |         return Ok(order); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPost("{orderId:int}")] |     [HttpPost("{orderId:int}")] | ||||||
|     public Task<IActionResult> SendMessage(int orderId, [FromBody]string message) |     public async Task<IActionResult> SendMessage(int orderId, [FromBody]string message) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var order = await _dbContext.SellerServiceOrders.Include(x=>x.Seller).ThenInclude(x=>x.User).Include(x=>x.Buyer) | ||||||
|  |             .FirstOrDefaultAsync(x=>x.Id==orderId); | ||||||
|  | 
 | ||||||
|  |         if (order == null) | ||||||
|  |             return NotFound("Order not found."); | ||||||
|  |          | ||||||
|  |         order.Messages.Add(new SellerServiceOrderMessage() | ||||||
|  |         { | ||||||
|  |             Message = message, | ||||||
|  |             SenderId = User.GetUserId(), | ||||||
|  |             SentAt = DateTime.UtcNow | ||||||
|  |         }); | ||||||
|  |         _dbContext.SellerServiceOrders.Update(order); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(order); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{orderId:int}/Suspend")] |  | ||||||
|     public Task<IActionResult> SuspendOrder(int orderId) |  | ||||||
|     { |  | ||||||
|         throw new NotImplementedException(); |  | ||||||
|     } |  | ||||||
|      |  | ||||||
|     [HttpPut("{orderId:int}/Unsuspend")] |  | ||||||
|     public Task<IActionResult> UnsuspendOrder(int orderId) |  | ||||||
|     { |  | ||||||
|         throw new NotImplementedException(); |  | ||||||
|     } |  | ||||||
|      |      | ||||||
|     [HttpPut("{orderId:int}/Terminate")] |     [HttpPut("{orderId:int}/Terminate")] | ||||||
|     public Task<IActionResult> TerminateOrder(int orderId) |     public async Task<IActionResult> TerminateOrder(int orderId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var order = await _dbContext.SellerServiceOrders.Include(x=>x.Seller).ThenInclude(x=>x.User).Include(x=>x.Buyer) | ||||||
|  |             .FirstOrDefaultAsync(x=>x.Id==orderId); | ||||||
|  | 
 | ||||||
|  |         if (order == null) | ||||||
|  |             return NotFound("Order not found."); | ||||||
|  |          | ||||||
|  |         order.Status = EnumOrderStatus.Cancelled; | ||||||
|  |         _dbContext.SellerServiceOrders.Update(order); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(order); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -27,7 +27,6 @@ public class AdminSellerRequestsController : Controller | |||||||
|     /// <returns>A list of seller profile requests</returns> |     /// <returns>A list of seller profile requests</returns> | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Authorize("read:seller-profile-request")] |     [Authorize("read:seller-profile-request")] | ||||||
|     [Route("SellerRequests")] |  | ||||||
|     public async Task<IActionResult> GetSellerRequests(int offset = 0, int pageSize = 10) |     public async Task<IActionResult> GetSellerRequests(int offset = 0, int pageSize = 10) | ||||||
|     { |     { | ||||||
|         var requests = _dbContext.SellerProfileRequests.Skip(offset).Take(pageSize).ToList(); |         var requests = _dbContext.SellerProfileRequests.Skip(offset).Take(pageSize).ToList(); | ||||||
| @ -41,7 +40,7 @@ public class AdminSellerRequestsController : Controller | |||||||
|     /// <returns>The number of requests.</returns> |     /// <returns>The number of requests.</returns> | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     [Authorize("read:seller-profile-request")] |     [Authorize("read:seller-profile-request")] | ||||||
|     [Route("SellerRequests/Count")] |     [Route("Count")] | ||||||
|     public async Task<IActionResult> GetSellerRequestsCount() |     public async Task<IActionResult> GetSellerRequestsCount() | ||||||
|     { |     { | ||||||
|         var result = _dbContext.SellerProfileRequests.Count(); |         var result = _dbContext.SellerProfileRequests.Count(); | ||||||
| @ -55,7 +54,7 @@ public class AdminSellerRequestsController : Controller | |||||||
|     /// <returns>The new seller profile.</returns> |     /// <returns>The new seller profile.</returns> | ||||||
|     [HttpPut] |     [HttpPut] | ||||||
|     [Authorize("write:seller-profile-request")] |     [Authorize("write:seller-profile-request")] | ||||||
|     [Route("SellerRequests/{userId}")] |     [Route("{userId}")] | ||||||
|     public async Task<IActionResult> AcceptSellerRequest(string userId) |     public async Task<IActionResult> AcceptSellerRequest(string userId) | ||||||
|     { |     { | ||||||
|         var request = await _dbContext.SellerProfileRequests.FirstOrDefaultAsync(request=>request.UserId==userId); |         var request = await _dbContext.SellerProfileRequests.FirstOrDefaultAsync(request=>request.UserId==userId); | ||||||
|  | |||||||
| @ -1,13 +1,16 @@ | |||||||
|  | using ArtPlatform.API.Extensions; | ||||||
| using ArtPlatform.Database; | using ArtPlatform.Database; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
|  | using Microsoft.AspNetCore.Http.HttpResults; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Microsoft.EntityFrameworkCore; | ||||||
| 
 | 
 | ||||||
| namespace ArtPlatform.API.Controllers; | namespace ArtPlatform.API.Controllers; | ||||||
| 
 | 
 | ||||||
| [ApiController] | [ApiController] | ||||||
| [Authorize("admin")] | [Authorize("admin")] | ||||||
| [Route("api/admin/[controller]")]
 | [Route("api/admin/[controller]")]
 | ||||||
| public class AdminSellersController | public class AdminSellersController:ControllerBase | ||||||
| { | { | ||||||
|     private readonly ApplicationDbContext _dbContext; |     private readonly ApplicationDbContext _dbContext; | ||||||
| 
 | 
 | ||||||
| @ -17,50 +20,122 @@ public class AdminSellersController | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     public Task<IActionResult> GetSellers(string search="", int offset = 0, int pageSize = 10) |     public async Task<IActionResult> GetSellers(string search="", int offset = 0, int pageSize = 10) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var sellers = await _dbContext.UserSellerProfiles.Include(x=>x.User) | ||||||
|  |             .Where(x=>x.User.DisplayName.Contains(search) || x.User.Email.Contains(search)) | ||||||
|  |             .Skip(offset).Take(pageSize).ToListAsync(); | ||||||
|  |         return Ok(sellers); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("Count")] |     [HttpGet("Count")] | ||||||
|     public Task<IActionResult> GetSellersCount(string search="") |     public async Task<IActionResult> GetSellersCount(string search="") | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var result = await _dbContext.UserSellerProfiles.Include(x=>x.User) | ||||||
|  |             .Where(x=>x.User.DisplayName.Contains(search) || x.User.Email.Contains(search)) | ||||||
|  |             .CountAsync(); | ||||||
|  |         return Ok(result); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("{sellerId:int}")] |     [HttpGet("{sellerId:int}")] | ||||||
|     public Task<IActionResult> GetSeller(int sellerId) |     public async Task<IActionResult> GetSeller(int sellerId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var seller = await _dbContext.UserSellerProfiles.Include(x=>x.User) | ||||||
|  |             .FirstOrDefaultAsync(x=>x.Id==sellerId); | ||||||
|  | 
 | ||||||
|  |         if (seller == null) | ||||||
|  |             return NotFound("Seller not found."); | ||||||
|  |          | ||||||
|  |         return Ok(seller); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("{sellerId:int}/Orders")] |     [HttpGet("{sellerId:int}/Orders")] | ||||||
|     public Task<IActionResult> GetSellerOrders(int sellerId) |     public async Task<IActionResult> GetSellerOrders(int sellerId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var seller = _dbContext.UserSellerProfiles.Include(x=>x.User) | ||||||
|  |             .FirstOrDefault(x=>x.Id==sellerId); | ||||||
|  |          | ||||||
|  |         if (seller == null) | ||||||
|  |             return NotFound("Seller not found."); | ||||||
|  |          | ||||||
|  |         var orders = await _dbContext.SellerServiceOrders.Where(x=>x.SellerId==sellerId).ToListAsync(); | ||||||
|  |         return Ok(orders); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{sellerId:int}/Suspend")] |     [HttpPut("{sellerId:int}/Suspend")] | ||||||
|     public Task<IActionResult> SuspendSeller(int sellerId) |     public async Task<IActionResult> SuspendSeller(int sellerId, [FromQuery]string reason, [FromQuery]int days) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var seller = _dbContext.UserSellerProfiles.FirstOrDefault(x=>x.Id==sellerId); | ||||||
|  |          | ||||||
|  |         if (seller == null) | ||||||
|  |             return NotFound("Seller not found."); | ||||||
|  | 
 | ||||||
|  |         if (seller.Suspended) | ||||||
|  |             return BadRequest("Seller is already suspended."); | ||||||
|  |          | ||||||
|  |         seller.Suspended = true; | ||||||
|  |         seller.SuspendedDate = DateTime.UtcNow; | ||||||
|  |         seller.UnsuspendDate = DateTime.UtcNow.AddDays(days); | ||||||
|  |         seller.SuspendedReason = reason; | ||||||
|  |         seller.SuspendAdminId = User.GetUserId(); | ||||||
|  |         _dbContext.UserSellerProfiles.Update(seller); | ||||||
|  |          | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{sellerId:int}/Unsuspend")] |     [HttpPut("{sellerId:int}/Unsuspend")] | ||||||
|     public Task<IActionResult> UnsuspendSeller(int sellerId) |     public async Task<IActionResult> UnsuspendSeller(int sellerId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var seller = _dbContext.UserSellerProfiles.FirstOrDefault(x=>x.Id==sellerId); | ||||||
|  |          | ||||||
|  |         if (seller == null) | ||||||
|  |             return NotFound("Seller not found."); | ||||||
|  | 
 | ||||||
|  |         if (!seller.Suspended) | ||||||
|  |             return BadRequest("Seller is not suspended."); | ||||||
|  |          | ||||||
|  |         seller.Suspended = false; | ||||||
|  |         seller.SuspendedDate = null; | ||||||
|  |         seller.UnsuspendDate = null; | ||||||
|  |         seller.SuspendedReason = null; | ||||||
|  |         seller.SuspendAdminId = null; | ||||||
|  |         _dbContext.UserSellerProfiles.Update(seller); | ||||||
|  |          | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{sellerId:int}/Terminate")] |     [HttpPut("{sellerId:int}/Terminate")] | ||||||
|     public Task<IActionResult> TerminateSeller(int sellerId) |     public async Task<IActionResult> TerminateSeller(int sellerId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var seller = _dbContext.UserSellerProfiles.FirstOrDefault(x=>x.Id==sellerId); | ||||||
|  |          | ||||||
|  |         if (seller == null) | ||||||
|  |             return NotFound("Seller not found."); | ||||||
|  | 
 | ||||||
|  |         if (!seller.Suspended) | ||||||
|  |             return BadRequest("Seller is not suspended."); | ||||||
|  | 
 | ||||||
|  |         _dbContext.UserSellerProfiles.Remove(seller); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{sellerId:int}/SetBiography")] |     [HttpPut("{sellerId:int}/SetBiography")] | ||||||
|     public Task<IActionResult> SetBiography(string userId, [FromBody]string biography) |     public async Task<IActionResult> SetBiography(int sellerId, [FromBody]string biography) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var seller = _dbContext.UserSellerProfiles.FirstOrDefault(x=>x.Id==sellerId); | ||||||
|  |          | ||||||
|  |         if (seller == null) | ||||||
|  |             return NotFound("Seller not found."); | ||||||
|  | 
 | ||||||
|  |         if (!seller.Suspended) | ||||||
|  |             return BadRequest("Seller is not suspended."); | ||||||
|  | 
 | ||||||
|  |         seller.Biography = biography; | ||||||
|  |         _dbContext.UserSellerProfiles.Update(seller); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @ -1,13 +1,15 @@ | |||||||
|  | using ArtPlatform.API.Extensions; | ||||||
| using ArtPlatform.Database; | using ArtPlatform.Database; | ||||||
| using Microsoft.AspNetCore.Authorization; | using Microsoft.AspNetCore.Authorization; | ||||||
| using Microsoft.AspNetCore.Mvc; | using Microsoft.AspNetCore.Mvc; | ||||||
|  | using Microsoft.EntityFrameworkCore; | ||||||
| 
 | 
 | ||||||
| namespace ArtPlatform.API.Controllers; | namespace ArtPlatform.API.Controllers; | ||||||
| 
 | 
 | ||||||
| [ApiController] | [ApiController] | ||||||
| [Authorize("admin")] | [Authorize("admin")] | ||||||
| [Route("api/admin/[controller]")]
 | [Route("api/admin/[controller]")]
 | ||||||
| public class AdminUsersController | public class AdminUsersController:ControllerBase | ||||||
| { | { | ||||||
|     private readonly ApplicationDbContext _dbContext; |     private readonly ApplicationDbContext _dbContext; | ||||||
| 
 | 
 | ||||||
| @ -17,57 +19,143 @@ public class AdminUsersController | |||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet] |     [HttpGet] | ||||||
|     public Task<IActionResult> GetUsers(string search="", int offset = 0, int pageSize = 10) |     public async Task<IActionResult> GetUsers(string search="", int offset = 0, int pageSize = 10) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var users = await _dbContext.Users | ||||||
|  |             .Where(x=>x.DisplayName.Contains(search) || x.Email.Contains(search)) | ||||||
|  |             .Skip(offset).Take(pageSize).ToListAsync(); | ||||||
|  |         return Ok(users); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("Count")] |     [HttpGet("Count")] | ||||||
|     public Task<IActionResult> GetUsersCount(string search="") |     public async Task<IActionResult> GetUsersCount(string search="") | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var result = await _dbContext.Users | ||||||
|  |             .Where(x=>x.DisplayName.Contains(search) || x.Email.Contains(search)) | ||||||
|  |             .CountAsync(); | ||||||
|  |         return Ok(result); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("{userId}")] |     [HttpGet("{userId}")] | ||||||
|     public Task<IActionResult> GetUser(string userId) |     public async Task<IActionResult> GetUser(string userId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  | 
 | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         return Ok(user); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpGet("{userId}/Orders")] |     [HttpGet("{userId}/Orders")] | ||||||
|     public Task<IActionResult> GetUserOrders(string userId) |     public async Task<IActionResult> GetUserOrders(string userId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.Include(x=>x.Orders).FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         return Ok(user.Orders); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{userId}/Suspend")] |     [HttpPut("{userId}/Suspend")] | ||||||
|     public Task<IActionResult> SuspendUser(string userId) |     public async Task<IActionResult> SuspendUser(string userId, [FromQuery]string reason, [FromQuery]int days) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         user.Suspended = true; | ||||||
|  |         user.SuspendedDate = DateTime.UtcNow; | ||||||
|  |         user.SuspendedReason = reason; | ||||||
|  |         user.SuspendAdminId = User.GetUserId(); | ||||||
|  |         user.UnsuspendDate = DateTime.UtcNow.AddDays(days); | ||||||
|  |         _dbContext.Users.Update(user); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{userId}/Unsuspend")] |     [HttpPut("{userId}/Unsuspend")] | ||||||
|     public Task<IActionResult> UnsuspendUser(string userId) |     public async Task<IActionResult> UnsuspendUser(string userId) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         user.Suspended = false; | ||||||
|  |         user.SuspendedDate = null; | ||||||
|  |         user.SuspendedReason = null; | ||||||
|  |         user.SuspendAdminId = null; | ||||||
|  |         user.UnsuspendDate = null; | ||||||
|  |         _dbContext.Users.Update(user); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{userId}/Terminate")] |     [HttpPut("{userId}/Ban")] | ||||||
|     public Task<IActionResult> TerminateUser(string userId) |     public async Task<IActionResult> BanUser(string userId, [FromQuery]string reason, [FromQuery]int days) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         user.Banned = true; | ||||||
|  |         user.BannedDate = DateTime.UtcNow; | ||||||
|  |         user.BannedReason = reason; | ||||||
|  |         user.BanAdminId = User.GetUserId(); | ||||||
|  |         user.UnbanDate = DateTime.UtcNow.AddDays(days); | ||||||
|  |         _dbContext.Users.Update(user); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|  |     } | ||||||
|  |      | ||||||
|  |     [HttpPut("{userId}/Unban")] | ||||||
|  |     public async Task<IActionResult> UnbanUser(string userId) | ||||||
|  |     { | ||||||
|  |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         user.Banned = false; | ||||||
|  |         user.BannedDate = null; | ||||||
|  |         user.BannedReason = null; | ||||||
|  |         user.BanAdminId = null; | ||||||
|  |         user.UnbanDate = null; | ||||||
|  |         _dbContext.Users.Update(user); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{userId}/SetDisplayName")] |     [HttpPut("{userId}/SetDisplayName")] | ||||||
|     public Task<IActionResult> SetDisplayName(string userId, [FromBody]string displayName) |     public async Task<IActionResult> SetDisplayName(string userId, [FromBody]string displayName) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         user.DisplayName = displayName; | ||||||
|  |         _dbContext.Users.Update(user); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
|     [HttpPut("{userId}/SetBiography")] |     [HttpPut("{userId}/SetBiography")] | ||||||
|     public Task<IActionResult> SetBiography(string userId, [FromBody]string biography) |     public async Task<IActionResult> SetBiography(string userId, [FromBody]string biography) | ||||||
|     { |     { | ||||||
|         throw new NotImplementedException(); |         var user = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId); | ||||||
|  |          | ||||||
|  |         if (user == null) | ||||||
|  |             return NotFound("User not found."); | ||||||
|  |          | ||||||
|  |         user.Biography = biography; | ||||||
|  |         _dbContext.Users.Update(user); | ||||||
|  |         await _dbContext.SaveChangesAsync(); | ||||||
|  |         return Ok(); | ||||||
|     } |     } | ||||||
|      |      | ||||||
| } | } | ||||||
| @ -35,7 +35,7 @@ public class UserMiddleware | |||||||
|                 dbContext.Users.Add(user); |                 dbContext.Users.Add(user); | ||||||
|                 await dbContext.SaveChangesAsync(); |                 await dbContext.SaveChangesAsync(); | ||||||
|             } |             } | ||||||
|             else |             else  | ||||||
|             {    |             {    | ||||||
|                 user.Email= context.User.Claims.FirstOrDefault(x=>x.Type==ClaimTypes.Email)?.Value ?? string.Empty; |                 user.Email= context.User.Claims.FirstOrDefault(x=>x.Type==ClaimTypes.Email)?.Value ?? string.Empty; | ||||||
|                 dbContext.Users.Update(user); |                 dbContext.Users.Update(user); | ||||||
|  | |||||||
| @ -12,6 +12,18 @@ public record User | |||||||
|     public string Email { get; set; } = null!; |     public string Email { get; set; } = null!; | ||||||
|     public int? UserSellerProfileId { get; set; } |     public int? UserSellerProfileId { get; set; } | ||||||
|      |      | ||||||
|  |     public bool Banned { get; set; } = false; | ||||||
|  |     public DateTime? BannedDate { get; set; } | ||||||
|  |     public DateTime? UnbanDate { get; set; } | ||||||
|  |     public string? BannedReason { get; set; } | ||||||
|  |     public string? BanAdminId { get; set; } | ||||||
|  |      | ||||||
|  |     public bool Suspended { get; set; } = false; | ||||||
|  |     public DateTime? SuspendedDate { get; set; } | ||||||
|  |     public DateTime? UnsuspendDate { get; set; } | ||||||
|  |     public string? SuspendedReason { get; set; } | ||||||
|  |     public string? SuspendAdminId { get; set; } | ||||||
|  |      | ||||||
|     [JsonIgnore] public virtual UserSellerProfile? UserSellerProfile { get; set; } |     [JsonIgnore] public virtual UserSellerProfile? UserSellerProfile { get; set; } | ||||||
|     [JsonIgnore] public virtual ICollection<SellerServiceOrder> Orders { get; set; } |     [JsonIgnore] public virtual ICollection<SellerServiceOrder> Orders { get; set; } | ||||||
| } | } | ||||||
| @ -12,6 +12,13 @@ public record UserSellerProfile | |||||||
|     public bool AgeRestricted { get; set; } |     public bool AgeRestricted { get; set; } | ||||||
|     public string? StripeAccountId { get; set; } |     public string? StripeAccountId { get; set; } | ||||||
|     public bool PrepaymentRequired { get; set; } = false; |     public bool PrepaymentRequired { get; set; } = false; | ||||||
|  |      | ||||||
|  |     public bool Suspended { get; set; } = false; | ||||||
|  |     public DateTime? SuspendedDate { get; set; } | ||||||
|  |     public DateTime? UnsuspendDate { get; set; } | ||||||
|  |     public string? SuspendedReason { get; set; } | ||||||
|  |     public string? SuspendAdminId { get; set; } | ||||||
|  |      | ||||||
|     public virtual User User { get; set; } = null!; |     public virtual User User { get; set; } = null!; | ||||||
| 
 | 
 | ||||||
|     public virtual ICollection<SellerService> SellerServices { get; set; } = new List<SellerService>(); |     public virtual ICollection<SellerService> SellerServices { get; set; } = new List<SellerService>(); | ||||||
|  | |||||||
							
								
								
									
										526
									
								
								src/ArtPlatform.Database/Migrations/20240128214009_lmao.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							
							
						
						
									
										526
									
								
								src/ArtPlatform.Database/Migrations/20240128214009_lmao.Designer.cs
									
									
									
										generated
									
									
									
										Normal file
									
								
							| @ -0,0 +1,526 @@ | |||||||
|  | // <auto-generated /> | ||||||
|  | using System; | ||||||
|  | using System.Collections.Generic; | ||||||
|  | using ArtPlatform.Database; | ||||||
|  | using Microsoft.EntityFrameworkCore; | ||||||
|  | using Microsoft.EntityFrameworkCore.Infrastructure; | ||||||
|  | using Microsoft.EntityFrameworkCore.Migrations; | ||||||
|  | using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||||||
|  | using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; | ||||||
|  | 
 | ||||||
|  | #nullable disable | ||||||
|  | 
 | ||||||
|  | namespace ArtPlatform.Database.Migrations | ||||||
|  | { | ||||||
|  |     [DbContext(typeof(ApplicationDbContext))] | ||||||
|  |     [Migration("20240128214009_lmao")] | ||||||
|  |     partial class lmao | ||||||
|  |     { | ||||||
|  |         /// <inheritdoc /> | ||||||
|  |         protected override void BuildTargetModel(ModelBuilder modelBuilder) | ||||||
|  |         { | ||||||
|  | #pragma warning disable 612, 618 | ||||||
|  |             modelBuilder | ||||||
|  |                 .HasAnnotation("ProductVersion", "8.0.1") | ||||||
|  |                 .HasAnnotation("Relational:MaxIdentifierLength", 63); | ||||||
|  | 
 | ||||||
|  |             NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerProfilePortfolioPiece", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("FileReference") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerProfileId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int?>("SellerServiceId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerProfileId"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerServiceId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerProfilePortfolioPieces"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerProfileRequest", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Accepted") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("AcceptedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime>("RequestDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("UserId") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("UserId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerProfileRequests"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerService", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Description") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Name") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<double>("Price") | ||||||
|  |                         .HasColumnType("double precision"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerProfileId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerProfileId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerServices"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrder", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("BuyerId") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime>("CreatedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("EndDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("PaymentUrl") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<double>("Price") | ||||||
|  |                         .HasColumnType("double precision"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerServiceId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("Status") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("TermsAcceptedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("BuyerId"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerId"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerServiceId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerServiceOrders"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderMessage", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Message") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerServiceOrderId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SenderId") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime>("SentAt") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerServiceOrderId"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SenderId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerServiceOrderMessages"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderMessageAttachment", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("FileReference") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerServiceOrderMessageId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerServiceOrderMessageId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerServiceOrderMessageAttachments"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderReview", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("Rating") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Review") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime>("ReviewDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("ReviewerId") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerServiceId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int>("SellerServiceOrderId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("ReviewerId"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerServiceId"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("SellerServiceOrderId"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("SellerServiceOrderReviews"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.User", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<string>("Id") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("BanAdminId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Banned") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("BannedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("BannedReason") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Biography") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("DisplayName") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Email") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SuspendAdminId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Suspended") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("SuspendedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SuspendedReason") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("UnbanDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("UnsuspendDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<int?>("UserSellerProfileId") | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("Users"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.UserSellerProfile", b => | ||||||
|  |                 { | ||||||
|  |                     b.Property<int>("Id") | ||||||
|  |                         .ValueGeneratedOnAdd() | ||||||
|  |                         .HasColumnType("integer"); | ||||||
|  | 
 | ||||||
|  |                     NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id")); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("AgeRestricted") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("Biography") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("PrepaymentRequired") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<List<string>>("SocialMediaLinks") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text[]"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("StripeAccountId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SuspendAdminId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Suspended") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("SuspendedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SuspendedReason") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("UnsuspendDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("UserId") | ||||||
|  |                         .IsRequired() | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.HasKey("Id"); | ||||||
|  | 
 | ||||||
|  |                     b.HasIndex("UserId") | ||||||
|  |                         .IsUnique(); | ||||||
|  | 
 | ||||||
|  |                     b.ToTable("UserSellerProfiles"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerProfilePortfolioPiece", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.UserSellerProfile", "SellerProfile") | ||||||
|  |                         .WithMany("PortfolioPieces") | ||||||
|  |                         .HasForeignKey("SellerProfileId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.SellerService", "SellerService") | ||||||
|  |                         .WithMany("PortfolioPieces") | ||||||
|  |                         .HasForeignKey("SellerServiceId"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerProfile"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerService"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerProfileRequest", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.User", "User") | ||||||
|  |                         .WithMany() | ||||||
|  |                         .HasForeignKey("UserId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("User"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerService", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.UserSellerProfile", "SellerProfile") | ||||||
|  |                         .WithMany("SellerServices") | ||||||
|  |                         .HasForeignKey("SellerProfileId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerProfile"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrder", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.User", "Buyer") | ||||||
|  |                         .WithMany("Orders") | ||||||
|  |                         .HasForeignKey("BuyerId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.UserSellerProfile", "Seller") | ||||||
|  |                         .WithMany() | ||||||
|  |                         .HasForeignKey("SellerId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.SellerService", "SellerService") | ||||||
|  |                         .WithMany() | ||||||
|  |                         .HasForeignKey("SellerServiceId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("Buyer"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("Seller"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerService"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderMessage", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.SellerServiceOrder", "SellerServiceOrder") | ||||||
|  |                         .WithMany("Messages") | ||||||
|  |                         .HasForeignKey("SellerServiceOrderId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.User", "Sender") | ||||||
|  |                         .WithMany() | ||||||
|  |                         .HasForeignKey("SenderId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerServiceOrder"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("Sender"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderMessageAttachment", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.SellerServiceOrderMessage", "SellerServiceOrderMessage") | ||||||
|  |                         .WithMany("Attachments") | ||||||
|  |                         .HasForeignKey("SellerServiceOrderMessageId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerServiceOrderMessage"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderReview", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.User", "Reviewer") | ||||||
|  |                         .WithMany() | ||||||
|  |                         .HasForeignKey("ReviewerId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.SellerService", "SellerService") | ||||||
|  |                         .WithMany("Reviews") | ||||||
|  |                         .HasForeignKey("SellerServiceId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.SellerServiceOrder", "SellerServiceOrder") | ||||||
|  |                         .WithMany("Reviews") | ||||||
|  |                         .HasForeignKey("SellerServiceOrderId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("Reviewer"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerService"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerServiceOrder"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.UserSellerProfile", b => | ||||||
|  |                 { | ||||||
|  |                     b.HasOne("ArtPlatform.Database.Entities.User", "User") | ||||||
|  |                         .WithOne("UserSellerProfile") | ||||||
|  |                         .HasForeignKey("ArtPlatform.Database.Entities.UserSellerProfile", "UserId") | ||||||
|  |                         .OnDelete(DeleteBehavior.Cascade) | ||||||
|  |                         .IsRequired(); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("User"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerService", b => | ||||||
|  |                 { | ||||||
|  |                     b.Navigation("PortfolioPieces"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("Reviews"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrder", b => | ||||||
|  |                 { | ||||||
|  |                     b.Navigation("Messages"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("Reviews"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.SellerServiceOrderMessage", b => | ||||||
|  |                 { | ||||||
|  |                     b.Navigation("Attachments"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.User", b => | ||||||
|  |                 { | ||||||
|  |                     b.Navigation("Orders"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("UserSellerProfile"); | ||||||
|  |                 }); | ||||||
|  | 
 | ||||||
|  |             modelBuilder.Entity("ArtPlatform.Database.Entities.UserSellerProfile", b => | ||||||
|  |                 { | ||||||
|  |                     b.Navigation("PortfolioPieces"); | ||||||
|  | 
 | ||||||
|  |                     b.Navigation("SellerServices"); | ||||||
|  |                 }); | ||||||
|  | #pragma warning restore 612, 618 | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
							
								
								
									
										172
									
								
								src/ArtPlatform.Database/Migrations/20240128214009_lmao.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								src/ArtPlatform.Database/Migrations/20240128214009_lmao.cs
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,172 @@ | |||||||
|  | using System; | ||||||
|  | using Microsoft.EntityFrameworkCore.Migrations; | ||||||
|  | 
 | ||||||
|  | #nullable disable | ||||||
|  | 
 | ||||||
|  | namespace ArtPlatform.Database.Migrations | ||||||
|  | { | ||||||
|  |     /// <inheritdoc /> | ||||||
|  |     public partial class lmao : Migration | ||||||
|  |     { | ||||||
|  |         /// <inheritdoc /> | ||||||
|  |         protected override void Up(MigrationBuilder migrationBuilder) | ||||||
|  |         { | ||||||
|  |             migrationBuilder.AddColumn<string>( | ||||||
|  |                 name: "SuspendAdminId", | ||||||
|  |                 table: "UserSellerProfiles", | ||||||
|  |                 type: "text", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<bool>( | ||||||
|  |                 name: "Suspended", | ||||||
|  |                 table: "UserSellerProfiles", | ||||||
|  |                 type: "boolean", | ||||||
|  |                 nullable: false, | ||||||
|  |                 defaultValue: false); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<DateTime>( | ||||||
|  |                 name: "SuspendedDate", | ||||||
|  |                 table: "UserSellerProfiles", | ||||||
|  |                 type: "timestamp with time zone", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<string>( | ||||||
|  |                 name: "SuspendedReason", | ||||||
|  |                 table: "UserSellerProfiles", | ||||||
|  |                 type: "text", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<DateTime>( | ||||||
|  |                 name: "UnsuspendDate", | ||||||
|  |                 table: "UserSellerProfiles", | ||||||
|  |                 type: "timestamp with time zone", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<string>( | ||||||
|  |                 name: "BanAdminId", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "text", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<bool>( | ||||||
|  |                 name: "Banned", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "boolean", | ||||||
|  |                 nullable: false, | ||||||
|  |                 defaultValue: false); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<DateTime>( | ||||||
|  |                 name: "BannedDate", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "timestamp with time zone", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<string>( | ||||||
|  |                 name: "BannedReason", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "text", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<string>( | ||||||
|  |                 name: "SuspendAdminId", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "text", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<bool>( | ||||||
|  |                 name: "Suspended", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "boolean", | ||||||
|  |                 nullable: false, | ||||||
|  |                 defaultValue: false); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<DateTime>( | ||||||
|  |                 name: "SuspendedDate", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "timestamp with time zone", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<string>( | ||||||
|  |                 name: "SuspendedReason", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "text", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<DateTime>( | ||||||
|  |                 name: "UnbanDate", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "timestamp with time zone", | ||||||
|  |                 nullable: true); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.AddColumn<DateTime>( | ||||||
|  |                 name: "UnsuspendDate", | ||||||
|  |                 table: "Users", | ||||||
|  |                 type: "timestamp with time zone", | ||||||
|  |                 nullable: true); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         /// <inheritdoc /> | ||||||
|  |         protected override void Down(MigrationBuilder migrationBuilder) | ||||||
|  |         { | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "SuspendAdminId", | ||||||
|  |                 table: "UserSellerProfiles"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "Suspended", | ||||||
|  |                 table: "UserSellerProfiles"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "SuspendedDate", | ||||||
|  |                 table: "UserSellerProfiles"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "SuspendedReason", | ||||||
|  |                 table: "UserSellerProfiles"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "UnsuspendDate", | ||||||
|  |                 table: "UserSellerProfiles"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "BanAdminId", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "Banned", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "BannedDate", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "BannedReason", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "SuspendAdminId", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "Suspended", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "SuspendedDate", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "SuspendedReason", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "UnbanDate", | ||||||
|  |                 table: "Users"); | ||||||
|  | 
 | ||||||
|  |             migrationBuilder.DropColumn( | ||||||
|  |                 name: "UnsuspendDate", | ||||||
|  |                 table: "Users"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
| @ -249,6 +249,18 @@ namespace ArtPlatform.Database.Migrations | |||||||
|                     b.Property<string>("Id") |                     b.Property<string>("Id") | ||||||
|                         .HasColumnType("text"); |                         .HasColumnType("text"); | ||||||
| 
 | 
 | ||||||
|  |                     b.Property<string>("BanAdminId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Banned") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("BannedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("BannedReason") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|                     b.Property<string>("Biography") |                     b.Property<string>("Biography") | ||||||
|                         .IsRequired() |                         .IsRequired() | ||||||
|                         .HasColumnType("text"); |                         .HasColumnType("text"); | ||||||
| @ -261,6 +273,24 @@ namespace ArtPlatform.Database.Migrations | |||||||
|                         .IsRequired() |                         .IsRequired() | ||||||
|                         .HasColumnType("text"); |                         .HasColumnType("text"); | ||||||
| 
 | 
 | ||||||
|  |                     b.Property<string>("SuspendAdminId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Suspended") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("SuspendedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SuspendedReason") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("UnbanDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("UnsuspendDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|                     b.Property<int?>("UserSellerProfileId") |                     b.Property<int?>("UserSellerProfileId") | ||||||
|                         .HasColumnType("integer"); |                         .HasColumnType("integer"); | ||||||
| 
 | 
 | ||||||
| @ -294,6 +324,21 @@ namespace ArtPlatform.Database.Migrations | |||||||
|                     b.Property<string>("StripeAccountId") |                     b.Property<string>("StripeAccountId") | ||||||
|                         .HasColumnType("text"); |                         .HasColumnType("text"); | ||||||
| 
 | 
 | ||||||
|  |                     b.Property<string>("SuspendAdminId") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<bool>("Suspended") | ||||||
|  |                         .HasColumnType("boolean"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("SuspendedDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<string>("SuspendedReason") | ||||||
|  |                         .HasColumnType("text"); | ||||||
|  | 
 | ||||||
|  |                     b.Property<DateTime?>("UnsuspendDate") | ||||||
|  |                         .HasColumnType("timestamp with time zone"); | ||||||
|  | 
 | ||||||
|                     b.Property<string>("UserId") |                     b.Property<string>("UserId") | ||||||
|                         .IsRequired() |                         .IsRequired() | ||||||
|                         .HasColumnType("text"); |                         .HasColumnType("text"); | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user