...
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Back.Services;
|
||||
using Back.Common;
|
||||
using Back.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
@@ -11,14 +12,14 @@ namespace Back.Controllers
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
public class OrderssController : ControllerBase
|
||||
public class OrdersController : ControllerBase
|
||||
{
|
||||
private readonly ServOrders _servOrders;
|
||||
private readonly ServPromotion _servPromotion;
|
||||
private readonly ServPricing _servPricing;
|
||||
private readonly servUser _servUser;
|
||||
|
||||
public OrderssController(ServOrders servOrders, ServPromotion servPromotion, ServPricing servPricing, servUser servUser)
|
||||
public OrdersController(ServOrders servOrders, ServPromotion servPromotion, ServPricing servPricing, servUser servUser)
|
||||
{
|
||||
_servOrders = servOrders;
|
||||
_servPricing = servPricing;
|
||||
@@ -51,7 +52,27 @@ namespace Back.Controllers
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
int CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
return Ok(await _servOrders.GetOrderItems(CompanyID, OrderID));
|
||||
return Ok(await _servOrders.GetOrderItems( OrderID, CompanyID));
|
||||
}
|
||||
[HttpDelete("CancelOrder/{OrderID}")]
|
||||
public async Task<ActionResult<List<OrderItemDto>>> CancelOrder(int OrderID)
|
||||
{
|
||||
var claim = HttpContext.User.Claims.First(c => c.Type == "UserID");
|
||||
var UserID = claim.Value;
|
||||
var user = await _servUser.GetUserByUserID(Convert.ToInt32(UserID));
|
||||
int CompanyID = user.RolUsers.First().CompanyID;
|
||||
|
||||
var order =await _servOrders.GetOrder(OrderID, CompanyID);
|
||||
if (order==null)
|
||||
return NotFound();
|
||||
|
||||
if (order.Status==StatusOrder.Create)
|
||||
{
|
||||
order.Status = StatusOrder.Cancel;
|
||||
order.ApprovalDate = DateTime.Now.ConvertMiladiToShamsi();
|
||||
return Ok(await _servOrders.UpdateOrder(order));
|
||||
}
|
||||
else return BadRequest(new List<string> { "در این وضعیت امکان ابطال نیست" });
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user