using Com.FirmLib.Bll;
using FWindSoft.DataFramework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Com.FirmLib.UI.BllCommon
{
    /// <summary>
    /// 项目管理
    /// </summary>
    public static class ProjectManager
    {
        /// <summary>
        /// 同步供应商项目[自动检测是否首次]
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="venderId"></param>
        public static void SyncSellerProject(string projectId, string venderId)
        {
            var projects = BllFactory<SellerBll>.Instance.GetProjectItems(venderId);
            if (projects.Any(p => p.Id == projectId))
            {
                return;
            }
            BllFactory<ProjectBll>.Instance.ProjectSync(projectId);
        }
        /// <summary>
        /// 同步维修商项目
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="venderId"></param>
        public static void SyncMaintainerProject(string projectId, string venderId)
        {
            var projects = BllFactory<MaintainerBll>.Instance.GetProjectItems(venderId);
            if (projects.Any(p => p.Id == projectId))
            {
                return;
            }
            BllFactory<ProjectBll>.Instance.ProjectSync(projectId);
        }
        /// <summary>
        /// 同步保险商项目
        /// </summary>
        /// <param name="projectId"></param>
        /// <param name="venderId"></param>
        public static void SyncInsuerProject(string projectId, string venderId)
        {
            var projects = BllFactory<InsuerBll>.Instance.GetProjectItems(venderId);
            if (projects.Any(p => p.Id == projectId))
            {
                return;
            }
            BllFactory<ProjectBll>.Instance.ProjectSync(projectId);

        }
    }
}
