Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Boggin committed Dec 13, 2018
1 parent 196bfa2 commit 00de093
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 20 deletions.
10 changes: 10 additions & 0 deletions src/FeatureFlagger.Behaviours/RolloutBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 34,15 @@ public string Username()
var rand = r.Next().ToString(CultureInfo.InvariantCulture);
return "username" rand;
}

public string UserName()
{
throw new NotImplementedException();
}

public bool UserHasFeature(string userName, string featureName)
{
throw new NotImplementedException();
}
}
}
51 changes: 35 additions & 16 deletions src/FeatureFlagger.Behaviours/User.cs
Original file line number Diff line number Diff line change
@@ -1,20 1,25 @@
namespace RoyalLondon.IntermediaryManagement.Api.FeatureFlagger.Behaviours
namespace FeatureFlagger.Behaviours
{
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;

using RoyalLondon.IntermediaryManagement.Api.Entities;

[Export(typeof(IUser))]
public class User : IUser
{
public bool UserHasFeature(string userName, string featureName)
{
public string UserName()
{
throw new NotImplementedException();
}

bool IUser.UserHasFeature(string userName, string featureName)
{
IntermediaryManagement_DB context = null;
DbContext context = null;
try
{
context = IntermediariesContainerFactory.Create();
context = DbContextFactory.Create();
/*
var user =
context.Users.FirstOrDefault(
u =>
Expand All @@ -27,19 32,33 @@ public bool UserHasFeature(string userName, string featureName)
f.Name.Equals(
featureName,
StringComparison.OrdinalIgnoreCase));

return hasFeature == true;
*/

return true;
}
finally
{
context?.Dispose();
}
}

public string UserName()
{
// TODO: get the authorised user from SSO.
return "dummy";
}
}

public class DbContext
{
internal readonly List<User> Users;

internal void Dispose()
{
throw new NotImplementedException();
}
}

public class DbContextFactory
{
internal static DbContext Create()
{
throw new NotImplementedException();
}
}
}
}
8 changes: 4 additions & 4 deletions src/FeatureFlagger.Behaviours/UserBehaviour.cs
Original file line number Diff line number Diff line change
@@ -1,11 1,10 @@
namespace RoyalLondon.IntermediaryManagement.Api.FeatureFlagger.Behaviours
namespace FeatureFlagger.Behaviours
{
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;

using Castle.Core.Internal;
using global::FeatureFlagger.Behaviours;

[Export(typeof(IBehaviour))]
public class UserBehaviour : IBehaviour
Expand All @@ -26,7 25,8 @@ public Func<Dictionary<string, string>, bool> Behaviour()
string username = x.TryGetValue("name", out username) ? username : user.UserName();
string lookup = x.TryGetValue("lookup", out lookup) ? lookup : "store";
if (lookup.IsNullOrEmpty() || lookup.Equals("store"))
// if (lookup.IsNullOrEmpty() || lookup.Equals("store"))
if (string.IsNullOrEmpty(lookup) || lookup.Equals("store"))
{
return user.UserHasFeature(username, x["feature"]);
}
Expand Down

0 comments on commit 00de093

Please sign in to comment.