Beispiel #1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         db.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #2
0
 protected override void Dispose(bool disposing)
 {
     if (_db != null)
     {
         _db.Dispose();
     }
     base.Dispose(disposing);
 }
Beispiel #3
0
        public async Task <Guid> SaveStatus(PhoneTypeDTO _Dto, Guid Id, int EntityState)
        {
            PhoneTypeMaster PhoneType = new PhoneTypeMaster();

            PhoneType = await db.PhoneTypeMasters.Where(o => o.Id == Id).FirstOrDefaultAsync();

            PhoneType.ActivatedDate = DateTime.Now;

            if (PhoneType.StatusCode == EMPConstants.InActive)
            {
                PhoneType.StatusCode = EMPConstants.Active;
            }
            else if (PhoneType.StatusCode == EMPConstants.Active)
            {
                PhoneType.StatusCode = EMPConstants.InActive;
            }

            if (EntityState == (int)System.Data.Entity.EntityState.Modified)
            {
                PhoneType.LastUpdatedDate = DateTime.Now;
                PhoneType.LastUpdatedBy   = _Dto.UserId;
                db.Entry(PhoneType).State = System.Data.Entity.EntityState.Modified;
            }

            try
            {
                await db.SaveChangesAsync();

                db.Dispose();
                return(PhoneType.Id);
            }

            catch (DbUpdateConcurrencyException)
            {
                if (!IsExists(PhoneType.Id))
                {
                    return(Guid.Empty);
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #4
0
        public async Task <Guid> SaveStatus(BankSubQuestionDTO _Dto, Guid Id, int EntityState)
        {
            BankSubQuestion bankSubQuestion = new BankSubQuestion();

            bankSubQuestion = await db.BankSubQuestions.Where(o => o.Id == Id).FirstOrDefaultAsync();

            if (bankSubQuestion.StatusCode == EMPConstants.InActive)
            {
                bankSubQuestion.StatusCode = EMPConstants.Active;
            }
            else if (bankSubQuestion.StatusCode == EMPConstants.Active)
            {
                bankSubQuestion.StatusCode = EMPConstants.InActive;
            }

            if (EntityState == (int)System.Data.Entity.EntityState.Modified)
            {
                bankSubQuestion.LastUpdatedDate = DateTime.Now;
                bankSubQuestion.LastUpdatedBy   = _Dto.UserId;
                db.Entry(bankSubQuestion).State = System.Data.Entity.EntityState.Modified;
            }

            try
            {
                await db.SaveChangesAsync();

                db.Dispose();
                return(bankSubQuestion.Id);
            }

            catch (DbUpdateConcurrencyException)
            {
                if (!IsExists(bankSubQuestion.Id))
                {
                    return(Guid.Empty);
                }
                else
                {
                    throw;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// This Method is used to update Amount for Customer Associated Fees
        /// </summary>
        /// <param name="tmDto"></param>
        /// <returns></returns>
        public bool UpdateCustomerAssociatedFees(TransmitterFeeDTO tmDto)
        {
            bool iretval = false;

            //int entityState = 0;
            try
            {
                if (tmDto != null)
                {
                    Guid newguid, newguid2;

                    bool IsRefId  = Guid.TryParse(tmDto.FeeMaster_ID, out newguid2);
                    bool IsRefId1 = Guid.TryParse(tmDto.refId, out newguid);
                    CustomerAssociatedFee customerassociatedfee = new CustomerAssociatedFee();

                    var data = db.CustomerAssociatedFees.Where(a => a.emp_CustomerInformation_ID == newguid && a.FeeMaster_ID == newguid2 && a.IsActive == true).FirstOrDefault();
                    if (data != null)
                    {
                        customerassociatedfee = data;
                        customerassociatedfee.LastUpdatedBy   = tmDto.UserId ?? Guid.Empty;
                        customerassociatedfee.LastUpdatedDate = System.DateTime.Now;
                        customerassociatedfee.IsActive        = false;
                        db.Entry(customerassociatedfee).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        db.Dispose();
                        //EMP.Core.Utilities.AuditLogger.AudittrailLog(customerassociatedfee, data, "Modify", tmDto.UserId ?? Guid.Empty);
                    }

                    db = new DatabaseEntities();
                    CustomerAssociatedFee customerassociatedfeeSave = new CustomerAssociatedFee();

                    customerassociatedfeeSave                 = data;
                    customerassociatedfeeSave.ID              = Guid.NewGuid();
                    customerassociatedfeeSave.Amount          = tmDto.Amount;
                    customerassociatedfeeSave.IsActive        = true;
                    customerassociatedfeeSave.CreatedBy       = tmDto.UserId ?? Guid.Empty;
                    customerassociatedfeeSave.CreatedDate     = System.DateTime.Now;
                    customerassociatedfeeSave.LastUpdatedBy   = tmDto.UserId ?? Guid.Empty;
                    customerassociatedfeeSave.LastUpdatedDate = System.DateTime.Now;
                    db.CustomerAssociatedFees.Add(customerassociatedfeeSave);

                    db.SaveChanges();
                    db.Dispose();
                    //EMP.Core.Utilities.AuditLogger.AudittrailLog(customerassociatedfeeSave, null, "Add", tmDto.UserId ?? Guid.Empty);
                    iretval = true;
                }
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteFeeService/UpdateCustomerAssociatedFees", Guid.Empty);
                return(false);
            }
            return(iretval);
        }
Beispiel #6
0
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (_db != null)
         {
             _db.Dispose();
             _db = null;
         }
     }
 }
Beispiel #7
0
 protected virtual void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             entities.Dispose();
         }
     }
     this.disposed = true;
 }
        public bool Save(userSecurityAnswerModel _Dto)
        {
            try
            {
                List <SecurityAnswerUserMap> _SecurityAnswers = new List <SecurityAnswerUserMap>();

                List <SecurityQuestionAnswerModel> _userSecurityAnswerModel = new List <SecurityQuestionAnswerModel>();

                if (_Dto.Status == "2")
                {
                    var result = db.SecurityAnswerUserMaps.Where(o => o.UserId == _Dto.Id).ToList();
                    if (result.Count() > 0)
                    {
                        db.SecurityAnswerUserMaps.RemoveRange(result);
                    }
                }

                foreach (var item in _Dto.QuestionsLst)
                {
                    SecurityAnswerUserMap _SecurityAnswer = new SecurityAnswerUserMap();
                    _SecurityAnswer.Id              = Guid.NewGuid();
                    _SecurityAnswer.QuestionId      = item.QuestionId;
                    _SecurityAnswer.Answer          = item.Answer;
                    _SecurityAnswer.DisplayOrder    = item.DisplayOrder;
                    _SecurityAnswer.UserId          = _Dto.Id;
                    _SecurityAnswer.CreatedBy       = _Dto.Id;
                    _SecurityAnswer.LastUpdatedBy   = _Dto.Id;
                    _SecurityAnswer.LastUpdatedDate = DateTime.Now;
                    _SecurityAnswer.CreatedDate     = DateTime.Now;
                    _SecurityAnswer.StatusCode      = EMPConstants.Active;
                    _SecurityAnswers.Add(_SecurityAnswer);
                }

                db.SecurityAnswerUserMaps.AddRange(_SecurityAnswers);

                try
                {
                    db.SaveChanges();
                    db.Dispose();
                }
                catch (DbUpdateConcurrencyException ex)
                {
                    ExceptionLogger.LogException(ex.ToString(), "SecurityAnswer/PostSecurityQuestion", Guid.Empty);
                    return(false);
                }
                return(true);
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "SecurityAnswer/PostSecurityQuestion", Guid.Empty);
                return(false);
            }
        }
        public async Task <Guid> SaveStatus(ResetPasswordModel _Dto, Guid Id, int EntityState)
        {
            try
            {
                emp_CustomerLoginInformation CustomerLoginInformation = new emp_CustomerLoginInformation();
                CustomerLoginInformation = await db.emp_CustomerLoginInformation.Where(o => o.Id == Id).FirstOrDefaultAsync();

                //securityQuestionMaster.ActivatedDate = DateTime.Now;

                if (CustomerLoginInformation.StatusCode == EMPConstants.InActive)
                {
                    CustomerLoginInformation.StatusCode = EMPConstants.Active;
                }
                else if (CustomerLoginInformation.StatusCode == EMPConstants.Active)
                {
                    CustomerLoginInformation.StatusCode = EMPConstants.InActive;
                }

                if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    CustomerLoginInformation.LastUpdatedDate = DateTime.Now;
                    CustomerLoginInformation.LastUpdatedBy   = _Dto.UserId;
                    db.Entry(CustomerLoginInformation).State = System.Data.Entity.EntityState.Modified;
                }

                try
                {
                    await db.SaveChangesAsync();

                    db.Dispose();
                    return(CustomerLoginInformation.Id);
                }

                catch (DbUpdateConcurrencyException)
                {
                    if (!IsExists(CustomerLoginInformation.Id))
                    {
                        return(Guid.Empty);
                    }
                    else
                    {
                        return(Guid.Empty);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "ResetPassword/PutResetPassword", Id);
                return(Guid.Empty);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Method to validate token against expiry and existence in database.
        /// </summary>
        /// <param name="tokenId"></param>
        /// <returns></returns>
        public bool ValidateToken(string tokenId)
        {
            db = new DatabaseEntities();
            var token = db.TokenMasters.Where(t => t.AuthToken == tokenId && t.ExpiredOn > DateTime.Now).FirstOrDefault();

            if (token != null && !(DateTime.Now > token.ExpiredOn))
            {
                token.ExpiredOn       = token.ExpiredOn.AddSeconds(Convert.ToDouble(ConfigurationManager.AppSettings["TokenExpiredOn"].ToString()));
                db.Entry(token).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                db.Dispose();
                return(true);
            }
            return(false);
        }
Beispiel #11
0
        //public UserService(DatabaseEntities _db, UserDetailDTO _user)
        //{
        //    db = _db;
        //    user = _user;
        //}

        public IQueryable<UserDTO> GetAllUser()
        {
            db = new DatabaseEntities();
            var User = db2.UserMasters.Select(o => new UserDTO
            {
                Id = o.Id,
                FirstName = o.FirstName,
                LastName = o.LastName,
                EmailAddress = o.EmailAddress,
                UserName = o.UserName,
                GroupName = o.UserGroupMaps.Select(s => new GroupDTO() { Id = s.GroupId, Name = s.GroupMaster.Name }).FirstOrDefault().Name,
                AccessType = o.EntityMaster.AccessTypeMaster.Name,
                StatusCode = o.StatusCode
            }).DefaultIfEmpty();
            db.Dispose();
            return User.OrderBy(o => o.FirstName);
        }
Beispiel #12
0
        public async Task <bool> Delete(Guid Id)
        {
            try
            {
                var deletedata = db.APIIntegrations.Where(o => o.Id == Id).FirstOrDefault();
                if (deletedata != null)
                {
                    db.APIIntegrations.Remove(deletedata);
                    await db.SaveChangesAsync();

                    db.Dispose();
                }
                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }
        }
Beispiel #13
0
        /// <summary>
        /// Delete tokens for the specific deleted user
        /// </summary>
        /// <param name="userId"></param>
        /// <returns>true for successful delete</returns>
        public bool DeleteByUserId(Guid userId)
        {
            try
            {
                db = new DatabaseEntities();
                var data = db.TokenMasters.Where(o => o.UserId == userId);
                if (data != null)
                {
                    db.TokenMasters.RemoveRange(data);
                    db.SaveChanges();
                    db.Dispose();
                }

                return(true);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(false);
            }
        }
Beispiel #14
0
        //public UserService(uTaxDBEntities _db, UserDetailDTO _user)
        //{
        //    db = _db;
        //    user = _user;
        //}

        public TokenDTO GenerateToken(Guid userId, string userip = "")
        {
            db = new DatabaseEntities();
            var tokenModel = new TokenDTO();

            if (userId != Guid.Empty)
            {
                string   token     = Guid.NewGuid().ToString();
                DateTime issuedOn  = DateTime.Now;
                DateTime expiredOn = DateTime.Now.AddSeconds(Convert.ToDouble(ConfigurationManager.AppSettings["TokenExpiredOn"].ToString()));
                //  string hostName = Dns.GetHostName();
                string myIP = userip;// Dns.GetHostByName(hostName).AddressList[0].ToString();

                var tokendomain = new TokenMaster
                {
                    UserId     = userId,
                    AuthToken  = token,
                    IssuedOn   = issuedOn,
                    ExpiredOn  = expiredOn,
                    IPAddress  = myIP,
                    StatusCode = EMPConstants.Active
                };

                db.TokenMasters.Add(tokendomain);
                db.SaveChanges();
                db.Dispose();

                tokenModel = new TokenDTO()
                {
                    UserId     = userId,
                    IssuedOn   = issuedOn,
                    ExpiredOn  = expiredOn,
                    AuthToken  = token,
                    StatusCode = EMPConstants.Active
                };
            }

            return(tokenModel);
        }
Beispiel #15
0
 /// <summary>
 /// Method to kill the provided token id.
 /// </summary>
 /// <param name="tokenId">true for successful delete</param>
 public bool Kill(string TokenId)
 {
     // GroupRoleMap _GroupRoleMap = new GroupRoleMap();
     try
     {
         db = new DatabaseEntities();
         var data = db.TokenMasters.Where(o => o.AuthToken == TokenId).FirstOrDefault();
         if (data != null)
         {
             //db.TokenMasters.Remove(data);
             data.ExpiredOn       = data.ExpiredOn.AddMinutes(-Convert.ToDouble(ConfigurationManager.AppSettings["TokenExpiredOn"].ToString()));
             data.StatusCode      = "INA";
             db.Entry(data).State = EntityState.Modified;
             db.SaveChanges();
             db.Dispose();
         }
         return(true);
     }
     catch (DbUpdateConcurrencyException)
     {
         return(false);
     }
 }
        public bool ActivateCustomer(Guid CustomerId, Guid UserId)
        {
            try
            {
                db = new DatabaseEntities();

                emp_CustomerInformation model = new emp_CustomerInformation();
                model = db.emp_CustomerInformation.Where(a => a.Id == CustomerId).FirstOrDefault();

                if (model != null)
                {
                    model.IsActivationCompleted = 1;
                    model.AccountStatus         = "Active";
                    model.LastUpdatedBy         = UserId;
                    model.LastUpdatedDate       = DateTime.Now;
                    db.Entry(model).State       = System.Data.Entity.EntityState.Modified;
                }

                try
                {
                    db.SaveChanges();
                    db.Dispose();
                    return(true);
                }
                catch (Exception ex)
                {
                    ExceptionLogger.LogException(ex.ToString(), "Configuration/ActivateCustomer", UserId);
                    return(false);
                }
            }
            catch (Exception ex)
            {
                ExceptionLogger.LogException(ex.ToString(), "Configuration/ActivateCustomer", UserId);
                return(false);
            }
        }
Beispiel #17
0
        /// <summary>
        /// This method is used to Save the main office details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int Save(SubSiteFeesDTO dto)
        {
            int entityState = 0;
            int iretval     = 0;

            List <SubSiteFeeConfig> subsitefeeconfigs = new List <SubSiteFeeConfig>();

            try
            {
                if (dto != null)
                {
                    Guid newguid2 = Guid.NewGuid();

                    bool IsRefId = Guid.TryParse(dto.refId, out newguid2);
                    if (IsRefId)
                    {
                        var SubSiteFeeConfig = db.SubSiteFeeConfigs.Where(o => o.emp_CustomerInformation_ID == newguid2).ToList();
                        if (SubSiteFeeConfig.Count() > 0)
                        {
                            db.SubSiteFeeConfigs.RemoveRange(SubSiteFeeConfig);
                            db.SaveChanges();
                        }

                        var subsiteBankFeeconfig = db.SubSiteBankFeesConfigs.Where(o => o.emp_CustomerInformation_ID == newguid2).ToList();
                        if (subsiteBankFeeconfig.Count() > 0)
                        {
                            db.SubSiteBankFeesConfigs.RemoveRange(subsiteBankFeeconfig);
                            db.SaveChanges();
                        }
                    }

                    foreach (var item in dto.SubsiteFees)
                    {
                        SubSiteFeeConfig subsitefeeconfig = new SubSiteFeeConfig();

                        subsitefeeconfig.ID = Guid.NewGuid();
                        entityState         = (int)System.Data.Entity.EntityState.Added;
                        SaveBankDetail(item.SubSiteBankFees, subsitefeeconfig.ID, newguid2, item.UserId ?? Guid.Empty);
                        subsitefeeconfig.emp_CustomerInformation_ID = newguid2; // newguid;
                        subsitefeeconfig.IsAddOnFeeCharge           = item.IsAddOnFeeCharge;

                        if (subsitefeeconfig.IsAddOnFeeCharge)
                        {
                            subsitefeeconfig.IsSameforAll = item.IsSameforAll;
                        }
                        else
                        {
                            subsitefeeconfig.IsSameforAll = false;
                        }

                        subsitefeeconfig.IsSubSiteAddonFee     = item.IsSubSiteAddonFee;
                        subsitefeeconfig.ServiceorTransmission = item.ServiceorTransmission;
                        subsitefeeconfig.StatusCode            = EMPConstants.Active;
                        subsitefeeconfig.LastUpdatedBy         = item.UserId ?? Guid.Empty;
                        subsitefeeconfig.LastUpdatedDate       = System.DateTime.Now;

                        if (entityState == (int)System.Data.Entity.EntityState.Added)
                        {
                            subsitefeeconfig.CreatedBy   = item.UserId ?? Guid.Empty;
                            subsitefeeconfig.CreatedDate = System.DateTime.Now;
                            subsitefeeconfigs.Add(subsitefeeconfig);
                        }
                        else
                        {
                            // For Sub-Site Fee Changes
                            if (subsitefeeconfig.IsSameforAll)
                            {
                                var childRecord = db.emp_CustomerInformation.Where(o => o.ParentId == subsitefeeconfig.emp_CustomerInformation_ID && o.IsActivationCompleted != 1).Select(o => new { o.Id, o.IsActivationCompleted }).ToList();
                                // var IsActiveChild = childRecord.ToList().Where(o => o.IsActivationCompleted == 1).Any();
                                //if (!IsActiveChild)
                                //{
                                foreach (var ChildItem in childRecord)
                                {
                                    var subsitebankfees = db.SubSiteBankFeesConfigs.Where(o => o.emp_CustomerInformation_ID == ChildItem.Id).ToList();
                                    foreach (var subsitebankfeeItem in subsitebankfees)
                                    {
                                        var ParentSubSiteBankFees = item.SubSiteBankFees.Where(o => o.BankMaster_ID == subsitebankfeeItem.BankMaster_ID.ToString()).FirstOrDefault();
                                        if (ParentSubSiteBankFees != null)
                                        {
                                            subsitebankfeeItem.BankMaxFees     = ParentSubSiteBankFees.BankMaxFees;
                                            subsitebankfeeItem.BankMaxFees_MSO = ParentSubSiteBankFees.BankMaxFees_MSO ?? 0;

                                            db.Entry(subsitebankfeeItem).State = System.Data.Entity.EntityState.Modified;
                                            db.SaveChanges();
                                        }
                                    }
                                }
                            }

                            db.Entry(subsitefeeconfig).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                }
                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    db.SubSiteFeeConfigs.AddRange(subsitefeeconfigs);
                    db.SaveChanges();
                }

                db.Dispose();

                return(1);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "SubSiteFeeService/GetSubSiteBankFeeById", dto.UserId);
                iretval = 0;
                return(iretval);

                throw;
            }
        }
Beispiel #18
0
 public void Dispose()
 {
     db.Dispose();
     throw new NotImplementedException();
 }
        /// <summary>
        /// This method is used to save and update the Sub Site Office Configuration Details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public Guid SaveSubSiteOfficeConfigInfo(SubSiteOfficeConfigDTO dto)
        {
            db = new DatabaseEntities();
            Guid MyId                 = Guid.Empty;
            int  entityState          = 0;
            bool prevBS               = false;
            SubSiteOfficeConfig model = new SubSiteOfficeConfig();

            if (dto != null)
            {
                Guid Id, refId;
                if (Guid.TryParse(dto.Id, out Id))
                {
                    model = db.SubSiteOfficeConfigs.Where(a => a.Id == Id).FirstOrDefault();
                    if (model != null)
                    {
                        prevBS      = model.HasBusinessSoftware;
                        entityState = (int)System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        return(Guid.Empty);
                    }
                }
                else
                {
                    model.Id    = Guid.NewGuid();
                    entityState = (int)System.Data.Entity.EntityState.Added;
                }

                bool IsRefId = Guid.TryParse(dto.RefId, out refId);
                if (!IsRefId)
                {
                    return(Guid.Empty);
                }
                model.RefId = refId;
                model.EFINListedOtherOffice = dto.EFINListedOtherOffice ?? false;
                model.SiteOwnthisEFIN       = dto.SiteOwnthisEFIN ?? false;
                model.EFINOwnerSite         = dto.EFINOwnerSite;
                int SOorSSorEFIN = 0;
                if (int.TryParse(dto.SOorSSorEFIN, out SOorSSorEFIN))
                {
                    model.SOorSSorEFIN = SOorSSorEFIN;
                }
                else
                {
                    return(Guid.Empty);
                }

                model.CanSubSiteLoginToEmp = true;
                model.SubSiteSendTaxReturn = dto.SubSiteSendTaxReturn ?? false;
                model.SiteanMSOLocation    = dto.SiteanMSOLocation ?? false;
                model.LastUpdatedBy        = dto.UserId ?? Guid.Empty;
                model.LastUpdatedDate      = System.DateTime.Now;

                ///// Main Site Data
                model.IsMainSiteTransmitTaxReturn = dto.IsMainSiteTransmitTaxReturn;
                model.NoofTaxProfessionals        = dto.NoofTaxProfessionals;
                model.IsSoftwareOnNetwork         = dto.IsSoftwareOnNetwork;
                model.NoofComputers       = dto.NoofComputers;
                model.PreferredLanguage   = dto.PreferredLanguage;
                model.HasBusinessSoftware = dto.IsBusinessSoftware;
                model.IsSharingEFIN       = dto.IsSharingEFIN;

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

                //var enrollconfig = db.EnrollmentOfficeConfigurations.Where(x => x.CustomerId == refId && x.StatusCode == EMPConstants.Active).FirstOrDefault();
                //if (enrollconfig != null)
                //{
                //    enrollconfig.IsSoftwareOnNetwork = dto.IsSoftwareOnNetwork;
                //    enrollconfig.LastUpdatedBy = dto.UserId ?? Guid.Empty;
                //    enrollconfig.LastUpdatedDate = DateTime.Now;
                //    enrollconfig.NoofComputers = dto.NoofComputers;
                //    enrollconfig.NoofTaxProfessionals = dto.NoofTaxProfessionals;
                //    enrollconfig.PreferredLanguage = dto.PreferredLanguage;
                //}

                //if (model.SOorSSorEFIN == 3 && model.LastUpdatedBy != Guid.Empty)
                //{
                //    var emp_Info = db.emp_CustomerInformation.Where(o => o.Id == dto.UserId).FirstOrDefault();
                //    if (emp_Info != null)
                //    {
                //        emp_Info.IsAdditionalEFINAllowed = true;
                //        db.Entry(emp_Info).State = System.Data.Entity.EntityState.Modified;
                //    }
                //}


                var emp_MyInfo = db.emp_CustomerInformation.Where(o => o.Id == refId).FirstOrDefault();
                if (emp_MyInfo != null)
                {
                    var emp_ParentInfo = db.emp_CustomerInformation.Where(o => o.Id == emp_MyInfo.ParentId).FirstOrDefault();
                    if (emp_ParentInfo != null)
                    {
                        MyId = emp_MyInfo.Id;

                        if (emp_ParentInfo.EntityId == (int)EMPConstants.Entity.MO)
                        {
                            if (model.SOorSSorEFIN == 1)
                            {
                                emp_MyInfo.EROType  = "Multi Office - Single Office";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.MO_SO;
                            }
                            else if (model.SOorSSorEFIN == 3)
                            {
                                emp_MyInfo.EROType  = "Multi Office - Additional EFIN";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.MO_AE;
                            }
                        }
                        else if (emp_ParentInfo.EntityId == (int)EMPConstants.Entity.SVB_MO)
                        {
                            if (model.SOorSSorEFIN == 1)
                            {
                                emp_MyInfo.EROType  = "Service Bureau - Multi Office - Single Office";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.SVB_MO_SO;
                            }
                            else if (model.SOorSSorEFIN == 3)
                            {
                                emp_MyInfo.EROType  = "Service Bureau - Multi Office - Additional EFIN";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.SVB_MO_AE;
                            }
                        }
                        else if (emp_ParentInfo.EntityId == (int)EMPConstants.Entity.SVB)
                        {
                            if (model.SOorSSorEFIN == 1)
                            {
                                emp_MyInfo.EROType  = "Service Bureau - Single Office";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.SVB_SO;
                            }
                            else if (model.SOorSSorEFIN == 2)
                            {
                                emp_MyInfo.EROType  = "Service Bureau - Multi Office";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.SVB_MO;
                            }
                            else if (model.SOorSSorEFIN == 3)
                            {
                                emp_MyInfo.EROType  = "Service Bureau - Additional EFIN";
                                emp_MyInfo.EntityId = (int)EMPConstants.Entity.SVB_AE;
                            }
                        }

                        if (model.SOorSSorEFIN == 3)
                        {
                            emp_MyInfo.IsAdditionalEFINAllowed = true;
                        }

                        if (emp_MyInfo.EFINStatus == (int)EMPConstants.EFINStatus_ForSub.Sharing && model.SiteOwnthisEFIN == false)
                        {
                            var UserId = model.EFINOwnerSite;
                            if (!string.IsNullOrEmpty(UserId))
                            {
                                var UserMain = (from emp in db.emp_CustomerInformation
                                                join emplog in db.emp_CustomerLoginInformation
                                                on emp.Id equals emplog.CustomerOfficeId
                                                where emplog.EMPUserId == UserId
                                                select new { emp.EFIN }).FirstOrDefault();

                                if (UserMain != null)
                                {
                                    emp_MyInfo.EFIN = UserMain.EFIN ?? 0;
                                }
                            }
                        }

                        db.Entry(emp_MyInfo).State = System.Data.Entity.EntityState.Modified;
                    }

                    if (emp_MyInfo.IsActivationCompleted == 1)
                    {
                        if (prevBS != dto.IsBusinessSoftware && dto.IsBusinessSoftware)
                        {
                            var loginfo = db.emp_CustomerLoginInformation.Where(x => x.CustomerOfficeId == refId).FirstOrDefault();

                            var sy = db.SalesYearMasters.Where(x => x.Id == emp_MyInfo.SalesYearID).Select(x => x.SalesYear).FirstOrDefault();
                            CustomerInformationService cis = new CustomerInformation.CustomerInformationService();
                            cis.SaveEmpCsrData(refId, "Business Software", emp_MyInfo.SalesforceAccountID, sy.Value.ToString());

                            EmailNotification _email = new EmailNotification();
                            _email.CreatedBy    = dto.UserId ?? Guid.Empty;
                            _email.CreatedDate  = DateTime.Now;
                            _email.EmailCC      = "";
                            _email.EmailContent = "";
                            _email.EmailSubject = "Business Software";
                            _email.EmailTo      = EMPConstants.SupportutaxEmail;
                            _email.EmailType    = (int)EMPConstants.EmailTypes.BusinessSoftware;
                            _email.IsSent       = false;
                            _email.Parameters   = loginfo.EMPUserId + "$|$" + loginfo.MasterIdentifier + "$|$" + dto.IsBusinessSoftware;
                            db.EmailNotifications.Add(_email);
                        }
                    }
                    if (prevBS != dto.IsBusinessSoftware && dto.IsBusinessSoftware && emp_MyInfo.EntityId != (int)EMPConstants.Entity.SO)
                    {
                        var loginfo    = db.emp_CustomerLoginInformation.Where(x => x.CustomerOfficeId == refId).FirstOrDefault();
                        var parentinfo = db.emp_CustomerInformation.Where(x => x.Id == emp_MyInfo.ParentId).FirstOrDefault();
                        var parentsb   = db.MainOfficeConfigurations.Where(x => x.emp_CustomerInformation_ID == emp_MyInfo.ParentId).Select(x => x.HasBusinessSoftware).FirstOrDefault();
                        if (parentinfo != null)
                        {
                            if (parentinfo.QuoteSoftwarePackage != EMPConstants.EnterprisePackage && !parentsb)
                            {
                                EmailNotification _email = new EmailNotification();
                                _email.CreatedBy    = dto.UserId ?? Guid.Empty;
                                _email.CreatedDate  = DateTime.Now;
                                _email.EmailCC      = "";
                                _email.EmailContent = "";
                                _email.EmailSubject = "Business Software";
                                _email.EmailTo      = EMPConstants.accountutaxEmail;
                                _email.EmailType    = (int)EMPConstants.EmailTypes.BusinessSoftware;
                                _email.IsSent       = false;
                                _email.Parameters   = loginfo.EMPUserId + "$|$" + loginfo.MasterIdentifier + "$|$" + dto.IsBusinessSoftware;
                                db.EmailNotifications.Add(_email);
                            }
                        }
                    }
                }
            }

            try
            {
                db.SaveChanges();
                db.Dispose();

                if (MyId != Guid.Empty)
                {
                    DropDownService ddService = new DropDownService();
                    var             items     = ddService.GetBottomToTopHierarchy(MyId);
                }

                return(model.Id);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/SaveSubSiteOfficeConfigInfo", Guid.Empty);
                return(Guid.Empty);
            }
        }
Beispiel #20
0
        public PaymentOptionResponse Save(CustomerPaymentInfo info)
        {
            PaymentOptionResponse res = new PaymentOptionResponse();

            try
            {
                CustomerPaymentOption CPO = new CustomerPaymentOption();
                bool isNew = true;

                Guid userid, oldid;
                if (Guid.TryParse(info.Id, out oldid) && info.Id != Guid.Empty.ToString())
                {
                    CPO = db.CustomerPaymentOptions.Where(a => a.Id == oldid).FirstOrDefault();
                    if (CPO != null)
                    {
                        isNew = false;
                    }
                    else
                    {
                        res.status = false;
                    }
                }
                else
                {
                    CPO.Id = Guid.NewGuid();
                }
                bool IsRefId = Guid.TryParse(info.UserId, out userid);

                CPO.IsSameasBankAccount = info.IsSameBankAccount;
                CPO.PaymentType         = info.PaymentType;
                if (isNew)
                {
                    Guid CustId;
                    var  customerid = db.emp_CustomerLoginInformation.Where(x => x.Id == userid).Select(x => x.CustomerOfficeId).FirstOrDefault();
                    bool IsCustId   = Guid.TryParse(customerid.ToString(), out CustId);

                    CPO.CreatedBy   = userid;
                    CPO.BankId      = info.BankId;
                    CPO.CreatedDate = DateTime.Now;
                    CPO.CustomerId  = userid;
                    CPO.SiteType    = info.SiteType;
                    db.CustomerPaymentOptions.Add(CPO);
                }
                else
                {
                    CPO.BankId      = info.BankId;
                    CPO.UpdatedBy   = userid;
                    CPO.UpdatedDate = DateTime.Now;
                    if (info.IsSameBankAccount == 2 && info.PaymentType == 2)
                    {
                        var ach = (from s in db.CustomerPaymentViaACHes
                                   where s.PaymentOptionId == CPO.Id
                                   select s).FirstOrDefault();
                        if (ach != null)
                        {
                            db.CustomerPaymentViaACHes.Remove(ach);
                        }
                    }
                }
                db.SaveChanges();
                db.Dispose();
                res.status = true;
                res.Id     = CPO.Id.ToString();
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerPaymentOptionsService/Save", Guid.Empty);
                res.status = false;
            }
            return(res);
        }
Beispiel #21
0
        public async Task<int> SaveUser(UserDetailDTO _user, Guid Id, int EntityState)
        {
            UserMaster usermaster = new UserMaster();
            string Password = "";

            if (_user != null)
            {
                if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    var Existuser = db.UserMasters.Where(o => o.Id != Id && o.UserName == _user.UserName).Any();
                    if (Existuser)
                        return -1;

                    usermaster = db.UserMasters.Where(o => o.Id == Id).FirstOrDefault();
                }
                else
                {
                    var Existuser = db.UserMasters.Where(o => o.UserName == _user.UserName).Any();
                    if (Existuser)
                        return -1;
                    Password = GetRandomPassword();
                    usermaster.Password = PasswordManager.CryptText(Password); //"admin1"

                }
                //usermaster.Id = "";
                usermaster.Id = Id;
                usermaster.EntityId = _user.EntityId;
                usermaster.CustomerId = _user.CustomerId;
                usermaster.FirstName = _user.FirstName;
                usermaster.LastName = _user.LastName;
                // usermaster.MiddleName = _user.MiddleName;
                usermaster.UserName = _user.UserName;

                usermaster.EmailAddress = _user.EmailAddress;
                usermaster.IsEmailConfirmed = _user.IsEmailConfirmed;
                usermaster.EmailConfirmationCode = _user.EmailConfirmationCode;
                usermaster.PasswordResetCode = _user.PasswordResetCode;

                usermaster.LastLoginDate = _user.LastLoginDate;
                usermaster.IsActive = true;
                usermaster.IsActiveDate = DateTime.Now;
                usermaster.StatusCode = EMPConstants.Active;

                if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                {

                    usermaster.CreatedBy = _user.UserId;
                    usermaster.CreatedDate = DateTime.Now;
                    usermaster.LastUpdatedDate = DateTime.Now;
                    usermaster.LastUpdatedBy = _user.UserId;
                    db.Entry(usermaster).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    usermaster.LastUpdatedDate = DateTime.Now;
                    usermaster.LastUpdatedBy = _user.UserId;
                    db.UserMasters.Add(usermaster);

                    EmailNotification _email = new EmailNotification();
                    _email.CreatedBy = _user.UserId;
                    _email.CreatedDate = DateTime.Now;
                    _email.EmailCC = "";
                    _email.EmailContent = "";
                    _email.EmailSubject = EMPConstants.NewUserMailSubject;
                    _email.EmailTo = _user.EmailAddress;
                    _email.EmailType = (int)EMPConstants.EmailTypes.NewAdminUser;
                    _email.IsSent = false;
                    _email.Parameters = _user.UserName + "$|$" + Password;
                    db.EmailNotifications.Add(_email);
                }


                // User Group Mapping Saving
                UserGroupMap usergroup = new UserGroupMap();

                UserGroupMapDTO UserGroupMapDto = await _UserGroupService.GetByUserId(usermaster.Id);
                bool IsNewGroup = true;
                if (UserGroupMapDto != null)
                {
                    if (UserGroupMapDto.Id != Guid.Empty)
                    {
                        IsNewGroup = false;
                        usergroup.Id = UserGroupMapDto.Id;
                        usergroup.GroupId = _user.Groups.Id;
                        usergroup.UserId = usermaster.Id;
                        usergroup.StatusCode = EMPConstants.Active;
                        db.Entry(usergroup).State = System.Data.Entity.EntityState.Modified;
                    }
                }

                if (IsNewGroup)
                {
                    usergroup.Id = Guid.NewGuid();
                    usergroup.GroupId = _user.Groups.Id;
                    usergroup.UserId = usermaster.Id;
                    usergroup.StatusCode = EMPConstants.Active;
                    db.UserGroupMaps.Add(usergroup);
                }

                if (_user.Roles.ToList().Count > 0)
                {
                    if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                    {
                        var UserRole1 = db.UserRolesMaps.Where(o => o.UserId == _user.Id).ToList();
                        if (UserRole1.Count() > 0)
                            db.UserRolesMaps.RemoveRange(UserRole1);
                    }

                    List<UserRolesMap> _UserRolesMapList = new List<UserRolesMap>();
                    foreach (RoleDTO Role in _user.Roles)
                    {
                        UserRolesMap _UserRolesMap = new UserRolesMap();
                        _UserRolesMap.Id = Guid.NewGuid();
                        _UserRolesMap.UserId = usermaster.Id;
                        _UserRolesMap.RoleId = Role.Id;
                        _UserRolesMap.StatusCode = EMPConstants.Active;
                        _UserRolesMapList.Add(_UserRolesMap);
                    }

                    db.UserRolesMaps.AddRange(_UserRolesMapList);
                }
            }

            try
            {

                await db.SaveChangesAsync();
                db.Dispose();

                return 1;
            }

            catch (DbUpdateConcurrencyException)
            {
                return 0;
            }
        }
        /// <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);
            }
        }
        /// <summary>
        /// This method is used to save and update the Enrollment Affiliate Configuration Detail
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int SaveEnrollmentOfficeConfig(EnrollmentOfficeConfigDTO dto)
        {
            // int entityState = 0;

            EnrollmentOfficeConfiguration model = new EnrollmentOfficeConfiguration();

            if (dto != null)
            {
                Guid Id, UserId, CustomerId;
                int  entityState = (int)System.Data.Entity.EntityState.Added;
                if (!Guid.TryParse(dto.CustomerId.ToString(), out CustomerId))
                {
                    return(-1);
                }
                if (!Guid.TryParse(dto.UserId.ToString(), out UserId))
                {
                    return(-1);
                }
                if (dto.Id != null)
                {
                    if (!Guid.TryParse(dto.Id.ToString(), out Id))
                    {
                        return(-1);
                    }

                    entityState = (int)System.Data.Entity.EntityState.Modified;

                    if (Id == Guid.Empty)
                    {
                        Id       = Guid.NewGuid();
                        model.Id = Id;
                    }
                }
                else
                {
                    Id       = Guid.NewGuid();
                    model.Id = Id;
                }

                if (entityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    model = db.EnrollmentOfficeConfigurations.Where(a => a.Id == dto.Id).FirstOrDefault();
                    if (model == null)
                    {
                        return(-1);
                    }
                }
                model.CustomerId = CustomerId;
                model.IsMainSiteTransmitTaxReturn = dto.IsMainSiteTransmitTaxReturn;
                model.NoofComputers        = dto.NoofComputers;
                model.NoofTaxProfessionals = dto.NoofTaxProfessionals;
                model.NoofTaxProfessionals = dto.NoofTaxProfessionals;
                model.PreferredLanguage    = dto.PreferredLanguage;
                model.IsSoftwareOnNetwork  = dto.IsSoftwareOnNetwork;
                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.EnrollmentOfficeConfigurations.Add(model);
                }
                else
                {
                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                }

                var custInfo = db.emp_CustomerInformation.Where(x => x.Id == CustomerId).FirstOrDefault();
                if (custInfo.EntityId == (int)EMPConstants.Entity.MO || custInfo.EntityId == (int)EMPConstants.Entity.SVB)
                {
                    var accountconfig = db.MainOfficeConfigurations.Where(x => x.emp_CustomerInformation_ID == CustomerId && x.StatusCode == EMPConstants.Active).FirstOrDefault();
                    if (accountconfig != null)
                    {
                        accountconfig.ComputerswillruninSoftware   = dto.NoofComputers ?? 0;
                        accountconfig.IsSoftwarebeInstalledNetwork = dto.IsSoftwareOnNetwork ?? false;
                        accountconfig.LastUpdatedBy            = dto.UserId ?? Guid.Empty;
                        accountconfig.LastUpdatedDate          = DateTime.Now;
                        accountconfig.PreferredSupportLanguage = dto.PreferredLanguage ?? 0;
                        accountconfig.TaxProfessionals         = dto.NoofTaxProfessionals ?? 0;
                    }
                }
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(1);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "EnrollmentOfficeConfigService/SaveEnrollmentOfficeConfig", Guid.Empty);
                return(-1);
            }
        }
        /// <summary>
        /// This method is used to save and update the Sub Site Office Configuration Details
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public async Task <int> SaveSubSiteOfficeAffiProgConfig(SubSiteOfficeAffiliateProgramConfigDTO dto)
        {
            int entityState = 0;

            SubSiteOfficeAffiliateProgramConfig model = new SubSiteOfficeAffiliateProgramConfig();

            if (dto != null)
            {
                int  Id;
                Guid refId, AffiliateProgId;
                if (int.TryParse(dto.Id.ToString(), out Id))
                {
                    model = db.SubSiteOfficeAffiliateProgramConfigs.Where(a => a.Id == Id).FirstOrDefault();
                    if (model != null)
                    {
                        entityState = (int)System.Data.Entity.EntityState.Modified;
                    }
                    else
                    {
                        return(-1);
                    }
                }
                else
                {
                    //model.Id = Guid.NewGuid();
                    entityState = (int)System.Data.Entity.EntityState.Added;
                }

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

                bool IsAffiliateProgId = Guid.TryParse(dto.AffiliateProgramId, out AffiliateProgId);
                if (!IsAffiliateProgId)
                {
                    return(-1);
                }

                model.CustomerInformation_Id = refId;
                model.AffiliateProgramId     = AffiliateProgId;
                model.AffiliateProgramCharge = dto.AffiliateProgramCharge;
                model.StatusCode             = EMPConstants.Active;

                if (entityState == (int)System.Data.Entity.EntityState.Added)
                {
                    model.CreatedBy   = dto.UserId ?? Guid.Empty;
                    model.CreatedDate = System.DateTime.Now;
                    db.SubSiteOfficeAffiliateProgramConfigs.Add(model);

                    //Guid SiteMapId;
                    //Guid.TryParse("2639fb0a-0caa-47cf-b315-587e7ce86aef", out SiteMapId);
                    //CustomerConfigurationStatu ConfigStatusModel = new CustomerConfigurationStatu();
                    //ConfigStatusModel.Id = Guid.NewGuid();
                    //ConfigStatusModel.CustomerId = dto.UserId ?? Guid.Empty;
                    //ConfigStatusModel.SitemapId = SiteMapId;
                    //ConfigStatusModel.StatusCode = "done";
                    //ConfigStatusModel.UpdatedBy = dto.UserId ?? Guid.Empty;
                    //ConfigStatusModel.UpdatedDate = DateTime.Now;
                    //db.CustomerConfigurationStatus.Add(ConfigStatusModel);
                }
                else
                {
                    model.LastUpdatedBy   = dto.UserId ?? Guid.Empty;
                    model.LastUpdatedDate = System.DateTime.Now;

                    db.Entry(model).State = System.Data.Entity.EntityState.Modified;
                }
            }
            try
            {
                await db.SaveChangesAsync();

                db.Dispose();
                return(model.Id);
            }
            catch (Exception ex)
            {
                return(-1);

                throw;
            }
        }
        /// <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;
            }
        }
