Exemplo n.º 1
0
        /// <summary>
        /// This method is used to Save the main office details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public Guid SupportServiceSave(SubSiteSupportDTO dto)
        {
            int entityState            = 0;
            SubSiteConfiguration model = new SubSiteConfiguration();

            if (dto != null)
            {
                Guid Id, refId;
                bool IsRefId = Guid.TryParse(dto.refId, out refId);
                if (!IsRefId)
                {
                    return(Guid.Empty);
                }
                if (Guid.TryParse(dto.Id, out Id))
                {
                    model = db.SubSiteConfigurations.Where(a => a.ID == Id).FirstOrDefault();
                    if (model.IsuTaxManageingEnrolling != null && model.IsuTaxManageOnboarding != null)
                    {
                        Guid SiteMapId;
                        int  EntityType = 0;
                        if (Guid.TryParse("68882c05-5914-4fdb-b284-e33d6c029f5a", out SiteMapId))
                        {
                            CustomerConfigurationStatu ConfigStatusModel = new CustomerConfigurationStatu();
                            ConfigStatusModel = db.CustomerConfigurationStatus.Where(o => o.CustomerId == refId && o.SitemapId == SiteMapId).FirstOrDefault();
                            if (ConfigStatusModel == null)
                            {
                                ConfigStatusModel    = new CustomerConfigurationStatu();
                                ConfigStatusModel.Id = Guid.NewGuid();
                            }
                            else
                            {
                                EntityType = (int)System.Data.Entity.EntityState.Modified;
                            }

                            ConfigStatusModel.CustomerId  = refId;
                            ConfigStatusModel.SitemapId   = SiteMapId;
                            ConfigStatusModel.StatusCode  = "done";
                            ConfigStatusModel.UpdatedBy   = dto.UserId ?? Guid.Empty;
                            ConfigStatusModel.UpdatedDate = DateTime.Now;

                            if (EntityType == (int)System.Data.Entity.EntityState.Modified)
                            {
                                db.Entry(ConfigStatusModel).State = System.Data.Entity.EntityState.Modified;
                            }
                            else
                            {
                                db.CustomerConfigurationStatus.Add(ConfigStatusModel);
                            }
                        }
                    }
                    if (model != null)
                    {
                        entityState = (int)System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        return(Guid.Empty);
                    }
                }
                else
                {
                    model.ID    = Guid.NewGuid();
                    entityState = (int)System.Data.Entity.EntityState.Added;
                }
                model.emp_CustomerInformation_ID = refId; // newguid;
                if (dto.IsuTaxCustomerSupport != null)
                {
                    model.IsuTaxCustomerSupport = dto.IsuTaxCustomerSupport.Value;
                }
                if (dto.NoofSupportStaff != null)
                {
                    model.NoofSupportStaff = dto.NoofSupportStaff.Value;
                }

                if (!string.IsNullOrEmpty(dto.NoofDays))
                {
                    model.NoofDays = dto.NoofDays;
                }

                if (dto.OpenHours != null)
                {
                    DateTime dt;
                    bool     res = DateTime.TryParse(dto.OpenHours, out dt);
                    if (!res)
                    {
                        return(Guid.Empty);
                    }
                    model.OpenHours = dt.TimeOfDay;
                }

                if (dto.CloseHours != null)
                {
                    DateTime dt;
                    bool     res = DateTime.TryParse(dto.CloseHours, out dt);

                    if (!res)
                    {
                        return(Guid.Empty);
                    }
                    model.CloseHours = dt.TimeOfDay;
                }

                if (!string.IsNullOrEmpty(dto.TimeZone))
                {
                    model.TimeZone = dto.TimeZone;
                }

                if (dto.IsAutoEnrollAffiliateProgram != null)
                {
                    model.IsAutoEnrollAffiliateProgram = dto.IsAutoEnrollAffiliateProgram.Value;
                }

                if (dto.SubSiteTaxReturn != null)
                {
                    model.SubSiteTaxReturn = dto.SubSiteTaxReturn.Value;
                }

                model.StatusCode      = EMPConstants.Active;
                model.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                model.LastUpdatedDate = System.DateTime.Now;

                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    model.CreatedBy   = dto.UserId ?? Guid.Empty;
                    model.CreatedDate = System.DateTime.Now;
                    db.SubSiteConfigurations.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;

                    var Affiliate = db.SubSiteAffiliateProgramConfigs.Where(o => o.SubSiteConfiguration_ID == model.ID).ToList();

                    if (Affiliate.ToList().Count > 0)
                    {
                        db.SubSiteAffiliateProgramConfigs.RemoveRange(Affiliate);
                    }
                }
                SaveSubOfficeDetails(refId, dto.SubSiteTaxReturn.Value);
                List <SubSiteAffiliateProgramConfig> SubSiteAffiliatePrograms = new List <SubSiteAffiliateProgramConfig>();

                foreach (var item in dto.Affiliates)
                {
                    SubSiteAffiliateProgramConfig SubSiteAffiliateProgram = new SubSiteAffiliateProgramConfig();
                    SubSiteAffiliateProgram.ID = Guid.NewGuid();
                    SubSiteAffiliateProgram.emp_CustomerInformation_ID = model.emp_CustomerInformation_ID;
                    SubSiteAffiliateProgram.AffiliateProgramMaster_ID  = item.AffiliateProgramId;
                    SubSiteAffiliateProgram.SubSiteConfiguration_ID    = model.ID;

                    SubSiteAffiliateProgram.CreatedBy       = dto.UserId ?? Guid.Empty;
                    SubSiteAffiliateProgram.CreatedDate     = DateTime.Now;
                    SubSiteAffiliateProgram.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                    SubSiteAffiliateProgram.LastUpdatedDate = DateTime.Now;

                    SubSiteAffiliatePrograms.Add(SubSiteAffiliateProgram);
                }

                if (dto.Affiliates.ToList().Count > 0)
                {
                    db.SubSiteAffiliateProgramConfigs.AddRange(SubSiteAffiliatePrograms);
                }
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(model.ID);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteConfigService/SupportServiceSave", Guid.Empty);
                return(Guid.Empty);

                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method is used to Save the main office details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public Guid OnBoardingServiceSave(SubSiteOnBoardingDTO dto)
        {
            int entityState            = 0;
            SubSiteConfiguration model = new SubSiteConfiguration();

            if (dto != null)
            {
                Guid Id, refId;
                bool IsRefId = Guid.TryParse(dto.refId, out refId);
                if (!IsRefId)
                {
                    return(Guid.Empty);
                }

                if (Guid.TryParse(dto.Id, out Id))
                {
                    model = db.SubSiteConfigurations.Where(a => a.ID == Id).FirstOrDefault();
                    if (model.IsuTaxManageingEnrolling != null && model.IsuTaxCustomerSupport != null)
                    {
                        Guid SiteMapId; int EntityType = 0;
                        if (Guid.TryParse("68882c05-5914-4fdb-b284-e33d6c029f5a", out SiteMapId))
                        {
                            CustomerConfigurationStatu ConfigStatusModel = new CustomerConfigurationStatu();
                            ConfigStatusModel = db.CustomerConfigurationStatus.Where(o => o.CustomerId == refId && o.SitemapId == SiteMapId).FirstOrDefault();
                            if (ConfigStatusModel == null)
                            {
                                ConfigStatusModel    = new CustomerConfigurationStatu();
                                ConfigStatusModel.Id = Guid.NewGuid();
                            }
                            else
                            {
                                EntityType = (int)System.Data.Entity.EntityState.Modified;
                            }

                            ConfigStatusModel.CustomerId  = refId;
                            ConfigStatusModel.SitemapId   = SiteMapId;
                            ConfigStatusModel.StatusCode  = "done";
                            ConfigStatusModel.UpdatedBy   = dto.UserId ?? Guid.Empty;
                            ConfigStatusModel.UpdatedDate = DateTime.Now;

                            if (EntityType == (int)System.Data.Entity.EntityState.Modified)
                            {
                                db.Entry(ConfigStatusModel).State = System.Data.Entity.EntityState.Modified;
                            }
                            else
                            {
                                db.CustomerConfigurationStatus.Add(ConfigStatusModel);
                            }
                        }
                    }

                    if (model != null)
                    {
                        entityState = (int)System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        return(Guid.Empty);
                    }
                }
                else
                {
                    model.ID    = Guid.NewGuid();
                    entityState = (int)System.Data.Entity.EntityState.Added;
                }
                model.emp_CustomerInformation_ID = refId; // newguid;
                if (dto.IsuTaxManageOnboarding != null)
                {
                    model.IsuTaxManageOnboarding = dto.IsuTaxManageOnboarding.Value;
                }
                model.StatusCode      = EMPConstants.Active;
                model.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                model.LastUpdatedDate = System.DateTime.Now;
                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    model.CreatedBy   = dto.UserId ?? Guid.Empty;
                    model.CreatedDate = System.DateTime.Now;
                    db.SubSiteConfigurations.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                }


                var custinfo = (from s in db.emp_CustomerInformation
                                join sy in db.SalesYearMasters on s.SalesYearID equals sy.Id
                                where s.Id == refId
                                select new
                {
                    s.IsMSOUser,
                    s.SalesforceAccountID,
                    sy.SalesYear
                }).FirstOrDefault();

                CustomerInformation.CustomerInformationService objCIS = new CustomerInformation.CustomerInformationService();
                string desc   = (custinfo.IsMSOUser ?? false) ? "Automated MSO " + custinfo.SalesYear ?? 0 + " Onboarding Case " : "Automated Desktop " + custinfo.SalesYear ?? 0 + " Onboarding Case";
                var    caseId = objCIS.SaveCSRCase(custinfo.SalesforceAccountID, (custinfo.SalesYear ?? 0).ToString(), dto.IsuTaxManageOnboarding ?? false, desc);

                var cinfo = db.emp_CustomerInformation.Where(x => x.Id == refId).FirstOrDefault();
                cinfo.OnBoardPrimaryKey = caseId;
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(model.ID);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteConfigService/OnBoardingServiceSave", Guid.Empty);
                return(Guid.Empty);

                throw;
            }
        }
        /// <summary>
        /// This method is used to Save the main office details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public bool CustomerConfigStatusSave(CustomerConfigStatusDTO dto)
        {
            try
            {
                int entityState = 0;

                CustomerConfigurationStatu model = new CustomerConfigurationStatu();

                if (dto != null)
                {
                    Guid Id, SitemapId, CustomerId, xBankId;

                    bool IsBankId = Guid.TryParse(dto.bankid, out xBankId);
                    if (!IsBankId)
                    {
                        return(false);
                    }

                    bool IsSitemapId = Guid.TryParse(dto.SitemapId, out SitemapId);
                    if (!IsSitemapId)
                    {
                        return(false);
                    }

                    bool IsCustomerId = Guid.TryParse(dto.CustomerId, out CustomerId);
                    if (!IsCustomerId)
                    {
                        return(false);
                    }

                    if (Guid.TryParse(dto.Id, out Id))
                    {
                        model = db.CustomerConfigurationStatus.Where(a => a.CustomerId == CustomerId && a.SitemapId == SitemapId).FirstOrDefault();
                        if (model != null)
                        {
                            entityState = (int)System.Data.Entity.EntityState.Modified;
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        model.Id    = Guid.NewGuid();
                        entityState = (int)System.Data.Entity.EntityState.Added;
                    }

                    model.CustomerId  = CustomerId; // newguid;
                    model.StatusCode  = dto.Status;
                    model.UpdatedBy   = dto.UserId ?? Guid.Empty;
                    model.UpdatedDate = System.DateTime.Now;
                    model.bankid      = xBankId; // newguid;

                    if (entityState == (int)System.Data.Entity.EntityState.Added)
                    {
                        db.CustomerConfigurationStatus.Add(model);
                    }
                    else
                    {
                        db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                    }
                }

                try
                {
                    db.SaveChanges();
                    db.Dispose();
                    return(true);
                }
                catch (Exception ex)
                {
                    ExceptionLogger.LogException(ex.ToString(), "Configuration/ConfigurationStatus", Guid.Empty);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "Configuration/ConfigurationStatus", Guid.Empty);
                return(false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method is used to Save the main office details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public Guid BankServiceSave(SubSiteBankServiceDTO dto)
        {
            int entityState            = 0;
            SubSiteConfiguration model = new SubSiteConfiguration();

            if (dto != null)
            {
                Guid Id, refId;

                bool IsRefId = Guid.TryParse(dto.refId, out refId);
                if (!IsRefId)
                {
                    return(Guid.Empty);
                }

                if (Guid.TryParse(dto.Id, out Id))
                {
                    model = db.SubSiteConfigurations.Where(a => a.ID == Id).FirstOrDefault();
                    if (model.IsuTaxManageOnboarding != null && model.IsuTaxCustomerSupport != null)
                    {
                        Guid SiteMapId;
                        int  EntityType = 0;
                        if (Guid.TryParse("68882c05-5914-4fdb-b284-e33d6c029f5a", out SiteMapId))
                        {
                            CustomerConfigurationStatu ConfigStatusModel = new CustomerConfigurationStatu();
                            ConfigStatusModel = db.CustomerConfigurationStatus.Where(o => o.CustomerId == refId && o.SitemapId == SiteMapId).FirstOrDefault();
                            if (ConfigStatusModel == null)
                            {
                                ConfigStatusModel    = new CustomerConfigurationStatu();
                                ConfigStatusModel.Id = Guid.NewGuid();
                            }
                            else
                            {
                                EntityType = (int)System.Data.Entity.EntityState.Modified;
                            }

                            ConfigStatusModel.CustomerId  = dto.UserId ?? Guid.Empty;
                            ConfigStatusModel.SitemapId   = SiteMapId;
                            ConfigStatusModel.StatusCode  = "done";
                            ConfigStatusModel.UpdatedBy   = dto.UserId ?? Guid.Empty;
                            ConfigStatusModel.UpdatedDate = DateTime.Now;

                            if (EntityType == (int)System.Data.Entity.EntityState.Modified)
                            {
                                db.Entry(ConfigStatusModel).State = System.Data.Entity.EntityState.Modified;
                            }
                            else
                            {
                                db.CustomerConfigurationStatus.Add(ConfigStatusModel);
                            }
                        }
                    }

                    if (model != null)
                    {
                        entityState = (int)System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        return(Guid.Empty);
                    }
                }
                else
                {
                    model.ID    = Guid.NewGuid();
                    entityState = (int)System.Data.Entity.EntityState.Added;
                }



                model.emp_CustomerInformation_ID = refId; // newguid;

                if (dto.IsuTaxManageingEnrolling != null)
                {
                    model.IsuTaxManageingEnrolling = dto.IsuTaxManageingEnrolling.Value;
                }

                if (dto.IsuTaxPortalEnrollment != null)
                {
                    model.IsuTaxPortalEnrollment = dto.IsuTaxPortalEnrollment.Value;
                }


                if (dto.IsSubSiteEFINAllow != null)
                {
                    model.IsSubSiteEFINAllow = dto.IsSubSiteEFINAllow.Value;
                }
                else
                {
                    model.IsSubSiteEFINAllow = false;
                }


                model.EnrollmentEmails     = dto.EnrollmentEmails;
                model.CanSubSiteLoginToEmp = true;

                model.StatusCode      = EMPConstants.Active;
                model.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                model.LastUpdatedDate = System.DateTime.Now;

                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    model.CreatedBy   = dto.UserId ?? Guid.Empty;
                    model.CreatedDate = System.DateTime.Now;
                    db.SubSiteConfigurations.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;

                    var Bank = db.SubSiteBankConfigs.Where(o => o.SubSiteConfiguration_ID == model.ID).ToList();

                    if (Bank.ToList().Count > 0)
                    {
                        db.SubSiteBankConfigs.RemoveRange(Bank);
                    }
                }

                List <SubSiteBankConfig> SubSiteBankConfigs = new List <SubSiteBankConfig>();

                foreach (var item in dto.SubSiteBankQuestions)
                {
                    SubSiteBankConfig SubSiteBank = new SubSiteBankConfig();
                    SubSiteBank.ID = Guid.NewGuid();
                    SubSiteBank.emp_CustomerInformation_ID = model.emp_CustomerInformation_ID;
                    SubSiteBank.BankMaster_ID           = item.BankId;
                    SubSiteBank.SubSiteConfiguration_ID = model.ID;
                    SubSiteBank.SubQuestion_ID          = item.QuestionId;

                    SubSiteBank.CreatedBy       = dto.UserId ?? Guid.Empty;
                    SubSiteBank.CreatedDate     = DateTime.Now;
                    SubSiteBank.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                    SubSiteBank.LastUpdatedDate = DateTime.Now;

                    SubSiteBankConfigs.Add(SubSiteBank);
                }

                if (dto.SubSiteBankQuestions.ToList().Count > 0)
                {
                    db.SubSiteBankConfigs.AddRange(SubSiteBankConfigs);
                }

                if (dto.IsuTaxManageingEnrolling ?? false)
                {
                    var custinfo = (from s in db.emp_CustomerInformation
                                    join sy in db.SalesYearMasters on s.SalesYearID equals sy.Id
                                    where s.Id == refId
                                    select new
                    {
                        s.IsMSOUser,
                        s.SalesforceAccountID,
                        sy.SalesYear
                    }
                                    ).FirstOrDefault();

                    CustomerInformation.CustomerInformationService objCIS = new CustomerInformation.CustomerInformationService();
                    string desc = (custinfo.IsMSOUser ?? false) ? "Automated MSO " + custinfo.SalesYear ?? 0 + " Enrollment Case " : "Automated Desktop " + custinfo.SalesYear ?? 0 + " Enrollment Case";
                    objCIS.SaveCSRCase(custinfo.SalesforceAccountID, (custinfo.SalesYear ?? 0).ToString(), true, desc, false);
                }
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(model.ID);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteConfigService/BankServiceSave", model.ID);
                return(Guid.Empty);

                throw;
            }
        }
        public bool SaveConfigurationSatus(Guid CustomerId, Guid UserId, Guid SiteMapID, string resettype, string ActiveLinkSiteMapID, Guid BankId, string status = "done")
        {
            try
            {
                db = new DatabaseEntities();


                int entityState = 0;
                CustomerConfigurationStatu model = new CustomerConfigurationStatu();

                if (BankId == Guid.Empty && SiteMapID != new Guid("067C03A3-34F1-4143-BEAE-35327A8FCA44"))
                {
                    model = db.CustomerConfigurationStatus.Where(a => a.CustomerId == CustomerId && a.SitemapId == SiteMapID).FirstOrDefault();
                }
                else
                {
                    model = db.CustomerConfigurationStatus.Where(a => a.CustomerId == CustomerId && a.SitemapId == SiteMapID && a.bankid == BankId).FirstOrDefault();
                }

                if (model != null)
                {
                    entityState = (int)System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    model       = new CustomerConfigurationStatu();
                    model.Id    = Guid.NewGuid();
                    entityState = (int)System.Data.Entity.EntityState.Added;
                }
                model.SitemapId  = SiteMapID;
                model.CustomerId = CustomerId;

                if (status.ToLower() == EMPConstants.Done)
                {
                    model.StatusCode = EMPConstants.Done;
                }
                else if (status.ToLower() == EMPConstants.None)
                {
                    model.StatusCode = EMPConstants.None;
                }

                model.UpdatedBy   = UserId;
                model.UpdatedDate = System.DateTime.Now;
                model.bankid      = BankId;

                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    db.CustomerConfigurationStatus.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                }
                try
                {
                    db.SaveChanges();


                    var xResetType = resettype;
                    if (!string.IsNullOrEmpty(xResetType))
                    {
                        if (xResetType == "_reset" || xResetType == "reset")
                        {
                            Guid GActiveLinkSitemapID = Guid.Empty;
                            if (!Guid.TryParse(ActiveLinkSiteMapID, out GActiveLinkSitemapID))
                            {
                                return(false);
                            }

                            var result = ResetConfigurationSatus(CustomerId, UserId, GActiveLinkSitemapID);
                        }
                    }

                    var isverified = db.emp_CustomerInformation.Where(x => x.Id == CustomerId).Select(x => x.IsVerified).FirstOrDefault();
                    if (SiteMapID.ToString().ToLower() == "98a706d7-031f-4c5d-8cc4-d32cc7658b63" || (SiteMapID.ToString().ToLower() == "1f2a6418-f9bc-4878-ab0b-2fa004c01c01" && (isverified ?? false)))
                    {
                        SaveConfigurationSatus(CustomerId, UserId, new Guid("7c8aa474-2535-4f69-a2ae-c3794887f92d"), resettype, ActiveLinkSiteMapID, BankId, status);
                    }
                    db.Dispose();
                    return(true);
                }
                catch (Exception ex)
                {
                    ExceptionLogger.LogException(ex.ToString(), "Configuration/Save", UserId);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "Configuration/Save", UserId);
                return(false);
            }
        }