using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Vina.Search.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class SyncController : Controller
    {
        private readonly IMediator _mediator;

        public SyncController(IMediator mediator)
        {
            _mediator = mediator;
        }

        #region sync

        [HttpPost("SyncTransactionByListId")]
        public async Task<ActionResult> SyncTransactionByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Finances.Transactions.SyncTransactionCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncBillByListId")]
        public async Task<ActionResult> SyncBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Bills.Bills.SyncBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncBatchByListId")]
        public async Task<ActionResult> SyncBatchByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Batches.SyncBatchCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncInboundBillByListId")]
        public async Task<ActionResult> SyncInboundBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Bills.InboundBills.SyncInboundBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncInventoryBillByListId")]
        public async Task<ActionResult> SyncInventoryBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Bills.InventoryBills.SyncInventoryBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncOutboundBillByListId")]
        public async Task<ActionResult> SyncOutboundBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Bills.OutboundBills.SyncOutboundBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncInvoiceByListId")]
        public async Task<ActionResult> SyncInvoiceByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Invoices.SyncInvoiceCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductByListId")]
        public async Task<ActionResult> SyncProductByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Products.SyncProductCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductGroupByListId")]
        public async Task<ActionResult> SyncProductGroupByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Categories.SyncProductGroupCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncCategoryByListId")]
        public async Task<ActionResult> SyncCategoryByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Categories.SyncCategoryCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncPromotionByListId")]
        public async Task<ActionResult> SyncPromotionByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Promotions.SyncPromotionCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncPromotionProductByListId")]
        public async Task<ActionResult> SyncPromotionProductByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Promotions.SyncPromotionProductCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncUserDistrictByListId")]
        public async Task<ActionResult> SyncUserDistrictByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Categories.SyncUserDistrictCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductTypeByListId")]
        public async Task<ActionResult> SyncProductTypeByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Categories.SyncProductTypeCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductBillByListId")]
        public async Task<ActionResult> SyncProductBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Products.ProductBills.SyncProductBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductInventoryByListId")]
        public async Task<ActionResult> SyncProductInventoryByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Products.SyncProductInventoryCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductInvoiceByListId")]
        public async Task<ActionResult> SyncProductInvoiceByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.ProductInvoices.SyncProductInvoiceCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncOrderByListId")]
        public async Task<ActionResult> SyncOrderByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Orders.SyncOrderCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductOrderByListId")]
        public async Task<ActionResult> SyncProductOrderByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.ProductOrders.SyncProductOrderCommand(list, new List<long>()));
            return Json(rs);
        }

        [HttpPost("SyncProductOrderByListOrderId")]
        public async Task<ActionResult> SyncProductOrderByListOrderId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.ProductOrders.SyncProductOrderCommand(new List<long>(), list));
            return Json(rs);
        }

        [HttpPost("SyncRetailBillByListId")]
        public async Task<ActionResult> SyncRetailBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Bills.RetailBills.SyncRetailBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncBranchByListId")]
        public async Task<ActionResult> SyncBranchByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Branches.SyncBranchCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncUnitByListId")]
        public async Task<ActionResult> SyncUnitByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Units.SyncUnitCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncProductUnitByListId")]
        public async Task<ActionResult> SyncProductUnitByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Units.SyncProductUnitCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncCustomerByListId")]
        public async Task<ActionResult> SyncCustomerByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Customers.SyncCustomerCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncDebtByListId")]
        public async Task<ActionResult> SyncDebtByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Generals.SyncDebtCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncGeneralLedgerByListId")]
        public async Task<ActionResult> SyncGeneralLedgerByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Generals.SyncGeneralLedgerCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncAccountByListId")]
        public async Task<ActionResult> SyncAccountByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Accounts.SyncAccountCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncBaseConfigurationByListId")]
        public async Task<ActionResult> SyncBaseConfigurationByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Configurations.SyncBaseConfigurationCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncContractDiscountLevelByListId")]
        public async Task<ActionResult> SyncContractDiscountLevelByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Configurations.SyncContractDiscountLevelCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncDiscountBranchDetailConfigByListId")]
        public async Task<ActionResult> SyncDiscountBranchDetailConfigByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Configurations.SyncDiscountBranchDetailConfigCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncWholesalePriceListByListId")]
        public async Task<ActionResult> SyncWholesalePriceListByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.Inventories.Configurations.SyncWholesalePriceListCommand(list));
            return Json(rs);
        }

        #endregion sync

        #region Fc Business

        [HttpPost("SyncRetailStatisticByListId")]
        public async Task<ActionResult> SyncRetailStatisticByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.RetailStatistics.SyncRetailStatisticCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncInboundStatisticByListId")]
        public async Task<ActionResult> SyncInboundStatisticByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.InboundStatistics.SyncInboundStatisticCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcProductInboundByListId")]
        public async Task<ActionResult> SyncFcProductInboundByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.ProductInbounds.SyncFcProductInboundCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcProductOutboundByListId")]
        public async Task<ActionResult> SyncFcProductOutboundByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.ProductOutbounds.SyncFcProductOutboundCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncOutboundStatisticByListId")]
        public async Task<ActionResult> SyncOutboundStatisticByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.OutboundStatistics.SyncOutboundStatisticCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcCustomerByListId")]
        public async Task<ActionResult> SyncFcCustomerByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcCustomers.SyncFcCustomerCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcInboundBillByListId")]
        public async Task<ActionResult> SyncFcInboundBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Bills.SyncFcInboundBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcOutboundBillByListId")]
        public async Task<ActionResult> SyncFcOutboundBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Bills.SyncFcOutboundBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcReceiptBillByListId")]
        public async Task<ActionResult> SyncFcReceiptBillByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Bills.SyncFcReceiptBillCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcProductStorageByListId")]
        public async Task<ActionResult> SyncFcProductStorageByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Products.SyncFcProductStorageCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcUnitExchangeByListId")]
        public async Task<ActionResult> SyncFcUnitExchangeByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.UnitExchanges.SyncFcUnitExchangeCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcProductShipmentByListId")]
        public async Task<ActionResult> SyncFcProductShipmentByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Products.ProductShipments.SyncFcProductShipmentCommand(list));
            return Json(rs);
        }

        [HttpPost("SyncFcProductSummaryByListId")]
        public async Task<ActionResult> SyncFcProductSummaryByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Products.ProductSummaries.SyncFcProductSummaryCommand(list));
            return Json(rs);
        }

        #endregion Fc Business

        #region dav

        [HttpPost("SyncProductStorageDavByListId")]
        public async Task<ActionResult> SyncProductStorageDavByListId([FromBody] List<long> list)
        {
            var rs = await _mediator.Send(new Bp.Sync.BackEnd.Application.Commands.FcBusinesses.Products.ProductSummaries.SyncProductStorageDavCommand(list));
            return Json(rs);
        }

        #endregion dav
    }
}