Files
moadiran/Back/Controllers/OrderssController.cs

58 lines
2.1 KiB
C#
Raw Normal View History

2024-07-25 17:18:03 +03:30
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")]
2024-07-26 10:30:07 +03:30
public async Task<ActionResult<PagingDto< OrderDto>>> GetAllOrder(ItemSerachOrder itemSerach)
2024-07-25 17:18:03 +03:30
{
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<OrderDto>>> 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));
}
}
}