public string GetAccountId(Guid Id)
        {
            DropDownService           ddService           = new DropDownService();
            List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();

            EntityHierarchyDTOs = ddService.GetEntityHierarchies(Id);

            var  TopFromHierarchy = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
            int  EntityId         = TopFromHierarchy.EntityId ?? 0;
            Guid ParentId         = TopFromHierarchy.CustomerId ?? Guid.Empty;

            if (EntityId == (int)EMPConstants.Entity.SVB || EntityId == (int)EMPConstants.Entity.MO)
            {
                var custinfo = db.emp_CustomerLoginInformation.Where(x => x.CustomerOfficeId == ParentId).FirstOrDefault();
                if (custinfo != null)
                {
                    if (string.IsNullOrEmpty(custinfo.CLAccountId))
                    {
                        return(custinfo.MasterIdentifier);
                    }
                    else
                    {
                        return(custinfo.CLAccountId);
                    }
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
Beispiel #2
0
        /// <summary>
        /// This Method is used to Get the Main Office Configuration Details
        /// </summary>
        /// <returns></returns>
        public IQueryable <SubSiteFeeDTO> GetSubSiteFeeById(Guid UserId)
        {
            try
            {
                DropDownService ddService = new DropDownService();

                List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();
                EntityHierarchyDTOs = ddService.GetEntityHierarchies(UserId);

                Guid TopParentId       = Guid.Empty;
                Guid FeeSourceParentId = Guid.Empty;

                if (EntityHierarchyDTOs.Count > 0)
                {
                    var TopFromHierarchy = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
                    TopParentId = TopFromHierarchy.CustomerId ?? Guid.Empty;

                    var FeeSource = EntityHierarchyDTOs.Where(o => o.EntityId == o.FeeSourceEntityId).FirstOrDefault();
                    if (FeeSource != null)
                    {
                        FeeSourceParentId = FeeSource.CustomerId ?? Guid.Empty;
                    }
                    else
                    {
                        FeeSourceParentId = TopParentId;
                    }
                }



                db = new DatabaseEntities();
                var DBQuery = (from sfc in db.SubSiteFeeConfigs
                               where (sfc.StatusCode == EMPConstants.Active) && sfc.emp_CustomerInformation_ID == TopParentId
                               select sfc);
                List <SubSiteFeeDTO> lstsbfee = new List <SubSiteFeeDTO>();
                foreach (var qr in DBQuery)
                {
                    SubSiteFeeDTO odto = new SubSiteFeeDTO();
                    odto.Id                    = qr.ID.ToString();
                    odto.refId                 = qr.emp_CustomerInformation_ID.ToString();
                    odto.IsAddOnFeeCharge      = qr.IsAddOnFeeCharge;
                    odto.IsSameforAll          = qr.IsSameforAll;
                    odto.IsSubSiteAddonFee     = qr.IsSubSiteAddonFee;
                    odto.ServiceorTransmission = qr.ServiceorTransmission;
                    odto.SubSiteBankFees       = db.SubSiteBankFeesConfigs.Where(a => a.SubSiteFeeConfig_ID == qr.ID).Select(a => new SubSiteBankFeesDTO
                    {
                        BankMaster_ID   = a.BankMaster_ID.ToString(),
                        BankMaxFees     = a.BankMaxFees,
                        BankMaxFees_MSO = a.BankMaxFees_MSO
                    }).ToList();
                    lstsbfee.Add(odto);
                }
                return(lstsbfee.AsQueryable());
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteFeeService/GetSubSiteFeeById", UserId);
                return(new List <SubSiteFeeDTO>().AsQueryable());
            }
        }
        public bool setDefaultBank(Guid CustomerId, Guid UserId, Guid BankId)
        {
            DropDownService           ddService           = new DropDownService();
            List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();

            EntityHierarchyDTOs = ddService.GetEntityHierarchies(UserId);

            Guid TopParentId = Guid.Empty;

            if (EntityHierarchyDTOs.Count > 0)
            {
                var TopFromHierarchy = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
                TopParentId = TopFromHierarchy.CustomerId ?? Guid.Empty;
            }

            var result = db.SetDefaultBankSP(CustomerId.ToString(), UserId.ToString(), BankId.ToString());
            var res1   = db.OfficeManagementGridSP(CustomerId.ToString(), CustomerId.ToString(), TopParentId == Guid.Empty ? null : TopParentId.ToString());

            return(true);
        }
Beispiel #4
0
        public List <FeeSetupReportDTO> GetNoBankAppSubmissionReport(string strguid)
        {
            try
            {
                db = new DatabaseEntities();
                List <string> lstCustGuid     = strguid.Split(',').ToList();
                List <Guid>   BE_CustomerList = db.BankEnrollments.Where(x => x.IsActive == true && x.StatusCode != EMPConstants.Ready && x.ArchiveStatusCode != EMPConstants.Archive).Select(a => a.CustomerId ?? Guid.Empty).ToList();
                //List<Guid> ES_CustomerList = (from be in db.EnrollmentBankSelections
                //                                  // join ssbc in db.SubSiteBankConfigs on new { x1 = be.BankId, x2 = be.CustomerId } equals new { x1 = ssbc.BankMaster_ID, x2 = ssbc.emp_CustomerInformation_ID }
                //                              where !BE_CustomerList.Contains(be.CustomerId) && be.StatusCode == EMPConstants.Active
                //                              select be.CustomerId).ToList();

                //var data = (from cu in db.emp_CustomerInformation
                //            join cl in db.emp_CustomerLoginInformation on cu.Id equals cl.CustomerOfficeId
                //            where ES_CustomerList.Contains(cu.Id) && cl.CrossLinkUserId != null
                //            select new { cu, cl }).Take(1);
                List <ReportCustomerModel> data = new List <ReportCustomerModel>();
                EnrollmentBankSelectionInfo.EnrollmentBankSelectionService oService = new EnrollmentBankSelectionInfo.EnrollmentBankSelectionService();
                if (db.emp_CustomerInformation.Any(a => lstCustGuid.Contains(a.Id.ToString())))
                {
                    List <string> lstGuids = GetChildData(lstCustGuid);

                    data = (from cu in db.emp_CustomerInformation
                            join cl in db.emp_CustomerLoginInformation on cu.Id equals cl.CustomerOfficeId
                            where !BE_CustomerList.Contains(cu.Id) && lstGuids.Contains(cu.Id.ToString()) && cl.CrossLinkUserId != null //&& ES_CustomerList.Contains(cu.Id)
                            select new ReportCustomerModel {
                        cu = cu, cl = cl
                    }).ToList();
                }
                else
                {
                    data = (from cu in db.emp_CustomerInformation
                            join cl in db.emp_CustomerLoginInformation on cu.Id equals cl.CustomerOfficeId
                            where !BE_CustomerList.Contains(cu.Id) && cl.CrossLinkUserId != null // && ES_CustomerList.Contains(cu.Id)
                            select new ReportCustomerModel {
                        cu = cu, cl = cl
                    }).ToList();
                }

                List <FeeSetupReportDTO> lstmodel   = new List <FeeSetupReportDTO>();
                DropDownService          _ddService = new DropDownService();
                //if (data.Count() > 0)
                {
                    foreach (var itm in data)
                    {
                        List <Guid> ES_BankList = (from be in db.EnrollmentBankSelections
                                                   // join ssbc in db.SubSiteBankConfigs on new { x1 = be.BankId, x2 = be.CustomerId } equals new { x1 = ssbc.BankMaster_ID, x2 = ssbc.emp_CustomerInformation_ID }
                                                   where be.CustomerId == itm.cu.Id && !BE_CustomerList.Contains(be.CustomerId) && be.StatusCode == EMPConstants.Active
                                                   select be.BankId).ToList();

                        if (ES_BankList.Count > 0)
                        {
                            if (itm.cu.EntityId != (int)EMPConstants.Entity.SO && itm.cu.EntityId != (int)EMPConstants.Entity.SOME && itm.cu.EntityId != (int)EMPConstants.Entity.SOME_SS)
                            {
                                List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();
                                EntityHierarchyDTOs = _ddService.GetEntityHierarchies(itm.cu.Id);

                                Guid TopParentId = Guid.Empty;
                                if (EntityHierarchyDTOs.Count > 0)
                                {
                                    var TopFromHierarchy = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
                                    TopParentId = TopFromHierarchy.CustomerId ?? Guid.Empty;

                                    var SubSiteBankConfigs = db.SubSiteBankConfigs.Where(o => o.emp_CustomerInformation_ID == TopParentId && ES_BankList.Contains(o.BankMaster_ID)).Select(o => o.BankMaster_ID).ToList();
                                    if (SubSiteBankConfigs.Count() == 0)
                                    {
                                        continue;
                                    }
                                    //  SubSiteBankConfigs
                                }
                                else
                                {
                                    var SubSiteBankConfigs = db.SubSiteBankConfigs.Where(o => o.emp_CustomerInformation_ID == itm.cu.Id && ES_BankList.Contains(o.BankMaster_ID)).Select(o => o.BankMaster_ID).ToList();
                                    if (SubSiteBankConfigs.Count() == 0)
                                    {
                                        continue;
                                    }
                                }
                            }

                            FeeSetupReportDTO omodel = new FeeSetupReportDTO();
                            omodel.UserID = itm.cl.EMPUserId;

                            if (itm.cu.ParentId != null)
                            {
                                omodel.ParentUserID = db.emp_CustomerLoginInformation.Where(a => a.CustomerOfficeId == itm.cu.ParentId).Select(a => a.CrossLinkUserId).FirstOrDefault();
                            }
                            else
                            {
                                omodel.ParentUserID = "";
                            }
                            omodel.CompanyName  = itm.cu.CompanyName;
                            omodel.Efin         = itm.cu.EFIN.ToString().PadLeft(6, '0');
                            omodel.MasterID     = itm.cl.MasterIdentifier;
                            omodel.AccountOwner = itm.cu.BusinessOwnerFirstName;
                            lstmodel.Add(omodel);
                        }
                    }
                }

                return(lstmodel.OrderBy(a => a.CompanyName).ToList());
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "ReportsService/GetNoBankAppSubmissionReport", Guid.Empty);
                return(new List <FeeSetupReportDTO>());
            }
        }
        public IQueryable <SubSiteBankFeeConfigDTO> SubSiteOfficeBankFee(Guid UserId)
        {
            try
            {
                DropDownService           ddService           = new DropDownService();
                List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();
                EntityHierarchyDTOs = ddService.GetEntityHierarchies(UserId);

                Guid ParentId          = Guid.Empty;
                Guid FeeSourceParentId = Guid.Empty;

                if (EntityHierarchyDTOs.Count > 0)
                {
                    var TopFromHierarchy = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
                    ParentId = TopFromHierarchy.CustomerId ?? Guid.Empty;
                }

                db = new DatabaseEntities();
                List <int> FeeFor = new List <int>();
                FeeFor.Add((int)EMPConstants.FeesFor.SVBFees);
                FeeFor.Add((int)EMPConstants.FeesFor.TransmissionFees);
                List <SubSiteBankFeeConfigDTO> ListDTO = new List <SubSiteBankFeeConfigDTO>();

                if (EntityHierarchyDTOs.Count <= 1)
                {
                    var data = (from fee in db.FeeMasters
                                                                        //join cust in db.CustomerAssociatedFees on fee.Id equals cust.FeeMaster_ID
                                where FeeFor.Contains(fee.FeesFor ?? 0) //&& cust.emp_CustomerInformation_ID == ParentId
                                select new { fee.FeesFor, fee.Amount }).ToList();

                    var dataa = (from s in data
                                 group s by s.FeesFor into g
                                 select new
                    {
                        feesfor = g.Key,
                        Amount = g.Sum(x => x.Amount)
                    }).ToList();



                    foreach (var itm in dataa.ToList())
                    {
                        SubSiteBankFeeConfigDTO SubSiteBankFeeConfig = new SubSiteBankFeeConfigDTO();
                        SubSiteBankFeeConfig.ServiceorTransmitter = itm.feesfor ?? 0;
                        SubSiteBankFeeConfig.AmountDSK            = itm.Amount ?? 0;
                        ListDTO.Add(SubSiteBankFeeConfig);
                    }
                }
                else
                {
                    var data = (from fee in db.FeeMasters
                                join cust in db.CustomerAssociatedFees on fee.Id equals cust.FeeMaster_ID
                                where FeeFor.Contains(fee.FeesFor ?? 0) && cust.emp_CustomerInformation_ID == ParentId
                                select new { fee.FeesFor, cust.Amount }).ToList();

                    var dataa = (from s in data
                                 group s by s.FeesFor into g
                                 select new
                    {
                        feesfor = g.Key,
                        Amount = g.Sum(x => x.Amount)
                    }).ToList();



                    foreach (var itm in dataa.ToList())
                    {
                        SubSiteBankFeeConfigDTO SubSiteBankFeeConfig = new SubSiteBankFeeConfigDTO();
                        SubSiteBankFeeConfig.ServiceorTransmitter = itm.feesfor ?? 0;
                        SubSiteBankFeeConfig.AmountDSK            = itm.Amount;
                        ListDTO.Add(SubSiteBankFeeConfig);
                    }
                }

                return(ListDTO.AsQueryable());
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/SubSiteOfficeBankFee", UserId);
                return(null);
            }
        }
        /// <summary>
        /// This Method is used to Get SubSite Office Configuration Details
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public async Task <SubSiteOfficeConfigDTO> GetSubSiteOfficeConfigById(Guid userid, Guid parentId)
        {
            try
            {
                DropDownService           ddService           = new DropDownService();
                List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();
                EntityHierarchyDTOs = ddService.GetEntityHierarchies(userid);

                Guid ParentId = Guid.Empty;

                if (EntityHierarchyDTOs.Count > 2)
                {
                    var LevelOne = EntityHierarchyDTOs.Where(o => o.Customer_Level == 1).FirstOrDefault();
                    if (LevelOne != null)
                    {
                        ParentId = LevelOne.CustomerId ?? Guid.Empty;
                    }
                    else
                    {
                        ParentId = EntityHierarchyDTOs.Where(o => o.Customer_Level == 0).Select(o => o.CustomerId).FirstOrDefault() ?? Guid.Empty;
                    }
                }


                db = new DatabaseEntities();
                var data = await db.SubSiteOfficeConfigs.Where(o => o.RefId == userid).Select(o => new SubSiteOfficeConfigDTO
                {
                    Id    = o.Id.ToString(),
                    RefId = o.RefId.ToString(),
                    EFINListedOtherOffice       = o.EFINListedOtherOffice,
                    SiteOwnthisEFIN             = o.SiteOwnthisEFIN,
                    EFINOwnerSite               = o.EFINOwnerSite,
                    SOorSSorEFIN                = o.SOorSSorEFIN.ToString(),
                    SubSiteSendTaxReturn        = o.SubSiteSendTaxReturn,
                    SiteanMSOLocation           = o.SiteanMSOLocation,
                    IsMainSiteTransmitTaxReturn = o.IsMainSiteTransmitTaxReturn,
                    NoofTaxProfessionals        = o.NoofTaxProfessionals,
                    IsSoftwareOnNetwork         = o.IsSoftwareOnNetwork,
                    NoofComputers               = o.NoofComputers,
                    PreferredLanguage           = o.PreferredLanguage,
                    CanSubSiteLoginToEmp        = o.CanSubSiteLoginToEmp ?? false,
                    IsBusinessSoftware          = o.HasBusinessSoftware,
                    IsSharingEFIN               = o.IsSharingEFIN
                }).FirstOrDefaultAsync();

                if (data == null)
                {
                    if (EntityHierarchyDTOs.Count > 2)
                    {
                        SubSiteOfficeConfigDTO data1 = new SubSiteOfficeConfigDTO();
                        var subsiteconfig            = (from ssc in db.SubSiteOfficeConfigs where ssc.RefId == parentId select ssc).FirstOrDefault();
                        //  data1.Id = "0";
                        if (subsiteconfig != null)
                        {
                            data1.SubSiteSendTaxReturn = subsiteconfig.SubSiteSendTaxReturn;
                        }
                        else
                        {
                            data1.SubSiteSendTaxReturn = true;
                        }
                        data1.IsBusinessSoftware = db.emp_CustomerInformation.Where(x => x.Id == userid).Select(x => x.QuoteSoftwarePackage).FirstOrDefault() == EMPConstants.EnterprisePackage;
                        return(data1);
                    }
                    else
                    {
                        SubSiteOfficeConfigDTO data1 = new SubSiteOfficeConfigDTO();
                        var subsiteconfig            = (from ssc in db.SubSiteConfigurations where ssc.emp_CustomerInformation_ID == parentId select ssc).FirstOrDefault();
                        //  data1.Id = "0";
                        if (subsiteconfig != null)
                        {
                            data1.iIsSubSiteSendTaxReturn = subsiteconfig.SubSiteTaxReturn ?? 0;
                        }
                        else
                        {
                            data1.iIsSubSiteSendTaxReturn = 0;
                        }
                        data1.IsBusinessSoftware = db.emp_CustomerInformation.Where(x => x.Id == userid).Select(x => x.QuoteSoftwarePackage).FirstOrDefault() == EMPConstants.EnterprisePackage;
                        return(data1);
                    }
                }
                else
                {
                    if (EntityHierarchyDTOs.Count < 3)
                    {
                        var subsiteconfig = (from ssc in db.SubSiteConfigurations where ssc.emp_CustomerInformation_ID == parentId select ssc).FirstOrDefault();
                        if (subsiteconfig != null)
                        {
                            data.iIsSubSiteSendTaxReturn = subsiteconfig.SubSiteTaxReturn ?? 0;
                        }
                        else
                        {
                            data.iIsSubSiteSendTaxReturn = (data.SubSiteSendTaxReturn == true) ? 1 : 0;
                        }
                    }
                }
                return(data);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/GetSubSiteOfficeConfigById", Guid.Empty);
                return(null);
            }
        }
        // public DatabaseEntities db = new DatabaseEntities();

        //public IQueryable<ChangePasswordModel> GetAll()
        //{
        //    db = new DatabaseEntities();
        //    var data = db.emp_CustomerLoginInformation.Select(o => new ChangePasswordModel
        //    {
        //        Id = o.Id,
        //        EMPPassword = o.EMPPassword,
        //        CustomerOfficeId = o.CustomerOfficeId,
        //        StatusCode = o.StatusCode
        //    }).DefaultIfEmpty();
        //    return data;
        //}

        public CustomerLoginModel Get(CustomerLoginModel _Dto, string userip)
        {
            try
            {
                DropDownService           ddService           = new DropDownService();
                List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();

                db = new DatabaseEntities();
                //var data2 = db.emp_CustomerLoginInformation.ToList();
                string EMPPassword = PasswordManager.CryptText(_Dto.EMPPassword); // _Dto.EMPPassword
                var    data        = (from ci in db.emp_CustomerInformation
                                      join cli in db.emp_CustomerLoginInformation on ci.Id equals cli.CustomerOfficeId
                                      join entMas in db.EntityMasters on ci.EntityId equals entMas.Id
                                      where cli.EMPUserId == _Dto.EMPUserId && cli.EMPPassword == EMPPassword && (ci.StatusCode == EMPConstants.Active || ci.StatusCode == EMPConstants.Pending)
                                      //&& ci.IsHold != true//ci.StatusCode == EMPConstants.Created ||
                                      select new { ci, cli, EntityId = entMas.Id, entMas.BaseEntityId }).FirstOrDefault();

                if (data != null)
                {
                    if ((data.ci.IsHold ?? false) && data.ci.EntityId != (int)EMPConstants.Entity.SO && data.ci.EntityId != (int)EMPConstants.Entity.MO && data.ci.EntityId != (int)EMPConstants.Entity.SVB)
                    {
                        _Dto.Id      = Guid.Empty;
                        _Dto.Message = "Your site has been placed on hold, please contact your Software Provider";
                        return(_Dto);
                    }
                    _Dto.Id = data.cli.Id;
                    _Dto.CustomerOfficeId = data.cli.CustomerOfficeId;

                    //11212016
                    _Dto.EFIN       = data.ci.EFIN;
                    _Dto.EFINStatus = data.ci.EFINStatus;

                    _Dto.TaxOfficeUsername = data.cli.TaxOfficeUsername;
                    _Dto.CrossLinkUserId   = data.cli.CrossLinkUserId;

                    _Dto.IsChangedPassword     = (data.cli.CrossLinkPassword == data.cli.EMPPassword) ? true : false;
                    _Dto.IsSetSecurityQuestion = db.SecurityAnswerUserMaps.Where(o => o.UserId == data.cli.CustomerOfficeId).Any();
                    _Dto.Token       = _TokenService.GenerateToken(data.ci.Id, userip);
                    _Dto.ParentID    = data.ci.ParentId.ToString();
                    _Dto.SalesYearID = data.ci.SalesYearID.ToString();
                    //_Dto.EntityDisplayID = data.DisplayId;
                    _Dto.BaseEntityId = data.BaseEntityId;
                    // _Dto.EntityID = data.EntityId;
                    _Dto.EntityID = data.ci.EntityId;//.ToString();

                    _Dto.IsMSOUser             = data.ci.IsMSOUser ?? false;
                    _Dto.IsActivationCompleted = data.ci.IsActivationCompleted ?? 0;
                    _Dto.IsEnrollmentSubmit    = new SubSiteFeeService().IsEnrollmentSubmit(data.ci.Id);
                    _Dto.IsVerified            = data.ci.IsVerified ?? false;

                    _Dto.uTaxNotCollectingSBFee = data.ci.uTaxNotCollectingSBFee ?? false;

                    _Dto.IsTaxReturn = true;
                    if (data.ci.ParentId == Guid.Empty || data.ci.ParentId == null)
                    {
                        var taxreturn = db.MainOfficeConfigurations.Where(x => x.emp_CustomerInformation_ID == data.ci.Id && x.StatusCode == EMPConstants.Active).FirstOrDefault();
                        if (taxreturn != null)
                        {
                            _Dto.IsTaxReturn = taxreturn.IsSiteTransmitTaxReturns;
                        }
                    }
                    _Dto.IsHold = data.ci.IsHold ?? false;

                    Guid TopParentId = Guid.Empty;
                    EntityHierarchyDTOs = ddService.GetEntityHierarchies(data.ci.Id);
                    var TopFromHierarchy = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
                    TopParentId = TopFromHierarchy.CustomerId ?? Guid.Empty;

                    DefaultBankModel DefaultBank = new DefaultBankModel();

                    DefaultBank = (from enrollbank in db.EnrollmentBankSelections
                                   where enrollbank.CustomerId == data.cli.CustomerOfficeId && enrollbank.StatusCode == EMPConstants.Active && enrollbank.BankSubmissionStatus == 1
                                   orderby enrollbank.BankSubmissionStatus descending, enrollbank.LastUpdatedDate descending
                                   select new DefaultBankModel {
                        BankId = enrollbank.BankId, BankSubmissionStatus = enrollbank.BankSubmissionStatus ?? 0, LastUpdatedDate = enrollbank.LastUpdatedDate
                    }).FirstOrDefault();

                    if (DefaultBank != null)
                    {
                        _Dto.BankId = DefaultBank.BankId;
                    }
                    else
                    {
                        DefaultBankModel DefaultBank2 = (from enrollbank in db.EnrollmentBankSelections
                                                         where enrollbank.CustomerId == data.cli.CustomerOfficeId && enrollbank.StatusCode == EMPConstants.Active
                                                         orderby enrollbank.BankSubmissionStatus descending, enrollbank.LastUpdatedDate descending
                                                         select new DefaultBankModel {
                            BankId = enrollbank.BankId, BankSubmissionStatus = enrollbank.BankSubmissionStatus ?? 0, LastUpdatedDate = enrollbank.LastUpdatedDate
                        }).FirstOrDefault();

                        if (DefaultBank2 != null)
                        {
                            _Dto.BankId = DefaultBank2.BankId;
                        }
                    }


                    if (_Dto.EntityID != (int)EMPConstants.Entity.SO && _Dto.EntityID != (int)EMPConstants.Entity.SOME && _Dto.EntityID != (int)EMPConstants.Entity.SOME_SS && _Dto.BankId != Guid.Empty)
                    {
                        var SSBConfig = db.SubSiteBankConfigs.Where(o => o.emp_CustomerInformation_ID == TopParentId && o.BankMaster_ID == _Dto.BankId).ToList();
                        if (SSBConfig.Count() == 0)
                        {
                            _Dto.BankId = Guid.Empty;
                        }
                    }

                    if (TopParentId != Guid.Empty)
                    {
                        if (TopParentId == data.ci.Id)
                        {
                            _Dto.CanSubSiteLoginToEmp = true;
                        }
                        else
                        {
                            if (_Dto.BaseEntityId == (int)EMPConstants.BaseEntities.AE_SS)
                            {
                                // _Dto.CanSubSiteLoginToEmp = db.SubSiteOfficeConfigs.Where(a => a.RefId.ToString() == _Dto.ParentID).Select(a => a.CanSubSiteLoginToEmp ?? false).FirstOrDefault();
                                //var SupParentData = db.emp_CustomerInformation.Where(o => o.Id == data.ci.ParentId).FirstOrDefault();
                                //if (SupParentData != null)
                                //{
                                _Dto.SupParentID = TopParentId.ToString();

                                var sscExist = (from ssc in db.SubSiteConfigurations where ssc.emp_CustomerInformation_ID == TopParentId select ssc).FirstOrDefault();
                                if (sscExist != null)
                                {
                                    if (sscExist.IsuTaxManageingEnrolling == true)
                                    {
                                        _Dto.CanSubSiteLoginToEmp = true;
                                    }
                                    else
                                    {
                                        if (sscExist.IsuTaxPortalEnrollment == true)
                                        {
                                            _Dto.CanSubSiteLoginToEmp = true;
                                        }
                                        else
                                        {
                                            _Dto.CanSubSiteLoginToEmp = false;
                                        }
                                    }
                                }



                                var subSiteOfficeCo = (from ssc in db.SubSiteOfficeConfigs where ssc.RefId == _Dto.CustomerOfficeId select ssc).FirstOrDefault();
                                if (subSiteOfficeCo != null)
                                {
                                    if (subSiteOfficeCo.EFINListedOtherOffice == false)
                                    {
                                        _Dto.EFINOwnerUserId = false;
                                    }
                                    else
                                    {
                                        if (subSiteOfficeCo.SiteOwnthisEFIN == false)
                                        {
                                            _Dto.EFINOwnerUserId = true;
                                        }
                                        else
                                        {
                                            _Dto.EFINOwnerUserId = false;
                                        }
                                    }
                                }
                                //}
                            }
                            else
                            {
                                // _Dto.CanSubSiteLoginToEmp = db.SubSiteConfigurations.Where(a => a.emp_CustomerInformation_ID.ToString() == _Dto.ParentID).Select(a => a.CanSubSiteLoginToEmp).FirstOrDefault();

                                var sscExist = (from ssc in db.SubSiteConfigurations where ssc.emp_CustomerInformation_ID == TopParentId select ssc).FirstOrDefault();
                                if (sscExist != null)
                                {
                                    if (sscExist.IsuTaxManageingEnrolling == true)
                                    {
                                        _Dto.CanSubSiteLoginToEmp = true;
                                    }
                                    else
                                    {
                                        if (sscExist.IsuTaxPortalEnrollment == true)
                                        {
                                            _Dto.CanSubSiteLoginToEmp = true;
                                        }
                                        else
                                        {
                                            _Dto.CanSubSiteLoginToEmp = false;
                                        }
                                    }
                                }


                                var subSiteOfficeCo = (from ssc in db.SubSiteOfficeConfigs where ssc.RefId == _Dto.CustomerOfficeId select ssc).FirstOrDefault();
                                if (subSiteOfficeCo != null)
                                {
                                    if (subSiteOfficeCo.EFINListedOtherOffice == false)
                                    {
                                        _Dto.EFINOwnerUserId = false;
                                    }
                                    else
                                    {
                                        if (subSiteOfficeCo.SiteOwnthisEFIN == false)
                                        {
                                            _Dto.EFINOwnerUserId = true;
                                        }
                                        else
                                        {
                                            _Dto.EFINOwnerUserId = false;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        _Dto.CanSubSiteLoginToEmp = true;
                    }


                    if (_Dto.EntityID == (int)EMPConstants.Entity.SOME_SS)
                    {
                        _Dto.CanSubSiteLoginToEmp = true;
                    }

                    EntityHierarchyDTOs = ddService.GetEntityHierarchies(_Dto.Id);

                    Guid ParentId = Guid.Empty;
                    int  Level    = EntityHierarchyDTOs.Count;
                    if (EntityHierarchyDTOs.Count > 0)
                    {
                        var LevelOne = EntityHierarchyDTOs.OrderByDescending(o => o.Customer_Level).FirstOrDefault();
                        if (LevelOne != null)
                        {
                            ParentId = LevelOne.CustomerId ?? Guid.Empty;
                        }

                        if (EntityHierarchyDTOs.Count > 1)
                        {
                            _Dto.IsMSOUser = db.emp_CustomerInformation.Where(o => o.Id == ParentId).Select(o => o.IsMSOUser).FirstOrDefault() ?? false;
                        }
                    }
                }
                else
                {
                    return(null);
                }
                return(_Dto);
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "CustomerLogin/Get", Guid.Empty);
                return(null);
            }
        }
        /// <summary>
        /// This Method is used to Get the Main Office Configuration Details
        /// </summary>
        /// <returns></returns>
        public async Task <SubSiteDTO> GetById(Guid userid)
        {
            try
            {
                DropDownService           ddService           = new DropDownService();
                List <EntityHierarchyDTO> EntityHierarchyDTOs = new List <EntityHierarchyDTO>();
                EntityHierarchyDTOs = ddService.GetEntityHierarchies(userid);

                Guid ParentId = Guid.Empty;
                int  Level    = EntityHierarchyDTOs.Count;
                if (EntityHierarchyDTOs.Count == 1)
                {
                    var LevelOne = EntityHierarchyDTOs.Where(o => o.Customer_Level == 0).FirstOrDefault();
                    if (LevelOne != null)
                    {
                        ParentId = LevelOne.CustomerId ?? Guid.Empty;
                    }
                }
                else
                {
                    var LevelOne = EntityHierarchyDTOs.Where(o => o.Customer_Level == 1).FirstOrDefault();
                    if (LevelOne != null)
                    {
                        ParentId = LevelOne.CustomerId ?? Guid.Empty;
                    }
                }

                userid = ParentId;

                db = new DatabaseEntities();
                var data = await db.SubSiteConfigurations.Where(o => (o.StatusCode == EMPConstants.Active || o.StatusCode == EMPConstants.Pending) && o.emp_CustomerInformation_ID == userid).Select(o => new SubSiteDTO
                {
                    Id    = o.ID.ToString(),
                    refId = o.emp_CustomerInformation_ID.ToString(),
                    IsuTaxManageingEnrolling = o.IsuTaxManageingEnrolling,
                    IsuTaxPortalEnrollment   = o.IsuTaxPortalEnrollment,
                    IsuTaxManageOnboarding   = o.IsuTaxManageOnboarding,
                    EnrollmentEmails         = o.EnrollmentEmails ?? false,
                    IsuTaxCustomerSupport    = o.IsuTaxCustomerSupport,
                    NoofSupportStaff         = o.NoofSupportStaff,
                    NoofDays                     = o.NoofDays,
                    OpenHours                    = o.OpenHours.Value.ToString(),  // "hh:mm tt"),// "hh:mm tt"),
                    CloseHours                   = o.CloseHours.Value.ToString(), //"hh:mm tt"),//"hh:mm tt"),
                    TimeZone                     = o.TimeZone.ToString(),
                    SubSiteTaxReturn             = o.SubSiteTaxReturn,
                    IsAutoEnrollAffiliateProgram = o.IsAutoEnrollAffiliateProgram,
                    IsSubSiteEFINAllow           = o.IsSubSiteEFINAllow,
                    CanSubSiteLoginToEmp         = o.CanSubSiteLoginToEmp,
                    Affiliates                   = o.SubSiteAffiliateProgramConfigs.Select(s => new SubSiteAffiliateProgramDTO()
                    {
                        AffiliateProgramId = s.AffiliateProgramMaster_ID
                    }).ToList(),
                    SubSiteBankQuestions = o.SubSiteBankConfigs.Select(s => new SubSiteBankQuestionDTO()
                    {
                        BankId = s.BankMaster_ID, QuestionId = s.SubQuestion_ID ?? Guid.Empty
                    }).ToList()
                }).FirstOrDefaultAsync();

                if (data != null)
                {
                    DateTime dt  = new DateTime();
                    bool     res = DateTime.TryParse(data.OpenHours, out dt);
                    string   ddt = new DateTime().Add(dt.TimeOfDay).ToString("hh:mm tt");
                    data.OpenHours = ddt;

                    DateTime dt1  = new DateTime();
                    bool     res1 = DateTime.TryParse(data.CloseHours, out dt1);
                    string   ddt1 = new DateTime().Add(dt1.TimeOfDay).ToString("hh:mm tt");
                    data.CloseHours = ddt1;
                }
                else
                {
                    if (Level > 2)
                    {
                        data = new DTO.SubSiteDTO();
                        var SubSiteOfficeCon = db.SubSiteOfficeConfigs.Where(o => o.RefId == ParentId).FirstOrDefault();

                        if (SubSiteOfficeCon != null)
                        {
                            if (SubSiteOfficeCon.SOorSSorEFIN == 2 || SubSiteOfficeCon.SOorSSorEFIN == 3)
                            {
                                data.IsSubSiteEFINAllow = true;
                            }
                        }
                    }

                    // OpenHours = new DateTime().Add(o.OpenHours.Value).ToString("hh:mm tt"),// "hh:mm tt"),
                    //     CloseHours = new DateTime().Add(o.CloseHours.Value).ToString("hh:mm tt"),//"hh:mm tt"),
                }

                return(data);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteConfigService/GetById", userid);
                return(null);
            }
        }