Beispiel #26
0
        public async Task <int> Save(BankMasterDTO _Dto, Guid Id, int EntityState)
        {
            BankMaster bankmaster = new BankMaster();

            if (_Dto != null)
            {
                bankmaster.Id                  = Id;
                bankmaster.BankName            = _Dto.BankName;
                bankmaster.BankServiceFees     = _Dto.BankServiceFees;
                bankmaster.MaxFeeLimitDeskTop  = _Dto.MaxFeeLimitDeskTop;
                bankmaster.MaxTranFeeDeskTop   = _Dto.MaxTranFeeDeskTop;
                bankmaster.MaxFeeLimitMSO      = _Dto.MaxFeeLimitMSO;
                bankmaster.MaxTranFeeMSO       = _Dto.MaxTranFeeMSO;
                bankmaster.ActivatedDate       = _Dto.ActivatedDate;
                bankmaster.BankProductDocument = _Dto.BankProductDocument;
                bankmaster.DeActivatedDate     = _Dto.DeActivatedDate;
                bankmaster.Description         = _Dto.Description;
                bankmaster.StatusCode          = EMPConstants.Active;
                bankmaster.BankCode            = _Dto.BankCode;
            }

            if (EntityState == (int)System.Data.Entity.EntityState.Modified)
            {
                var ExistBank = db.BankMasters.Where(o => o.Id != Id && o.BankName == _Dto.BankName).Any();
                if (ExistBank)
                {
                    return(-1);
                }

                bankmaster.LastUpdatedDate = DateTime.Now;
                bankmaster.LastUpdatedBy   = _Dto.UserId;
                db.Entry(bankmaster).State = System.Data.Entity.EntityState.Modified;
            }
            else
            {
                var ExistBank = db.BankMasters.Where(o => o.BankName == _Dto.BankName).Any();
                if (ExistBank)
                {
                    return(-1);
                }
                bankmaster.CreatedBy       = _Dto.UserId;
                bankmaster.CreatedDate     = DateTime.Now;
                bankmaster.LastUpdatedDate = DateTime.Now;
                bankmaster.LastUpdatedBy   = _Dto.UserId;
                db.BankMasters.Add(bankmaster);
            }


            if (_Dto.Entities.ToList().Count > 0)
            {
                if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    var MapData = db.BankEntityMaps.Where(o => o.BankId == Id).ToList();

                    if (MapData.Count() > 0)
                    {
                        db.BankEntityMaps.RemoveRange(MapData);
                    }
                }

                List <BankEntityMap> _BankEntityMapsList = new List <BankEntityMap>();
                foreach (EntityDTO item in _Dto.Entities)
                {
                    BankEntityMap _BankEntityMap = new BankEntityMap();
                    _BankEntityMap.Id       = Guid.NewGuid();
                    _BankEntityMap.BankId   = bankmaster.Id;
                    _BankEntityMap.EntityId = item.Id;
                    _BankEntityMapsList.Add(_BankEntityMap);
                }

                db.BankEntityMaps.AddRange(_BankEntityMapsList);
            }

            try
            {
                await db.SaveChangesAsync();

                db.Dispose();
                return(1);
            }

            catch (DbUpdateConcurrencyException)
            {
                return(0);
            }
        }
