using APT.BaseData.Domain.Entities;
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.BS;
using APT.Utility;
using APT.WebApi.Models;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;

namespace APT.BS.WebApi.Controllers.Api
{
    [Route("api/BS/BSCheckTypeLevel")]
    public partial class CheckTypeLevelController : AuthorizeApiController<T_BS_CHECK_TYPE_LEVEL>
    {

        /// <summary>
        /// 排序分页查询数据
        /// </summary>
        /// <param name="pageFilter">分页过滤实体</param>
        /// <returns></returns>
        [HttpPost, Route("OrderPagedDescription")]
        public PagedActionResult<T_BS_CHECK_TYPE_LEVEL> OrderPagedDescription([FromBody] KeywordPageFilter pageFilter)
        {
            //return SafeGetPagedData<bool>(() =>
            //{

            //});

            //参考 NotificationTask 
            var result = this.GetOrderPageEntities<T_BS_CHECK_TYPE_LEVEL>(null, pageFilter);
            if (result.TotalCount > 0)
            {
                List<T_BS_CHECK_TYPE_LEVEL> listCHECK_TYPE_LEVEL = result.Data.ToList();
                //foreach (var item in listCHECK_TYPE_LEVEL)
                //{
                //    item.CheckLevelDescription = ((MS.Domain.Enums.HMLevleEnum)item.CheckLevel).GetDescription();
                //}
                result.Data = listCHECK_TYPE_LEVEL;
            }
            return result;
        }


        ///// <summary>
        ///// 排序分页查询数据
        ///// </summary>
        ///// <param name="pageFilter">分页过滤实体</param>
        ///// <returns></returns>
        //[HttpPost, Route("OrderPagedDescription")]
        //public PagedActionResult<T_BS_CHECK_TYPE_LEVEL> OrderPagedDescription([FromBody] KeywordPageFilter pageFilter)
        //{
        //    var result = WitOrderPaged(null, pageFilter);
        //    if (result.TotalCount > 0)
        //    {
        //        List<T_BS_CHECK_TYPE_LEVEL> listCHECK_TYPE_LEVEL = result.Data.ToList();
        //        for (int i = 0; i < listCHECK_TYPE_LEVEL.Count; i++)
        //        {
        //            result.Data.ToList()[i].CheckLevelDescription = ((MS.Domain.Enums.HMLevleEnum)listCHECK_TYPE_LEVEL[i].CheckLevel).GetDescription();
        //        }
        //    }
        //    return result;
        //}


        /// <summary>
        /// 配合检查类型  检查层级
        /// </summary>
        /// <param name="pageFilter">分页过滤实体</param>
        /// <returns></returns>
        [HttpPost, Route("OrderPagedLevel")]
        public PagedActionResult<T_BS_CHECK_TYPE_LEVEL> OrderPagedLevel([FromBody] KeywordPageFilter pageFilter)
        {
            return SafeGetPagedData(delegate (PagedActionResult<T_BS_CHECK_TYPE_LEVEL> result)
            {
                PagedActionResult<T_BS_CHECK_TYPE_LEVEL> orderPageEntities = null;
                if (pageFilter.FilterGroup.Rules.Count == 0)
                {
                    orderPageEntities = new PagedActionResult<T_BS_CHECK_TYPE_LEVEL>();
                }
                else
                {
                    orderPageEntities = GetOrderPageEntities<T_BS_CHECK_TYPE_LEVEL>(null, pageFilter, null);
                }
                result.Data = orderPageEntities.Data;
                result.TotalCount = orderPageEntities.TotalCount;
            });
        }

    }
}
