mirror of
https://github.com/D4M13N-D3V/comissions-app-core-api.git
synced 2025-03-13 09:34:55 +00:00
migratoins
This commit is contained in:
parent
39c13a24ce
commit
45b99b35d4
@ -45,9 +45,7 @@ public class ApplicationDbContext:DbContext
|
||||
public DbSet<SellerProfileRequest> SellerProfileRequests { get; set; }= null!;
|
||||
public DbSet<SellerProfilePortfolioPiece> SellerProfilePortfolioPieces { get; set; }= null!;
|
||||
public DbSet<SellerService> SellerServices { get; set; }= null!;
|
||||
public DbSet<SellerServiceOrder> SellerServiceOrders { get; set; }= null!;
|
||||
public DbSet<SellerServiceOrderMessage> SellerServiceOrderMessages { get; set; }= null!;
|
||||
public DbSet<SellerServiceOrderMessageAttachment> SellerServiceOrderMessageAttachments { get; set; }= null!;
|
||||
public DbSet<SellerServiceOrder> SellerServiceOrders { get; set; } = null!;
|
||||
public DbSet<SellerServiceOrderReview> SellerServiceOrderReviews { get; set; }= null!;
|
||||
#endregion
|
||||
}
|
@ -58,26 +58,6 @@ public class AdminOrdersController:ControllerBase
|
||||
return Ok(order);
|
||||
}
|
||||
|
||||
[HttpPost("{orderId:int}")]
|
||||
public async Task<IActionResult> SendMessage(int orderId, [FromBody]string message)
|
||||
{
|
||||
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}/Terminate")]
|
||||
public async Task<IActionResult> TerminateOrder(int orderId)
|
||||
@ -88,7 +68,7 @@ public class AdminOrdersController:ControllerBase
|
||||
if (order == null)
|
||||
return NotFound("Order not found.");
|
||||
|
||||
order.Status = EnumOrderStatus.Cancelled;
|
||||
order.Status = EnumOrderStatus.Declined;
|
||||
_dbContext.SellerServiceOrders.Update(order);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok(order);
|
||||
|
@ -69,10 +69,7 @@ public class OrderController : Controller
|
||||
.FirstOrDefaultAsync(x=>x.Id==int.Parse(orderId));
|
||||
if (order != null && order.Seller.StripeAccountId==connectedAccountId && order.Status == EnumOrderStatus.WaitingForPayment)
|
||||
{
|
||||
if (order.Seller.PrepaymentRequired)
|
||||
order.Status = EnumOrderStatus.InProgress;
|
||||
else
|
||||
order.Status = EnumOrderStatus.Completed;
|
||||
order.Status = EnumOrderStatus.InProgress;
|
||||
}
|
||||
}
|
||||
return Ok();
|
||||
@ -105,7 +102,7 @@ public class OrderController : Controller
|
||||
[HttpPost]
|
||||
[Route("/api/Sellers/{sellerId:int}/Services/{serviceId:int}")]
|
||||
[Authorize("write:orders")]
|
||||
public async Task<IActionResult> CreateOrder(int sellerId, int serviceId)
|
||||
public async Task<IActionResult> CreateOrder(int sellerId, int serviceId, double amount)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles
|
||||
@ -125,7 +122,7 @@ public class OrderController : Controller
|
||||
if(service.Archived)
|
||||
return BadRequest("Service is archived.");
|
||||
|
||||
if(_dbContext.SellerServiceOrders.Where(x=>x.BuyerId==userId && x.Status!=EnumOrderStatus.Completed && x.Status!=EnumOrderStatus.Cancelled).Count()>=3)
|
||||
if(_dbContext.SellerServiceOrders.Where(x=>x.BuyerId==userId && x.Status!=EnumOrderStatus.Completed && x.Status!=EnumOrderStatus.Declined).Count()>=3)
|
||||
return BadRequest("You already have an order in progress. There is a limit of three at a time.");
|
||||
|
||||
var order = new SellerServiceOrder()
|
||||
@ -135,7 +132,7 @@ public class OrderController : Controller
|
||||
SellerServiceId = serviceId,
|
||||
Status = EnumOrderStatus.PendingAcceptance,
|
||||
CreatedDate = DateTime.UtcNow,
|
||||
Price = service.Price,
|
||||
Price = amount,
|
||||
SellerService = service,
|
||||
Buyer = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId),
|
||||
};
|
||||
@ -160,7 +157,7 @@ public class OrderController : Controller
|
||||
return BadRequest("You are not the buyer of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed)
|
||||
return BadRequest("/Order is not in a cancellable state.");
|
||||
order.Status = EnumOrderStatus.Cancelled;
|
||||
order.Status = EnumOrderStatus.Declined;
|
||||
order.EndDate = DateTime.UtcNow;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
@ -168,51 +165,6 @@ public class OrderController : Controller
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/AcceptPrice")]
|
||||
public async Task<IActionResult> AcceptPrice(int orderId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.SellerService)
|
||||
.Include(x=>x.Buyer)
|
||||
.Include(x=>x.Seller)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed)
|
||||
return BadRequest("/Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.DiscussingRequirements)
|
||||
return BadRequest("/Order has not been started yet.");
|
||||
|
||||
if(string.IsNullOrEmpty(order.PaymentUrl)==false)
|
||||
return BadRequest("/Order has price already been agreed on.");
|
||||
|
||||
if(order.Status==EnumOrderStatus.WaitingForPayment)
|
||||
return BadRequest("/Order is waiting for payment.");
|
||||
|
||||
order.TermsAcceptedDate = DateTime.UtcNow;
|
||||
|
||||
if (order.Seller.PrepaymentRequired)
|
||||
{
|
||||
order.Status = EnumOrderStatus.WaitingForPayment;
|
||||
var url = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
|
||||
order.PaymentUrl = url;
|
||||
}
|
||||
else
|
||||
{
|
||||
order.Status = EnumOrderStatus.InProgress;
|
||||
}
|
||||
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
[HttpPut]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Payment")]
|
||||
@ -241,73 +193,6 @@ public class OrderController : Controller
|
||||
return Ok(order.PaymentUrl);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Accept")]
|
||||
public async Task<IActionResult> Accept(int orderId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed)
|
||||
return BadRequest("/Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.InProgress)
|
||||
return BadRequest("/Order has not been started yet.");
|
||||
if(order.Status<EnumOrderStatus.PendingReview)
|
||||
return BadRequest("/Order is in progress and not pending review.");
|
||||
if(order.Status==EnumOrderStatus.WaitingForPayment)
|
||||
return BadRequest("/Order is waiting for payment.");
|
||||
|
||||
if(order.Seller.PrepaymentRequired)
|
||||
order.Status = EnumOrderStatus.Completed;
|
||||
else
|
||||
{
|
||||
order.Status = EnumOrderStatus.WaitingForPayment;
|
||||
var url = _paymentService.ChargeForService(order.Id, order.Seller.StripeAccountId, order.Price);
|
||||
order.PaymentUrl = url;
|
||||
}
|
||||
|
||||
order.TermsAcceptedDate = DateTime.UtcNow;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpDelete]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Deny")]
|
||||
public async Task<IActionResult> Deny(int orderId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed)
|
||||
return BadRequest("/Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.InProgress)
|
||||
return BadRequest("/Order has not been started yet.");
|
||||
if(order.Status<EnumOrderStatus.PendingReview)
|
||||
return BadRequest("/Order is in progress and not pending review.");
|
||||
order.Status = EnumOrderStatus.InProgress;
|
||||
order.TermsAcceptedDate = DateTime.UtcNow;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Review")]
|
||||
@ -341,123 +226,5 @@ public class OrderController : Controller
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("read:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Messages")]
|
||||
public async Task<IActionResult> GetMessages(int orderId, int offset = 0, int pageSize = 10)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Seller)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
var messages = _dbContext.SellerServiceOrderMessages
|
||||
.Include(x=>x.Sender)
|
||||
.Include(x=>x.Attachments)
|
||||
.OrderBy(x=>x.SentAt)
|
||||
.Where(x=>x.SellerServiceOrderId==orderId)
|
||||
.Skip(offset).Take(pageSize).ToList();
|
||||
var result = messages.Select(x=>x.ToModel()).ToList();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Message")]
|
||||
public async Task<IActionResult> Message(int orderId, [FromBody] SellerServiceOrderMessageModel model)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Messages)
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.BuyerId==userId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
|
||||
return BadRequest("/Order is already complete.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
if(order.Status<EnumOrderStatus.Waitlist)
|
||||
return BadRequest("/Order is not accepted.");
|
||||
var message = new SellerServiceOrderMessage()
|
||||
{
|
||||
SellerServiceOrderId = orderId,
|
||||
Message = model.Message,
|
||||
SentAt = DateTime.UtcNow,
|
||||
SenderId = userId,
|
||||
Sender = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId),
|
||||
};
|
||||
var dbMessage = _dbContext.SellerServiceOrderMessages.Add(message).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
|
||||
public async Task<IActionResult> MessageAttachment(int orderId, int messageId,IFormFile file)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Messages)
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
|
||||
return BadRequest("/Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.Waitlist)
|
||||
return BadRequest("/Order is not accepted.");
|
||||
|
||||
var message = _dbContext.SellerServiceOrderMessages.First(x=>x.Id==messageId && x.SellerServiceOrderId==orderId);
|
||||
if(message==null)
|
||||
return BadRequest("Message does not exist or does not belong to this order.");
|
||||
|
||||
var url = await _storageService.UploadImageAsync(file, Guid.NewGuid().ToString());
|
||||
var attachment = new SellerServiceOrderMessageAttachment()
|
||||
{
|
||||
SellerServiceOrderMessageId = message.Id,
|
||||
FileReference = url
|
||||
};
|
||||
_dbContext.SellerServiceOrderMessageAttachments.Add(attachment);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
[HttpGet]
|
||||
[Authorize("read:orders")]
|
||||
[Route("/api/Orders/{orderId:int}/Message/{messageId:int}/Attachment")]
|
||||
public async Task<IActionResult> MessageAttachments(int orderId, int messageId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Messages)
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId);
|
||||
if(order==null)
|
||||
return NotFound("/Order not found.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
|
||||
return BadRequest("/Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.Waitlist)
|
||||
return BadRequest("/Order is not accepted.");
|
||||
|
||||
var message = _dbContext.SellerServiceOrderMessages.Include(x=>x.Attachments)
|
||||
.First(x=>x.Id==messageId && x.SellerServiceOrderId==orderId);
|
||||
if(message==null)
|
||||
return BadRequest("Message does not exist or does not belong to this order.");
|
||||
|
||||
var content = await _storageService.DownloadImageAsync(message.Attachments.First().FileReference);
|
||||
return new FileStreamResult(content, "application/octet-stream");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,111 +68,81 @@ public class SellerOrderController : Controller
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
if(order==null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Cancelled)
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Declined)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.BuyerId!=userId)
|
||||
return BadRequest("You are not the buyer of this order.");
|
||||
if(order.Status!=EnumOrderStatus.Completed && order.Status!= EnumOrderStatus.Cancelled)
|
||||
if(order.Status!=EnumOrderStatus.Completed && order.Status!= EnumOrderStatus.Declined)
|
||||
return BadRequest("Order is not in a cancellable state.");
|
||||
order.Status = EnumOrderStatus.Cancelled;
|
||||
order.Status = EnumOrderStatus.Declined;
|
||||
order.EndDate = DateTime.UtcNow;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[HttpPut]
|
||||
[Authorize("write:seller-orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/Accept")]
|
||||
public async Task<IActionResult> AcceptOrder(int orderId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x => x.UserId == userId);
|
||||
if (seller == null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
if (seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
if(order==null)
|
||||
.Include(x => x.SellerService)
|
||||
.FirstOrDefaultAsync(x => x.Id == orderId && x.Seller.UserId == userId);
|
||||
if (order == null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Cancelled)
|
||||
if (order.Status == EnumOrderStatus.Completed || order.Status == EnumOrderStatus.Declined)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.BuyerId!=userId)
|
||||
if (order.BuyerId != userId)
|
||||
return BadRequest("You are not the buyer of this order.");
|
||||
if(order.Status!=EnumOrderStatus.PendingAcceptance)
|
||||
if (order.Status != EnumOrderStatus.PendingAcceptance)
|
||||
return BadRequest("Order has already been accepted.");
|
||||
order.Status = EnumOrderStatus.Waitlist;
|
||||
if (order.Status == EnumOrderStatus.Declined)
|
||||
return BadRequest("Order has already been declined.");
|
||||
order.Status = EnumOrderStatus.WaitingForPayment;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
[HttpPut]
|
||||
[Authorize("write:seller-orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/Start")]
|
||||
public async Task<IActionResult> StartOrder(int orderId)
|
||||
[Route("/api/SellerOrders/{orderId:int}/Decline")]
|
||||
public async Task<IActionResult> DeclineOrder(int orderId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x => x.UserId == userId);
|
||||
if (seller == null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
if (seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
if(order==null)
|
||||
.Include(x => x.SellerService)
|
||||
.FirstOrDefaultAsync(x => x.Id == orderId && x.Seller.UserId == userId);
|
||||
if (order == null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Cancelled)
|
||||
if (order.Status == EnumOrderStatus.Completed || order.Status == EnumOrderStatus.Declined)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.BuyerId!=userId)
|
||||
if (order.BuyerId != userId)
|
||||
return BadRequest("You are not the buyer of this order.");
|
||||
if(order.Status!=EnumOrderStatus.Waitlist)
|
||||
return BadRequest("Order has already been started.");
|
||||
order.Status = EnumOrderStatus.DiscussingRequirements;
|
||||
if (order.Status != EnumOrderStatus.PendingAcceptance)
|
||||
return BadRequest("Order has already been accepted or declined.");
|
||||
order.Status = EnumOrderStatus.Declined;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpPut]
|
||||
[Authorize("write:seller-orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/AdjustPrice")]
|
||||
public async Task<IActionResult> AdjustPrice(int orderId,[FromQuery]double price)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
if(order==null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Cancelled)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.Status>EnumOrderStatus.DiscussingRequirements)
|
||||
return BadRequest("Order requirements and price have already been confirmed.");
|
||||
if(order.Status<EnumOrderStatus.DiscussingRequirements)
|
||||
return BadRequest("Order has not been started.");
|
||||
order.Price = price;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPut]
|
||||
[Authorize("write:seller-orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/CompleteRevision")]
|
||||
@ -192,155 +162,16 @@ public class SellerOrderController : Controller
|
||||
return NotFound("Order not found.");
|
||||
if(order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Cancelled)
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status== EnumOrderStatus.Declined)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.InProgress)
|
||||
return BadRequest("Order has not been started.");
|
||||
if(order.Status>EnumOrderStatus.InProgress)
|
||||
return BadRequest("Order is pending review already.");
|
||||
order.Status = EnumOrderStatus.PendingReview;
|
||||
order.Status = EnumOrderStatus.Completed;
|
||||
order = _dbContext.SellerServiceOrders.Update(order).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
var result = order.ToModel();
|
||||
return Ok(result);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Authorize("read:orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/Messages")]
|
||||
public async Task<IActionResult> GetMessages(int orderId, int offset = 0, int pageSize = 10)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Seller)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
if(order==null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
var messages = _dbContext.SellerServiceOrderMessages
|
||||
.Include(x=>x.Sender)
|
||||
.Include(x=>x.Attachments)
|
||||
.OrderBy(x=>x.SentAt)
|
||||
.Where(x=>x.SellerServiceOrderId==orderId)
|
||||
.Skip(offset).Take(pageSize).ToList();
|
||||
var result = messages.Select(x=>x.ToModel()).ToList();
|
||||
return Ok(result);
|
||||
}
|
||||
[HttpPost]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/Message")]
|
||||
public async Task<IActionResult> Message(int orderId, [FromBody] SellerServiceOrderMessageModel model)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Messages)
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
if(order==null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
if(order.Status<EnumOrderStatus.Waitlist)
|
||||
return BadRequest("Order is not accepted.");
|
||||
var message = new SellerServiceOrderMessage()
|
||||
{
|
||||
SellerServiceOrderId = orderId,
|
||||
Message = model.Message,
|
||||
SentAt = DateTime.UtcNow,
|
||||
SenderId = userId,
|
||||
Sender = await _dbContext.Users.FirstOrDefaultAsync(x=>x.Id==userId),
|
||||
};
|
||||
var dbMessage = _dbContext.SellerServiceOrderMessages.Add(message).Entity;
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[Authorize("write:orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/Message/{messageId:int}/Attachment")]
|
||||
public async Task<IActionResult> MessageAttachment(int orderId, int messageId,IFormFile file)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Messages)
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId && x.Seller.UserId==userId);
|
||||
if(order==null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.Waitlist)
|
||||
return BadRequest("Order is not accepted.");
|
||||
|
||||
var message = _dbContext.SellerServiceOrderMessages.First(x=>x.Id==messageId && x.SellerServiceOrderId==orderId);
|
||||
if(message==null)
|
||||
return BadRequest("Message does not exist or does not belong to this order.");
|
||||
|
||||
var url = await _storageService.UploadImageAsync(file, Guid.NewGuid().ToString());
|
||||
var attachment = new SellerServiceOrderMessageAttachment()
|
||||
{
|
||||
SellerServiceOrderMessageId = message.Id,
|
||||
FileReference = url
|
||||
};
|
||||
_dbContext.SellerServiceOrderMessageAttachments.Add(attachment);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
return Ok();
|
||||
}
|
||||
[HttpGet]
|
||||
[Authorize("read:orders")]
|
||||
[Route("/api/SellerOrders/{orderId:int}/Message/{messageId:int}/Attachment")]
|
||||
public async Task<IActionResult> MessageAttachments(int orderId, int messageId)
|
||||
{
|
||||
var userId = User.GetUserId();
|
||||
var seller = await _dbContext.UserSellerProfiles.FirstOrDefaultAsync(x=>x.UserId==userId);
|
||||
if(seller==null)
|
||||
return NotFound("User it not a seller.");
|
||||
if(seller.Suspended)
|
||||
return BadRequest("Seller is suspended.");
|
||||
var order = await _dbContext.SellerServiceOrders
|
||||
.Include(x=>x.Messages)
|
||||
.Include(x=>x.Seller)
|
||||
.Include(x=>x.SellerService)
|
||||
.FirstOrDefaultAsync(x=>x.Id==orderId);
|
||||
if(order==null)
|
||||
return NotFound("Order not found.");
|
||||
if(order.BuyerId!=userId && order.Seller.UserId!=userId)
|
||||
return BadRequest("You are not the buyer or seller of this order.");
|
||||
if(order.Status==EnumOrderStatus.Completed || order.Status==EnumOrderStatus.Cancelled)
|
||||
return BadRequest("Order is already complete.");
|
||||
if(order.Status<EnumOrderStatus.Waitlist)
|
||||
return BadRequest("Order is not accepted.");
|
||||
|
||||
var message = _dbContext.SellerServiceOrderMessages.Include(x=>x.Attachments)
|
||||
.First(x=>x.Id==messageId && x.SellerServiceOrderId==orderId);
|
||||
if(message==null)
|
||||
return BadRequest("Message does not exist or does not belong to this order.");
|
||||
var attachment = message.Attachments.FirstOrDefault();
|
||||
if(attachment==null)
|
||||
return BadRequest("Message does not have an attachment.");
|
||||
var content = await _storageService.DownloadImageAsync(message.Attachments.First().FileReference);
|
||||
return new FileStreamResult(content, "application/octet-stream");
|
||||
}
|
||||
}
|
@ -19,6 +19,5 @@ public class SellerServiceOrder
|
||||
public virtual UserSellerProfile Seller { get; set; } = null!;
|
||||
|
||||
public virtual ICollection<SellerServiceOrderReview> Reviews { get; set; } = new List<SellerServiceOrderReview>();
|
||||
public virtual ICollection<SellerServiceOrderMessage> Messages { get; set; } = new List<SellerServiceOrderMessage>();
|
||||
public string? PaymentUrl { get; set; }
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
namespace comissions.app.database.Entities;
|
||||
|
||||
public class SellerServiceOrderMessage
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SellerServiceOrderId { get; set; }
|
||||
public string SenderId { get; set; }
|
||||
public string Message { get; set; } = null!;
|
||||
public DateTime SentAt { get; set; }
|
||||
|
||||
public virtual SellerServiceOrder SellerServiceOrder { get; set; } = null!;
|
||||
public virtual User Sender { get; set; } = null!;
|
||||
public virtual ICollection<SellerServiceOrderMessageAttachment> Attachments { get; set; } = null!;
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace comissions.app.database.Entities;
|
||||
|
||||
public class SellerServiceOrderMessageAttachment
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int SellerServiceOrderMessageId { get; set; }
|
||||
public string FileReference { get; set; } = null!;
|
||||
|
||||
public virtual SellerServiceOrderMessage SellerServiceOrderMessage { get; set; } = null!;
|
||||
}
|
@ -3,11 +3,9 @@ namespace comissions.app.database.Enums;
|
||||
public enum EnumOrderStatus
|
||||
{
|
||||
PendingAcceptance,
|
||||
Waitlist,
|
||||
DiscussingRequirements,
|
||||
InProgress,
|
||||
PendingReview,
|
||||
Completed,
|
||||
Cancelled,
|
||||
Declined,
|
||||
WaitingForPayment
|
||||
}
|
@ -10,10 +10,10 @@ using comissions.app.database;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ArtPlatform.Database.Migrations
|
||||
namespace comissions.app.api.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
[Migration("20240210073843_Initial")]
|
||||
[Migration("20240212032736_Initial")]
|
||||
partial class Initial
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -160,59 +160,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
b.ToTable("SellerServiceOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.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("comissions.app.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("comissions.app.database.Entities.SellerServiceOrderReview", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -424,36 +371,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
b.Navigation("SellerService");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderMessage", b =>
|
||||
{
|
||||
b.HasOne("comissions.app.database.Entities.SellerServiceOrder", "SellerServiceOrder")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("SellerServiceOrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("comissions.app.database.Entities.User", "Sender")
|
||||
.WithMany()
|
||||
.HasForeignKey("SenderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SellerServiceOrder");
|
||||
|
||||
b.Navigation("Sender");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderMessageAttachment", b =>
|
||||
{
|
||||
b.HasOne("comissions.app.database.Entities.SellerServiceOrderMessage", "SellerServiceOrderMessage")
|
||||
.WithMany("Attachments")
|
||||
.HasForeignKey("SellerServiceOrderMessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SellerServiceOrderMessage");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderReview", b =>
|
||||
{
|
||||
b.HasOne("comissions.app.database.Entities.User", "Reviewer")
|
||||
@ -501,16 +418,9 @@ namespace ArtPlatform.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrder", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Reviews");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderMessage", b =>
|
||||
{
|
||||
b.Navigation("Attachments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.User", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
@ -5,7 +5,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ArtPlatform.Database.Migrations
|
||||
namespace comissions.app.api.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Initial : Migration
|
||||
@ -177,34 +177,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SellerServiceOrderMessages",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
SellerServiceOrderId = table.Column<int>(type: "integer", nullable: false),
|
||||
SenderId = table.Column<string>(type: "text", nullable: false),
|
||||
Message = table.Column<string>(type: "text", nullable: false),
|
||||
SentAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SellerServiceOrderMessages", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SellerServiceOrderMessages_SellerServiceOrders_SellerServic~",
|
||||
column: x => x.SellerServiceOrderId,
|
||||
principalTable: "SellerServiceOrders",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_SellerServiceOrderMessages_Users_SenderId",
|
||||
column: x => x.SenderId,
|
||||
principalTable: "Users",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SellerServiceOrderReviews",
|
||||
columns: table => new
|
||||
@ -241,26 +213,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "SellerServiceOrderMessageAttachments",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "integer", nullable: false)
|
||||
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
|
||||
SellerServiceOrderMessageId = table.Column<int>(type: "integer", nullable: false),
|
||||
FileReference = table.Column<string>(type: "text", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_SellerServiceOrderMessageAttachments", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_SellerServiceOrderMessageAttachments_SellerServiceOrderMess~",
|
||||
column: x => x.SellerServiceOrderMessageId,
|
||||
principalTable: "SellerServiceOrderMessages",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellerProfilePortfolioPieces_SellerProfileId",
|
||||
table: "SellerProfilePortfolioPieces",
|
||||
@ -276,21 +228,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
table: "SellerProfileRequests",
|
||||
column: "UserId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellerServiceOrderMessageAttachments_SellerServiceOrderMess~",
|
||||
table: "SellerServiceOrderMessageAttachments",
|
||||
column: "SellerServiceOrderMessageId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellerServiceOrderMessages_SellerServiceOrderId",
|
||||
table: "SellerServiceOrderMessages",
|
||||
column: "SellerServiceOrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellerServiceOrderMessages_SenderId",
|
||||
table: "SellerServiceOrderMessages",
|
||||
column: "SenderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SellerServiceOrderReviews_ReviewerId",
|
||||
table: "SellerServiceOrderReviews",
|
||||
@ -342,15 +279,9 @@ namespace ArtPlatform.Database.Migrations
|
||||
migrationBuilder.DropTable(
|
||||
name: "SellerProfileRequests");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SellerServiceOrderMessageAttachments");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SellerServiceOrderReviews");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SellerServiceOrderMessages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "SellerServiceOrders");
|
||||
|
@ -9,7 +9,7 @@ using comissions.app.database;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ArtPlatform.Database.Migrations
|
||||
namespace comissions.app.api.Migrations
|
||||
{
|
||||
[DbContext(typeof(ApplicationDbContext))]
|
||||
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
||||
@ -157,59 +157,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
b.ToTable("SellerServiceOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.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("comissions.app.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("comissions.app.database.Entities.SellerServiceOrderReview", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
@ -421,36 +368,6 @@ namespace ArtPlatform.Database.Migrations
|
||||
b.Navigation("SellerService");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderMessage", b =>
|
||||
{
|
||||
b.HasOne("comissions.app.database.Entities.SellerServiceOrder", "SellerServiceOrder")
|
||||
.WithMany("Messages")
|
||||
.HasForeignKey("SellerServiceOrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("comissions.app.database.Entities.User", "Sender")
|
||||
.WithMany()
|
||||
.HasForeignKey("SenderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SellerServiceOrder");
|
||||
|
||||
b.Navigation("Sender");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderMessageAttachment", b =>
|
||||
{
|
||||
b.HasOne("comissions.app.database.Entities.SellerServiceOrderMessage", "SellerServiceOrderMessage")
|
||||
.WithMany("Attachments")
|
||||
.HasForeignKey("SellerServiceOrderMessageId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("SellerServiceOrderMessage");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderReview", b =>
|
||||
{
|
||||
b.HasOne("comissions.app.database.Entities.User", "Reviewer")
|
||||
@ -498,16 +415,9 @@ namespace ArtPlatform.Database.Migrations
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrder", b =>
|
||||
{
|
||||
b.Navigation("Messages");
|
||||
|
||||
b.Navigation("Reviews");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.SellerServiceOrderMessage", b =>
|
||||
{
|
||||
b.Navigation("Attachments");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("comissions.app.database.Entities.User", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
@ -1,10 +0,0 @@
|
||||
namespace comissions.app.api.Models.Order;
|
||||
|
||||
public class MessageModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string SenderId { get; set; }
|
||||
public string SenderDisplayName { get; set; }
|
||||
public string Message { get; set; }
|
||||
public int[] Attachments { get; set; }
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using ArtPlatform.Database.Entities;
|
||||
using comissions.app.database.Entities;
|
||||
|
||||
namespace comissions.app.api.Models.Order;
|
||||
|
||||
public static class MessageModelExtensions
|
||||
{
|
||||
|
||||
public static MessageModel ToModel(this SellerServiceOrderMessage sellerProfile)
|
||||
{
|
||||
return new MessageModel()
|
||||
{
|
||||
Id = sellerProfile.Id,
|
||||
SenderId = sellerProfile.SenderId,
|
||||
SenderDisplayName = sellerProfile.Sender.DisplayName,
|
||||
Message = sellerProfile.Message,
|
||||
Attachments = sellerProfile.Attachments.Select(x=>x.Id).ToArray()
|
||||
};
|
||||
}
|
||||
}
|
@ -15,6 +15,11 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.1"/>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.Design" Version="1.1.0" />
|
||||
<PackageReference Include="Stripe.net" Version="43.12.0" />
|
||||
|
@ -13,7 +13,7 @@ using System.Reflection;
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("comissions.app.database.migrator")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7d6ca309de4b95217468fc190ac2465eebaeb070")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+39c13a24ce87e41d0a98d64f71a8873e6e0fb7f2")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("comissions.app.database.migrator")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("comissions.app.database.migrator")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
@ -1 +1 @@
|
||||
4b812d03f91bd01a621a8ea1e43b31ad28a68b439981d547a25d799557852f47
|
||||
17d901dc318786e00800140359f2c1fd4726c24e195f53230c47f722959e350f
|
||||
|
@ -1 +1 @@
|
||||
17074580684655604
|
||||
17076145079561012
|
@ -1 +1 @@
|
||||
17076145079561012
|
||||
17077084151680581
|
Loading…
x
Reference in New Issue
Block a user