Beispiel #27
0
 public void Dispose()
 {
     db.Dispose();
 }
Beispiel #28
0
        public async Task <int> Save(FeesDTO _Dto, Guid Id, int EntityState)
        {
            FeeMaster _FeeMaster = new FeeMaster();

            if (_Dto != null)
            {
                _FeeMaster.Id            = Id;
                _FeeMaster.Name          = _Dto.Name;
                _FeeMaster.FeeType       = _Dto.FeeType;
                _FeeMaster.FeeCategoryID = _Dto.FeeCategoryID;
                _FeeMaster.IsIncludedMaxAmtCalculation = _Dto.IsIncludedMaxAmtCalculation;
                _FeeMaster.SalesforceFeesFieldID       = _Dto.SalesforceFeesFieldID;
                if (_FeeMaster.FeeType == EMPConstants.Fixedamount)
                {
                    _FeeMaster.FeeTypeId = 1;
                }
                if (_FeeMaster.FeeType == EMPConstants.Useramount)
                {
                    _FeeMaster.FeeTypeId = 2;
                }
                if (_FeeMaster.FeeType == EMPConstants.SalesForce)
                {
                    _FeeMaster.FeeTypeId = 3;
                }
                _FeeMaster.Amount    = _Dto.Amount;
                _FeeMaster.FeeNature = _Dto.FeeNature;
                if (_FeeMaster.FeeNature == EMPConstants.Mandatory)
                {
                    _FeeMaster.FeeNatureId = 1;
                }
                if (_FeeMaster.FeeNature == EMPConstants.Optional)
                {
                    _FeeMaster.FeeNatureId = 2;
                }
                _FeeMaster.ActivatedDate   = DateTime.Now;
                _FeeMaster.DeActivatedDate = null;// _Dto.DeActivatedDate;
                _FeeMaster.NoteForUser     = _Dto.NoteForUser;
                _FeeMaster.Note            = _Dto.Note;

                _FeeMaster.StatusCode = EMPConstants.Active;
                int FeesFor = 0;
                if (int.TryParse(_Dto.FeesFor, out FeesFor))
                {
                    _FeeMaster.FeesFor = FeesFor;
                }
                else
                {
                    return(0);
                }
            }

            if (EntityState == (int)System.Data.Entity.EntityState.Modified)
            {
                var ExistFee = db.FeeMasters.Where(o => o.Id != Id && o.Name == _Dto.Name).Any();
                if (ExistFee)
                {
                    return(-1);
                }

                _FeeMaster.LastUpdatedDate = DateTime.Now;
                _FeeMaster.LastUpdatedBy   = _Dto.UserId;
                db.Entry(_FeeMaster).State = System.Data.Entity.EntityState.Modified;
            }
            else
            {
                var ExistFee = db.FeeMasters.Where(o => o.Name == _Dto.Name).Any();
                if (ExistFee)
                {
                    return(-1);
                }
                _FeeMaster.CreatedBy       = _Dto.UserId;
                _FeeMaster.CreatedDate     = DateTime.Now;
                _FeeMaster.LastUpdatedDate = DateTime.Now;
                _FeeMaster.LastUpdatedBy   = _Dto.UserId;
                db.FeeMasters.Add(_FeeMaster);
            }


            if (_Dto.Entities.ToList().Count > 0)
            {
                if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    var MapData = db.FeeEntityMaps.Where(o => o.FeeId == Id).ToList();

                    if (MapData.Count() > 0)
                    {
                        db.FeeEntityMaps.RemoveRange(MapData);
                    }
                }

                List <FeeEntityMap> _FeeEntityMapList = new List <FeeEntityMap>();
                foreach (EntityDTO item in _Dto.Entities)
                {
                    FeeEntityMap _FeeEntityMap = new FeeEntityMap();
                    _FeeEntityMap.Id       = Guid.NewGuid();
                    _FeeEntityMap.FeeId    = _FeeMaster.Id;
                    _FeeEntityMap.EntityId = item.Id;
                    _FeeEntityMapList.Add(_FeeEntityMap);
                }

                db.FeeEntityMaps.AddRange(_FeeEntityMapList);
            }

            try
            {
                await db.SaveChangesAsync();

                db.Dispose();
                return(1);
            }

            catch (DbUpdateConcurrencyException)
            {
                return(0);
            }
        }
        /// <summary>
        /// This method is used to save and update the Enrollment Affiliate Configuration Detail
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public int SaveEnrollmentAffiProgConfig(EnrollmentAffiliateConfigDetailDTO dto)
        {
            //int entityState = 0;

            Guid refId = Guid.Empty, UserId, AffiliateProgId;

            bool IsUserId = Guid.TryParse(dto.UserId.ToString(), out UserId);

            if (!IsUserId)
            {
                return(-1);
            }

            if (dto != null)
            {
                // entityState = (int)System.Data.Entity.EntityState.Added;

                foreach (EnrollmentAffiliateConfigDTO item in dto.Affiliates)
                {
                    EnrollmentAffiliateConfiguration model = new EnrollmentAffiliateConfiguration();

                    if (item != null)
                    {
                        bool IsRefId = Guid.TryParse(item.CustomerId.ToString(), out refId);
                        if (!IsRefId)
                        {
                            return(-1);
                        }

                        bool IsAffiliateProgId = Guid.TryParse(item.AffiliateProgramId, out AffiliateProgId);
                        if (!IsAffiliateProgId)
                        {
                            return(-1);
                        }

                        decimal AffiliateProgramCharge;
                        bool    IsAffiliateProgramCharge = decimal.TryParse(item.AffiliateProgramCharge.ToString(), out AffiliateProgramCharge);
                        if (!IsAffiliateProgramCharge)
                        {
                            AffiliateProgramCharge = 0;
                        }

                        model.Id                     = Guid.NewGuid();
                        model.CustomerId             = refId;
                        model.AffiliateProgramId     = AffiliateProgId;
                        model.AffiliateProgramCharge = AffiliateProgramCharge;
                        model.StatusCode             = EMPConstants.Active;

                        model.LastUpdatedBy   = UserId;
                        model.LastUpdatedDate = System.DateTime.Now;
                        model.CreatedBy       = UserId;
                        model.CreatedDate     = System.DateTime.Now;

                        db.EnrollmentAffiliateConfigurations.Add(model);

                        //if (entityState == (int)System.Data.Entity.EntityState.Added)
                        //{
                        //    Guid SiteMapId;
                        //    Guid.TryParse("2f7d1b90-78aa-4a93-85ec-81cd8b10a545", out SiteMapId);
                        //    CustomerConfigurationStatu ConfigStatusModel = new CustomerConfigurationStatu();
                        //    ConfigStatusModel.Id = Guid.NewGuid();
                        //    ConfigStatusModel.CustomerId = dto.UserId ?? Guid.Empty;
                        //    ConfigStatusModel.SitemapId = SiteMapId;
                        //    ConfigStatusModel.StatusCode = "done";
                        //    ConfigStatusModel.UpdatedBy = dto.UserId ?? Guid.Empty;
                        //    ConfigStatusModel.UpdatedDate = DateTime.Now;
                        //    db.CustomerConfigurationStatus.Add(ConfigStatusModel);
                        //}
                    }
                }

                var _AffiliateList = db.EnrollmentAffiliateConfigurations.Where(a => a.CustomerId == refId).ToList();
                if (_AffiliateList.ToList().Count > 0)
                {
                    db.EnrollmentAffiliateConfigurations.RemoveRange(_AffiliateList);
                }
            }
            try
            {
                db.SaveChanges();
                db.Dispose();
                return(1);
            }
            catch (Exception ex)
            {
                EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "EnrollmentAffiliateConfigService/SaveEnrollmentAffiProgConfig", Guid.Empty);
                return(-1);

                throw;
            }
        }
