IInventoryApp.cs 1.65 KB
using System;
using System.Collections.Generic;
using Infrastructure;
using WebRepository;

namespace WebApp
{
    /// <summary>
    /// 库存查询接口App
    /// </summary>

    public partial class IInventoryApp : ApiApp
    {

        public IInventoryApp(IUnitWork unitWork, IAuth auth, BaseDBContext context) : base(unitWork, auth, context)
        {

        }

        public Response<List<InventoryModel>> GetCurrentStock(InventoryModel inventoryModel)
        {
            Response<List<InventoryModel>> Response = new Response<List<InventoryModel>>();

            if (!CheckLogin())
            {
                Response.Code = 500;
                Response.Status = false;
                Response.Message = "请先登录!";
                return Response;
            }

            try
            {
                Inventory inventory = new Inventory
                {
                    WarehouseType = inventoryModel.WarehouseType,
                    LocationCode = inventoryModel.LocationCode,
                    ContainerCode = inventoryModel.ContainerCode,
                    MaterialCode = inventoryModel.MaterialCode,
                    Lot = inventoryModel.Lot,
                    Status = inventoryModel.Status,
                    Qty = null,
                };

                Response.Result = _unitWork.Find(EntityToExpression<Inventory>.GetExpressions(inventory)).MapToList<InventoryModel>();
            }
            catch (Exception ex)
            {
                Response.Code = 500;
                Response.Status = false;
                Response.Message = ex.Message;
            }

            return Response;
        }
    }
}