public PrivacyResponseDto(long responseKey, bool? contactByEmail, bool? contactByPhone, bool? contactByPost, EmailPreferences? emailPreferences, bool? mailStop) : base(responseKey) { _contactByEmail = contactByEmail; _contactByPhone = contactByPhone; _contactByPost = contactByPost; _emailPreferences = emailPreferences; _mailStop = mailStop; }
public ActionResult EmailPreferences(EmailPreferences emailPreferences) { Check.Require(emailPreferences.Id == CurrentUser.Identity.Name, string.Format("User {0} attempted to save the email preferences for {1}", CurrentUser.Identity.Name, emailPreferences.Id)); if (!ModelState.IsValid) { return(View(emailPreferences)); } Message = "Your email preferences have been updated"; _emailPreferencesRepository.EnsurePersistent(emailPreferences); return(RedirectToAction("Profile")); }
private EmailPreferences GetEmailPreferences(string userId) { var pref = _emailPreferenceRepository.GetNullableById(userId); if (pref == null) { var log = Log.ForContext("userId", userId); //Log email pref not found log.Information("Email Preference not found with GetNullable"); pref = _emailPreferenceRepository.Queryable.FirstOrDefault(a => a.Id == userId.Trim().ToLower()); if (pref == null) { //Log that this failed too log.Information("Email Preference not found with FirstOrDefault and Trim.ToLower"); pref = new EmailPreferences(userId); } } return(pref); }
public async Task <ActionResult> SetPreferences(EmailPreferences emailPreferences) { Customer customer = await unitOfWork.Customers.Get(User.FindFirst(ClaimTypes.NameIdentifier).Value); customer.EmailPrefNameChange = emailPreferences.NameChange; customer.EmailPrefEmailChange = emailPreferences.EmailChange; customer.EmailPrefPasswordChange = emailPreferences.PasswordChange; customer.EmailPrefProfilePicChange = emailPreferences.ProfilePicChange; customer.EmailPrefNewCollaborator = emailPreferences.NewCollaborator; customer.EmailPrefRemovedCollaborator = emailPreferences.RemovedCollaborator; customer.EmailPrefRemovedListItem = emailPreferences.RemovedListItem; customer.EmailPrefMovedListItem = emailPreferences.MovedListItem; customer.EmailPrefAddedListItem = emailPreferences.AddedListItem; customer.EmailPrefListNameChange = emailPreferences.ListNameChange; customer.EmailPrefDeletedList = emailPreferences.DeletedList; customer.EmailPrefReview = emailPreferences.Review; await unitOfWork.Save(); return(Ok()); }
/// <summary> /// /// </summary> /// <param name="id">Workgroup Id</param> /// <param name="role">Role being for people being added</param> /// <param name="workgroup">workgroup</param> /// <param name="successCount">how many have already been successfully added</param> /// <param name="lookupUser">user being added</param> /// <param name="failCount">count of number not added</param> /// <param name="notAddedKvp">list of users not added and reason why.</param> /// <returns></returns> public int TryToAddPeople(int id, Role role, Workgroup workgroup, int successCount, string lookupUser, ref int failCount, ref int duplicateCount, List <KeyValuePair <string, string> > notAddedKvp) { var saveParm = lookupUser; var user = _userRepository.GetNullableById(lookupUser); if (user == null) { var ldapuser = _searchService.FindUser(lookupUser); if (ldapuser != null) { lookupUser = ldapuser.LoginId; user = _userRepository.GetNullableById(ldapuser.LoginId); if (user == null) { user = new User(ldapuser.LoginId); user.Email = ldapuser.EmailAddress; user.FirstName = ldapuser.FirstName; user.LastName = ldapuser.LastName; _userRepository.EnsurePersistent(user); var emailPrefs = new EmailPreferences(user.Id); _emailPreferencesRepository.EnsurePersistent(emailPrefs); } } } if (user == null) { //notAddedSb.AppendLine(string.Format("{0} : Not found", saveParm)); notAddedKvp.Add(new KeyValuePair <string, string>(saveParm, "Not found")); failCount++; return(successCount); } if (!_workgroupPermissionRepository.Queryable.Any(a => a.Role == role && a.User == user && a.Workgroup == workgroup && a.IsAdmin == false)) { var workgroupPermission = new WorkgroupPermission(); workgroupPermission.Role = role; workgroupPermission.User = _userRepository.GetNullableById(lookupUser); workgroupPermission.Workgroup = _workgroupRepository.GetNullableById(id); _workgroupPermissionRepository.EnsurePersistent(workgroupPermission); if (workgroup.Administrative) { var ids = GetChildWorkgroups(workgroup.Id); foreach (var childid in ids) { var childWorkgroup = _workgroupRepository.Queryable.Single(a => a.Id == childid); if (!_workgroupPermissionRepository.Queryable.Any(a => a.Workgroup == childWorkgroup && a.Role == role && a.User == user && a.IsAdmin && a.ParentWorkgroup == workgroup)) { Check.Require(role.Id != Role.Codes.Requester); var childPermission = new WorkgroupPermission(); childPermission.Role = role; childPermission.User = workgroupPermission.User; childPermission.Workgroup = childWorkgroup; childPermission.IsAdmin = true; childPermission.IsFullFeatured = workgroup.IsFullFeatured; childPermission.ParentWorkgroup = workgroup; _workgroupPermissionRepository.EnsurePersistent(childPermission); } } } // invalid the cache for the user that was just given permissions _userIdentity.RemoveUserRoleFromCache(Resources.Role_CacheId, workgroupPermission.User.Id); successCount++; } else { //notAddedSb.AppendLine(string.Format("{0} : Is a duplicate", lookupUser)); notAddedKvp.Add(new KeyValuePair <string, string>(lookupUser, "Is a duplicate")); failCount++; duplicateCount++; } return(successCount); }
public static EmailPreferences EmailPreferences(int?counter) { var rtValue = new EmailPreferences(counter.HasValue ? counter.Value.ToString() : "notSet"); return(rtValue); }
/// <summary> /// /// </summary> /// <param name="id">Workgroup Id</param> /// <param name="role">Role being for people being added</param> /// <param name="workgroup">workgroup</param> /// <param name="successCount">how many have already been successfully added</param> /// <param name="lookupUser">user being added</param> /// <param name="failCount">count of number not added</param> /// <param name="notAddedKvp">list of users not added and reason why.</param> /// <returns></returns> public int TryToAddPeople(int id, Role role, Workgroup workgroup, int successCount, string lookupUser, ref int failCount, ref int duplicateCount, List<KeyValuePair<string, string>> notAddedKvp) { var saveParm = lookupUser; var user = _userRepository.GetNullableById(lookupUser); if(user == null) { var ldapuser = _searchService.FindUser(lookupUser); if(ldapuser != null) { lookupUser = ldapuser.LoginId; user = _userRepository.GetNullableById(ldapuser.LoginId); if(user == null) { user = new User(ldapuser.LoginId); user.Email = ldapuser.EmailAddress; user.FirstName = ldapuser.FirstName; user.LastName = ldapuser.LastName; _userRepository.EnsurePersistent(user); var emailPrefs = new EmailPreferences(user.Id); _emailPreferencesRepository.EnsurePersistent(emailPrefs); } } } if(user == null) { //notAddedSb.AppendLine(string.Format("{0} : Not found", saveParm)); notAddedKvp.Add(new KeyValuePair<string, string>(saveParm, "Not found")); failCount++; return successCount; } if(!_workgroupPermissionRepository.Queryable.Any(a => a.Role == role && a.User == user && a.Workgroup == workgroup && a.IsAdmin== false)) { var workgroupPermission = new WorkgroupPermission(); workgroupPermission.Role = role; workgroupPermission.User = _userRepository.GetNullableById(lookupUser); workgroupPermission.Workgroup = _workgroupRepository.GetNullableById(id); _workgroupPermissionRepository.EnsurePersistent(workgroupPermission); if (workgroup.Administrative) { var ids = GetChildWorkgroups(workgroup.Id); foreach (var childid in ids) { var childWorkgroup = _workgroupRepository.Queryable.Single(a => a.Id == childid); if (!_workgroupPermissionRepository.Queryable.Any(a=> a.Workgroup==childWorkgroup && a.Role==role && a.User==user && a.IsAdmin && a.ParentWorkgroup==workgroup)) { Check.Require(role.Id != Role.Codes.Requester); var childPermission = new WorkgroupPermission(); childPermission.Role = role; childPermission.User = workgroupPermission.User; childPermission.Workgroup = childWorkgroup; childPermission.IsAdmin = true; childPermission.IsFullFeatured = workgroup.IsFullFeatured; childPermission.ParentWorkgroup = workgroup; _workgroupPermissionRepository.EnsurePersistent(childPermission); } } } // invalid the cache for the user that was just given permissions _userIdentity.RemoveUserRoleFromCache(Resources.Role_CacheId, workgroupPermission.User.Id); successCount++; } else { //notAddedSb.AppendLine(string.Format("{0} : Is a duplicate", lookupUser)); notAddedKvp.Add(new KeyValuePair<string, string>(lookupUser, "Is a duplicate")); failCount++; duplicateCount++; } return successCount; }
public static EmailPreferences EmailPreferences(int? counter) { var rtValue = new EmailPreferences(counter.HasValue ? counter.Value.ToString() : "notSet"); return rtValue; }
/// <summary> /// Determines if user has opted out of a selected email /// </summary> /// <param name="preference"></param> /// <param name="role"></param> /// <param name="currentStatus"></param> /// <param name="eventCode"></param> /// <returns>True if should receive email, False if should not receive email</returns> private bool IsMailRequested(EmailPreferences preference, OrderStatusCode role, OrderStatusCode currentStatus, EventCode eventCode, OrderType orderType = null) { // no preference, automatically gets emails if (preference == null) { return(true); } // what is the role of the user we are inspecting switch (role.Id) { case OrderStatusCode.Codes.Requester: // what event is happening switch (eventCode) { case EventCode.Approval: // evaluate the level that is being handled switch (currentStatus.Id) { case OrderStatusCode.Codes.Approver: return(preference.RequesterApproverApproved); case OrderStatusCode.Codes.ConditionalApprover: return(preference.RequesterApproverApproved); case OrderStatusCode.Codes.AccountManager: return(preference.RequesterAccountManagerApproved); // this technically doesn't exist, gets completed at purchaser level //case OrderStatusCode.Codes.Purchaser: return preference.RequesterPurchaserAction; //case OrderStatusCode.Codes.Complete: return preference.RequesterKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) default: return(true); } case EventCode.Update: switch (currentStatus.Id) { case OrderStatusCode.Codes.Approver: return(preference.RequesterApproverChanged); case OrderStatusCode.Codes.ConditionalApprover: return(preference.RequesterApproverChanged); case OrderStatusCode.Codes.AccountManager: return(preference.RequesterAccountManagerChanged); case OrderStatusCode.Codes.Purchaser: return(preference.RequesterPurchaserChanged); default: return(true); } case EventCode.Cancelled: // there is no option, user always receives this event return(true); case EventCode.Complete: return(preference.RequesterPurchaserAction); //case EventCode.KualiUpdate: // //TODO: add in kuali stuff // break; case EventCode.Received: return(preference.RequesterReceived); case EventCode.Paid: return(preference.RequesterPaid); } break; case OrderStatusCode.Codes.Approver: // evaluate the event switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.AccountManager: return(preference.ApproverAccountManagerApproved); case OrderStatusCode.Codes.Purchaser: return(preference.ApproverPurchaserProcessed); //case OrderStatusCode.Codes.Complete: return preference.ApproverKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? case OrderStatusCode.Codes.Complete: return(preference.ApproverPurchaserProcessed); default: return(false); } case EventCode.Update: // this email is turned off, no email exists return(false); case EventCode.Cancelled: // this email is turned off, no email exists return(false); // this technically doesn't exist, since a "complete" order is an approval at purchaser level, see switch statement in approval event. case EventCode.Complete: return(preference.ApproverPurchaserProcessed); //case EventCode.KualiUpdate: // //TODO: add in kuali stuff // break; case EventCode.Arrival: return(preference.ApproverOrderArrive); // no received status for approver case EventCode.Received: return(false); case EventCode.Paid: return(false); default: return(false); } case OrderStatusCode.Codes.ConditionalApprover: //Copied code from Approver above... Otherwise this was always returning true... // evaluate the event switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.AccountManager: return(preference.ApproverAccountManagerApproved); case OrderStatusCode.Codes.Purchaser: return(preference.ApproverPurchaserProcessed); //case OrderStatusCode.Codes.Complete: return preference.ApproverKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? case OrderStatusCode.Codes.Complete: return(preference.ApproverPurchaserProcessed); default: return(false); } case EventCode.Update: // this email is turned off, no email exists return(false); case EventCode.Cancelled: // this email is turned off, no email exists return(false); // this technically doesn't exist, since a "complete" order is an approval at purchaser level, see switch statement in approval event. case EventCode.Complete: return(preference.ApproverPurchaserProcessed); //case EventCode.KualiUpdate: // //TODO: add in kuali stuff // break; case EventCode.Arrival: return(preference.ApproverOrderArrive); // no received status for approver case EventCode.Received: return(false); case EventCode.Paid: return(false); default: return(false); } break; case OrderStatusCode.Codes.AccountManager: switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.Purchaser: return(preference.AccountManagerPurchaserProcessed); case OrderStatusCode.Codes.Complete: return(preference.AccountManagerPurchaserProcessed); //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? default: return(true); } case EventCode.Update: // no email exists return(false); case EventCode.Cancelled: // no email exists return(false); case EventCode.Complete: return(preference.AccountManagerPurchaserProcessed); //case EventCode.KualiUpdate: // //TODO: Add in kuali stuff // break; case EventCode.Arrival: return(preference.AccountManagerOrderArrive); // account manager doesn't have any emails fror received. case EventCode.Received: return(false); case EventCode.Paid: return(false); default: return(false); } case OrderStatusCode.Codes.Purchaser: switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.Complete: return(preference.PurchaserKualiApproved); //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? } // no email exists return(false); case EventCode.Update: // no email exists return(false); case EventCode.Cancelled: // no email exists return(false); //case EventCode.KualiUpdate: // //TODO: Add in Kuali Stuff // break; case EventCode.Arrival: return(preference.PurchaserOrderArrive); case EventCode.Received: switch (orderType.Id) { case "KFS": return(preference.PurchaserKfsItemReceived); case "PC": return(preference.PurchaserPCardItemReceived); case "CS": return(preference.PurchaserCampusServicesItemReceived); default: return(false); } case EventCode.Paid: switch (orderType.Id) { case "KFS": return(preference.PurchaserKfsItemPaid); case "PC": return(preference.PurchaserPCardItemPaid); case "CS": return(preference.PurchaserCampusServicesItemPaid); default: return(false); } default: return(false); } } // default receive email return(true); }
public PersonalResponseDto(long responseKey, string address1, string address2, string address3, string businessCode, string businessSiebel63, string companyName, string countryCode, string county, string customerId, string emailAddress, string firstName, string flexField1, string flexField10, string flexField11, string flexField12, string flexField13, string flexField14, string flexField15, string flexField2, string flexField3, string flexField4, string flexField5, string flexField6, string flexField7, string flexField8, string flexField9, string jobCode, string jobSiebel63, string jobTitle, string lastName, string personalTitle, string postcode, string pwd, string telephoneCountry, string telephoneArea, string telephoneNumber, string telephoneExt, string faxCountry, string faxArea, string faxNumber, string faxExt, string mobileCountry, string mobileNumber, string town, string worldSize, string worldSize63, string countryName, EmailPreferences? emailPreferences, string preferredLanguage, string companyWebsite,string companyRevenue) //RFG 2.11 : base(responseKey) { _address1 = address1; _address2 = address2; _address3 = address3; _businessCode = businessCode; _businessSiebel63 = businessSiebel63; _companyName = companyName; _countryCode = countryCode; _county = county; _customerId = customerId; _emailAddress = emailAddress; _firstName = firstName; _flexField1 = flexField1; _flexField10 = flexField10; _flexField11 = flexField11; _flexField12 = flexField12; _flexField13 = flexField13; _flexField14 = flexField14; _flexField15 = flexField15; _flexField2 = flexField2; _flexField3 = flexField3; _flexField4 = flexField4; _flexField5 = flexField5; _flexField6 = flexField6; _flexField7 = flexField7; _flexField8 = flexField8; _flexField9 = flexField9; _jobCode = jobCode; _jobSiebel63 = jobSiebel63; _jobTitle = jobTitle; _lastName = lastName; _personalTitle = personalTitle; _postcode = postcode; _pwd = pwd; _telephoneCountry = telephoneCountry; _telephoneArea = telephoneArea; _telephoneNumber = telephoneNumber; _telephoneExt = telephoneExt; _faxCountry = faxCountry; _faxArea = faxArea; _faxNumber = faxNumber; _faxExt = faxExt; _mobileCountry = mobileCountry; _mobileNumber = mobileNumber; _town = town; _worldSize = worldSize; _worldSize63 = worldSize63; _countryName = countryName; _emailPreferences = emailPreferences; _preferredLanguage = preferredLanguage; _companyWebsite = companyWebsite; //RFG 2.11 | Added by Raju _companyRevenue = companyRevenue; }
/// <summary> /// Determines if user has opted out of a selected email /// </summary> /// <param name="preference"></param> /// <param name="role"></param> /// <param name="currentStatus"></param> /// <param name="eventCode"></param> /// <returns>True if should receive email, False if should not receive email</returns> private bool IsMailRequested(EmailPreferences preference, OrderStatusCode role, OrderStatusCode currentStatus, EventCode eventCode, OrderType orderType = null) { // no preference, automatically gets emails if (preference == null) return true; // what is the role of the user we are inspecting switch (role.Id) { case OrderStatusCode.Codes.Requester: // what event is happening switch (eventCode) { case EventCode.Approval: // evaluate the level that is being handled switch (currentStatus.Id) { case OrderStatusCode.Codes.Approver: return preference.RequesterApproverApproved; case OrderStatusCode.Codes.ConditionalApprover: return preference.RequesterApproverApproved; case OrderStatusCode.Codes.AccountManager: return preference.RequesterAccountManagerApproved; // this technically doesn't exist, gets completed at purchaser level //case OrderStatusCode.Codes.Purchaser: return preference.RequesterPurchaserAction; //case OrderStatusCode.Codes.Complete: return preference.RequesterKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) default: return true; } case EventCode.Update: switch (currentStatus.Id) { case OrderStatusCode.Codes.Approver: return preference.RequesterApproverChanged; case OrderStatusCode.Codes.ConditionalApprover: return preference.RequesterApproverChanged; case OrderStatusCode.Codes.AccountManager: return preference.RequesterAccountManagerChanged; case OrderStatusCode.Codes.Purchaser: return preference.RequesterPurchaserChanged; default: return true; } case EventCode.Cancelled: // there is no option, user always receives this event return true; case EventCode.Complete: return preference.RequesterPurchaserAction; //case EventCode.KualiUpdate: // //TODO: add in kuali stuff // break; case EventCode.Received: return preference.RequesterReceived; case EventCode.Paid: return preference.RequesterPaid; } break; case OrderStatusCode.Codes.Approver: // evaluate the event switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.AccountManager: return preference.ApproverAccountManagerApproved; case OrderStatusCode.Codes.Purchaser: return preference.ApproverPurchaserProcessed; //case OrderStatusCode.Codes.Complete: return preference.ApproverKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? case OrderStatusCode.Codes.Complete: return preference.ApproverPurchaserProcessed; default: return false; } case EventCode.Update: // this email is turned off, no email exists return false; case EventCode.Cancelled: // this email is turned off, no email exists return false; // this technically doesn't exist, since a "complete" order is an approval at purchaser level, see switch statement in approval event. case EventCode.Complete: return preference.ApproverPurchaserProcessed; //case EventCode.KualiUpdate: // //TODO: add in kuali stuff // break; case EventCode.Arrival: return preference.ApproverOrderArrive; // no received status for approver case EventCode.Received: return false; case EventCode.Paid: return false; default: return false; } case OrderStatusCode.Codes.ConditionalApprover: //Copied code from Approver above... Otherwise this was always returning true... // evaluate the event switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.AccountManager: return preference.ApproverAccountManagerApproved; case OrderStatusCode.Codes.Purchaser: return preference.ApproverPurchaserProcessed; //case OrderStatusCode.Codes.Complete: return preference.ApproverKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? case OrderStatusCode.Codes.Complete: return preference.ApproverPurchaserProcessed; default: return false; } case EventCode.Update: // this email is turned off, no email exists return false; case EventCode.Cancelled: // this email is turned off, no email exists return false; // this technically doesn't exist, since a "complete" order is an approval at purchaser level, see switch statement in approval event. case EventCode.Complete: return preference.ApproverPurchaserProcessed; //case EventCode.KualiUpdate: // //TODO: add in kuali stuff // break; case EventCode.Arrival: return preference.ApproverOrderArrive; // no received status for approver case EventCode.Received: return false; case EventCode.Paid: return false; default: return false; } break; case OrderStatusCode.Codes.AccountManager: switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.Purchaser: return preference.AccountManagerPurchaserProcessed; case OrderStatusCode.Codes.Complete: return preference.AccountManagerPurchaserProcessed; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? default: return true; } case EventCode.Update: // no email exists return false; case EventCode.Cancelled: // no email exists return false; case EventCode.Complete: return preference.AccountManagerPurchaserProcessed; //case EventCode.KualiUpdate: // //TODO: Add in kuali stuff // break; case EventCode.Arrival: return preference.AccountManagerOrderArrive; // account manager doesn't have any emails fror received. case EventCode.Received: return false; case EventCode.Paid: return false; default: return false; } case OrderStatusCode.Codes.Purchaser: switch (eventCode) { case EventCode.Approval: switch (currentStatus.Id) { case OrderStatusCode.Codes.Complete: return preference.PurchaserKualiApproved; //Done: OrderStatusCode.Codes.Complete (Kuali Approved) or Request Completed (Look at Email Preferences Page) ? } // no email exists return false; case EventCode.Update: // no email exists return false; case EventCode.Cancelled: // no email exists return false; //case EventCode.KualiUpdate: // //TODO: Add in Kuali Stuff // break; case EventCode.Arrival: return preference.PurchaserOrderArrive; case EventCode.Received: switch (orderType.Id) { case "KFS": return preference.PurchaserKfsItemReceived; case "PC": return preference.PurchaserPCardItemReceived; case "CS": return preference.PurchaserCampusServicesItemReceived; default: return false; } case EventCode.Paid: switch (orderType.Id) { case "KFS": return preference.PurchaserKfsItemPaid; case "PC": return preference.PurchaserPCardItemPaid; case "CS": return preference.PurchaserCampusServicesItemPaid; default: return false; } default: return false; } } // default receive email return true; }
private EmailPreferences GetEmailPreferences(string userId) { var pref = _emailPreferenceRepository.GetNullableById(userId); if (pref == null) { var log = Log.ForContext("userId", userId); //Log email pref not found log.Information("Email Preference not found with GetNullable"); pref = _emailPreferenceRepository.Queryable.FirstOrDefault(a => a.Id == userId.Trim().ToLower()); if (pref == null) { //Log that this failed too log.Information("Email Preference not found with FirstOrDefault and Trim.ToLower"); pref = new EmailPreferences(userId); } } return pref; }