Beispiel #30
0
        public async Task <int> Save(GroupRoleDTO _dto, Guid Id, int EntityState)
        {
            try
            {
                GroupMaster groupMaster = new GroupMaster();
                if (_dto != null)
                {
                    groupMaster.Id         = Id;
                    groupMaster.Name       = _dto.GroupName;
                    groupMaster.StatusCode = EMPConstants.Active;
                }

                if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                {
                    var ExistGroup = db.GroupMasters.Where(o => o.Id != Id && o.Name == _dto.GroupName).Any();
                    if (ExistGroup)
                    {
                        return(-1);
                    }

                    groupMaster.LastUpdatedBy   = _dto.UserId;
                    groupMaster.LastUpdatedDate = DateTime.Now;
                    db.Entry(groupMaster).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    var ExistGroup = db.GroupMasters.Where(o => o.Name == _dto.GroupName).Any();
                    if (ExistGroup)
                    {
                        return(-1);
                    }

                    groupMaster.CreatedBy       = _dto.UserId;
                    groupMaster.CreatedDate     = DateTime.Now;
                    groupMaster.LastUpdatedBy   = _dto.UserId;
                    groupMaster.LastUpdatedDate = DateTime.Now;
                    db.GroupMasters.Add(groupMaster);
                }

                if (_dto.Roles.ToList().Count > 0)
                {
                    if (EntityState == (int)System.Data.Entity.EntityState.Modified)
                    {
                        var GroupRoleMapDel = db.GroupRoleMaps.Where(o => o.GroupId == Id).DefaultIfEmpty();
                        if (GroupRoleMapDel != null)
                        {
                            db.GroupRoleMaps.RemoveRange(GroupRoleMapDel);
                        }
                    }

                    List <GroupRoleMap> _GroupRoleMapList = new List <GroupRoleMap>();
                    foreach (RoleDTO item in _dto.Roles)
                    {
                        GroupRoleMap _GroupRoleMap = new GroupRoleMap();
                        _GroupRoleMap.Id      = Guid.NewGuid();
                        _GroupRoleMap.GroupId = groupMaster.Id;
                        _GroupRoleMap.RoleId  = item.Id;
                        _GroupRoleMapList.Add(_GroupRoleMap);
                    }

                    db.GroupRoleMaps.AddRange(_GroupRoleMapList);
                }

                await db.SaveChangesAsync();

                db.Dispose();

                return(1);
            }
            catch (DbUpdateConcurrencyException)
            {
                return(0);
            }
        }