using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;

namespace Performance.DtoModels
{
    /// <summary>
    /// 登录请求
    /// </summary>
    public class HospitalRequest
    {
        public int ID { get; set; }
        /// <summary>
        /// 医院名称
        /// </summary>
        public string HosName { get; set; }
        /// <summary>
        /// 简称
        /// </summary>
        public string ShortName { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string AreaCode { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string HosLevel { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string HosType { get; set; }
        /// <summary>
        /// 医院状态 1 启用 2 禁用
        /// </summary>
        public Nullable<int> States { get; set; }
        ///// <summary>
        ///// 是否开启年资系数 1 启用 2 禁用
        ///// </summary>
        //public Nullable<int> IsOpenWorkYear { get; set; }
        /// <summary>
        /// 是否开启药占比系数 1 启用 2 禁用
        /// </summary>
        public Nullable<int> IsOpenDrugprop { get; set; }
        ///// <summary>
        ///// 是否开启ICU有效收入系数 1 启用 2 禁用
        ///// </summary>
        //public Nullable<int> IsOpenIncome { get; set; }
        ///// <summary>
        ///// 是否开启规模/效率绩效 1 启用 2 禁用
        ///// </summary>
        //public Nullable<int> IsOpenDirector { get; set; }
        /// <summary>
        /// 是否显示绩效合计 1 显示绩效合计 2 显示管理绩效
        /// </summary>
        public Nullable<int> IsShowManage { get; set; }
        /// <summary>
        /// 是否开启科室CMI占比 1 启用 2 禁用
        /// </summary>
        public Nullable<int> IsOpenCMIPercent { get; set; }

        ///// <summary>
        ///// 是否开启行政后勤二次绩效分配 1 启用 2 禁用
        ///// </summary>
        //public Nullable<int> IsOpenLogisticsSecondAllot { get; set; }
    }

    public class HospitalRequestValidator : AbstractValidator<HospitalRequest>
    {
        public HospitalRequestValidator()
        {
            Action action = () =>
            {
                RuleFor(x => x.HosName).NotNull().NotEmpty().Length(1, 50);
                //RuleFor(x => x.AreaCode).NotNull().NotEmpty().Length(1, 50);
                RuleFor(x => x.HosLevel).NotNull().NotEmpty().Length(1, 50);
                RuleFor(x => x.HosType).NotNull().NotEmpty().Length(1, 50);
                //RuleFor(x => x.IsOpenWorkYear).NotNull().InclusiveBetween(1, 2);
            };

            RuleSet("Insert", () =>
            {
                action();
            });

            RuleSet("Update", () =>
            {
                action();
                RuleFor(x => x.ID).NotNull().GreaterThan(0);
                RuleFor(x => x.States).NotNull().InclusiveBetween(1, 2);
            });

            RuleSet("Delete", () =>
            {
                RuleFor(x => x.ID).NotNull().GreaterThan(0);
            });

            RuleSet("Disable", () =>
            {
                RuleFor(x => x.ID).NotNull().GreaterThan(0);
                RuleFor(x => x.States).NotNull().InclusiveBetween(1, 2);
            });
        }
    }
}
