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

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

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

        #region sync

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

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

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

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

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

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

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

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

        #endregion sync
    }
}