public PublicMortgage CastDB(PublicMortgageViewModel model)
        {
            PublicMortgage bc = new PublicMortgage();

            Com.HSJF.Infrastructure.ExtendTools.ObjectExtend.CopyTo(model, bc);
            return(bc);
        }
        public PublicMortgageViewModel CastModel(PublicMortgage model)
        {
            BaseAuditDAL            bad       = new BaseAuditDAL();
            var                     baseaudit = bad.Get(model.ID);
            var                     maxaudit  = bad.GetMaxAudit(model.ID);
            var                     dicdal    = new DictionaryDAL();
            PublicMortgageViewModel bcvm      = new PublicMortgageViewModel();

            Com.HSJF.Infrastructure.ExtendTools.ObjectExtend.CopyTo(model, bcvm);

            UserDAL ud    = new UserDAL();
            var     contr = ud.FindById(model.ContractPerson);

            if (contr != null)
            {
                bcvm.ContractPersonText = contr.Result.DisplayName;
            }
            var baseauditRelaType = "";
            var maxauditRelaType  = "";

            if (baseaudit != null)
            {
                if (!string.IsNullOrEmpty(baseaudit.OpeningSite))
                {
                    var baseauditRela = baseaudit.RelationPersonAudits.FirstOrDefault(t => t.IdentificationNumber == baseaudit.OpeningSite);
                    if (baseauditRela != null)
                    {
                        baseauditRelaType = baseauditRela.Name + "(" + dicdal.GetText(baseauditRela.RelationType) + ")";
                    }
                }
            }
            if (maxaudit != null)
            {
                if (!string.IsNullOrEmpty(maxaudit.OpeningSite))
                {
                    var maxauditRela = maxaudit.RelationPersonAudits.FirstOrDefault(t => t.IdentificationNumber == maxaudit.OpeningSite);
                    if (maxauditRela != null)
                    {
                        maxauditRelaType = maxauditRela.Name + "(" + dicdal.GetText(maxauditRela.RelationType) + ")";
                    }
                }
            }
            bcvm.OpeningSiteText = baseaudit == null ? maxaudit == null ? null : maxauditRelaType : baseauditRelaType;
            bcvm.CaseNum         = baseaudit == null ? maxaudit == null ? "" : maxaudit.NewCaseNum : baseaudit.NewCaseNum;
            bcvm.CaseStatusText  = baseaudit == null ? maxaudit == null ? "" : Com.HSJF.HEAS.Web.Helper.CaseStatusHelper.GetStatsText(maxaudit.CaseStatus) : Com.HSJF.HEAS.Web.Helper.CaseStatusHelper.GetStatsText(baseaudit.CaseStatus);
            bcvm.IsCurrent       = baseaudit == null ? false : (baseaudit.CaseStatus == Com.HSJF.Framework.DAL.CaseStatus.PublicMortgage) ? true : false;
            bcvm.AuditAmount     = baseaudit == null ? maxaudit == null ? 0 : maxaudit.AuditAmount : baseaudit.AuditAmount;
            return(bcvm);
        }