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); } }
public int Save(CustomerLoginInformationModel model) { int entityState = 0; emp_CustomerLoginInformation customerLoginInformation = new emp_CustomerLoginInformation(); if (model != null) { Guid newguid1; Guid CustomerOfficeId = model.CustomerOfficeId ?? Guid.Empty; if (Guid.TryParse(model.Id, out newguid1)) { //var ExistCust = db.emp_CustomerLoginInformation.Any(a => a.EFIN == model.EFIN && a.Id != newguid1); //if (ExistCust) // return -1; //11212016 - If int EFIN = model.EFIN ?? 0; if (EFIN > 0 && (model.EFINStatus == 16 || model.EFINStatus == 19)) { //if (CustomerOfficeId != Guid.Empty) //{ var ExistCust = db.emp_CustomerInformation.Any(a => a.EFIN == model.EFIN && a.Id != CustomerOfficeId); if (ExistCust) { return(-1); } //} } var ExistCrossCust = db.emp_CustomerLoginInformation.Any(a => a.CrossLinkUserId == model.CrossLinkUserId && a.Id != newguid1); if (ExistCrossCust) { return(-2); } } if (string.IsNullOrEmpty(model.Id)) { customerLoginInformation.Id = Guid.NewGuid(); } else { Guid newguid; if (Guid.TryParse(model.Id, out newguid)) { customerLoginInformation.Id = newguid; entityState = (int)System.Data.Entity.EntityState.Modified; } } // customerLoginInformation.EFIN = model.EFIN; customerLoginInformation.MasterIdentifier = model.MasterIdentifier; customerLoginInformation.CrossLinkUserId = model.CrossLinkUserId; customerLoginInformation.CrossLinkPassword = PasswordManager.CryptText(model.CrossLinkPassword);// model.CrossLinkPassword; customerLoginInformation.OfficePortalUrl = model.OfficePortalUrl; customerLoginInformation.TaxOfficeUsername = model.TaxOfficeUsername; customerLoginInformation.TaxOfficePassword = PasswordManager.CryptText(model.TaxOfficePassword); // model.TaxOfficePassword; customerLoginInformation.CustomerOfficeId = model.CustomerOfficeId; customerLoginInformation.EMPPassword = PasswordManager.CryptText(model.EMPPassword); //model.EMPPassword; customerLoginInformation.EMPUserId = model.EMPUserId; customerLoginInformation.StatusCode = EMPConstants.Active; customerLoginInformation.CLAccountId = model.CLAccountId; customerLoginInformation.CLLogin = model.CLLogin; customerLoginInformation.CLAccountPassword = string.IsNullOrEmpty(model.CLAccountPassword) ? "" : PasswordManager.CryptText(model.CLAccountPassword); if (entityState == (int)System.Data.Entity.EntityState.Modified) { customerLoginInformation.CreatedDate = DateTime.Now; customerLoginInformation.LastUpdatedDate = DateTime.Now; customerLoginInformation.LastUpdatedBy = model.UserId; customerLoginInformation.CreatedBy = model.UserId; db.Entry(customerLoginInformation).State = System.Data.Entity.EntityState.Modified; } else { db.Entry(customerLoginInformation).State = System.Data.Entity.EntityState.Added; customerLoginInformation.LastUpdatedBy = model.UserId; customerLoginInformation.LastUpdatedDate = DateTime.Now; db.emp_CustomerLoginInformation.Add(customerLoginInformation); } emp_CustomerInformation empCustInfo = new emp_CustomerInformation(); empCustInfo = db.emp_CustomerInformation.Where(o => o.Id == model.CustomerOfficeId).FirstOrDefault(); if (empCustInfo != null) { //11212016 - 2 empCustInfo.EFIN = model.EFIN; empCustInfo.EFINStatus = model.EFINStatus; empCustInfo.StatusCode = empCustInfo.IsActivationCompleted == 1 ? EMPConstants.Active : EMPConstants.Created; empCustInfo.CreatedBy = model.UserId; empCustInfo.LastUpdatedBy = model.UserId; if (empCustInfo.EntityId == (int)EMPConstants.Entity.SO || empCustInfo.EntityId == (int)EMPConstants.Entity.SOME) { if (empCustInfo.StatusCode == EMPConstants.Active || empCustInfo.IsActivationCompleted == 1) { empCustInfo.StatusCode = EMPConstants.Active; empCustInfo.IsActivationCompleted = 1; empCustInfo.AccountStatus = "Active"; if (empCustInfo.EntityId == (int)EMPConstants.Entity.SO) { empCustInfo.EROType = "Single Office"; } else if (empCustInfo.EntityId == (int)EMPConstants.Entity.SOME) { empCustInfo.EROType = "SOME"; } } } empCustInfo.CreatedDate = System.DateTime.Now; empCustInfo.LastUpdatedDate = System.DateTime.Now; db.Entry(empCustInfo).State = System.Data.Entity.EntityState.Modified; } } try { db.SaveChanges(); db.Dispose(); if (model != null) { if (model.CustomerOfficeId != Guid.Empty) { DropDownService ddService = new DropDownService(); var items = ddService.GetBottomToTopHierarchy(model.CustomerOfficeId ?? Guid.Empty); } } return(1); } catch (Exception ex) { EMPPortal.Core.Utilities.ExceptionLogger.LogException(ex.ToString(), "CustomerLoginInformationService/Save", Guid.Empty); return(0); throw; } }