public async Task <GenericResult <UserStorePolicy> > SetUserStorePolicy(UserStorePolicy policy) { var result = new GenericResult <UserStorePolicy>(); try { var validationResults = await _setUserStorePolicyEngine.ValidateUserStorePolicyForSave(policy); if (validationResults.IsFailure) { result.IsFailure = true; result.Message = validationResults.Message; return(result); } result.Data = await _setUserStorePolicyEngine.SetUserStorePolicy(policy); result.Message = "Success"; } catch (Exception ex) { result.IsFailure = true; result.Exception = ex; result.Message = ex.Message; } return(result); }
public async Task <UserStorePolicy> SetUserStorePolicy(UserStorePolicy policy) { var data = await _policyAccessor.SetUserStorePolicy(policy); SetUserStoredSharedPolicy(policy); return(data); }
private void SetUserStoredSharedPolicy(UserStorePolicy policy, StoreOptions shared = null) { if (shared == null) { shared = _sharedPolicyAccessor.GetPolicy().Stores; } shared.MaxLengthForKeys = policy.MaxLengthForKeys; shared.ProtectPersonalData = policy.ProtectPersonalData; _sharedPolicyAccessor.SetUserStorePolicy(shared); }
internal static UserStorePolicyEntity ToEntity(this UserStorePolicy model) { if (model == null) { return(null); } return(new UserStorePolicyEntity { Id = model.Id, Created = model.Created, CreatedById = model.CreatedById, MaxLengthForKeys = model.MaxLengthForKeys, ProtectPersonalData = model.ProtectPersonalData }); }
public async Task <UserStorePolicy> SetUserStorePolicy(UserStorePolicy policy) { using (var ctx = new UserDbContext(_options)) { var ent = await ctx.UserStorePolicies.AddAsync(policy.ToEntity()); var cnt = await ctx.SaveChangesAsync(); if (cnt < 1 || cnt > 2) { throw new Exception("There was an error updating the User Store Policy record."); } return(ent.Entity.ToModel()); } }
public async Task <GenericResult <IEnumerable <string> > > ValidateUserStorePolicyForSave(UserStorePolicy policy) { var isNull = policy == null; return(await Task.FromResult(new GenericResult <IEnumerable <string> > { IsFailure = isNull, Message = isNull ? "User Store Policy cannot be null." : string.Empty, Data = isNull ? new [] { "User Store Policy cannot be null." } : new string[0] })); }