58 lines
2.2 KiB
C#
58 lines
2.2 KiB
C#
using Back.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Shared.DTOs;
|
|
using Shared.DTOs.Serch;
|
|
|
|
namespace Back.Controllers
|
|
{
|
|
|
|
[Route("api/[controller]")]
|
|
[Authorize]
|
|
[ApiController]
|
|
public class OrderssController : 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)
|
|
{
|
|
_servOrders = servOrders;
|
|
_servPricing = servPricing;
|
|
_servPromotion = servPromotion;
|
|
_servUser = servUser;
|
|
|
|
}
|
|
[HttpGet("GetAllPromotion")]
|
|
[AllowAnonymous]
|
|
public async Task<ActionResult<List<PromotionDto>>> GetAllPromotion() =>Ok(await _servPromotion.GetAll());
|
|
|
|
[HttpGet("GetAllPricing")]
|
|
[AllowAnonymous]
|
|
public async Task<ActionResult<List<PricingDto>>> GetAllPricing() => Ok(await _servPricing.GetPricing());
|
|
[HttpPost("GetAllOrder")]
|
|
public async Task<ActionResult<PagingDto< OrderDto>>> GetAllOrder(ItemSerachOrder itemSerach)
|
|
{
|
|
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;
|
|
|
|
return Ok(await _servOrders.GetOrdersByCompanyID(CompanyID,itemSerach));
|
|
}
|
|
[HttpGet("GetOrderDetails/{OrderID}")]
|
|
public async Task<ActionResult<List<OrderItemDto>>> GetOrderDetails(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;
|
|
|
|
return Ok(await _servOrders.GetOrderItems(CompanyID, OrderID));
|
|
}
|
|
}
|
|
}
|