public IEnumerable<UserRole> FdpUserGetRoles(User forUser)
        {
            IList<UserRole> retVal = new List<UserRole>{UserRole.None};
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@CDSId", forUser.CDSId, DbType.String);
                   
                    var results = conn.Query<FdpUserRoleDataItem>("dbo.Fdp_UserRole_GetMany", para, commandType: CommandType.StoredProcedure);
                    var fdpUserRoleDataItems = results as IList<FdpUserRoleDataItem> ?? results.ToList();
                    if (fdpUserRoleDataItems.Any())
                    {
                        retVal = fdpUserRoleDataItems.Select(role => (UserRole) role.FdpUserRoleId).ToList();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return retVal;
        }
        public User FdpUserSave(User userToAdd)
        {
            User retVal = new EmptyUser();

            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@CDSId", userToAdd.CDSId, DbType.String);
                    para.Add("@FullName", userToAdd.FullName, DbType.String);
                    para.Add("@Mail", userToAdd.Mail, DbType.String);
                    para.Add("@IsAdmin", userToAdd.IsAdmin, DbType.Boolean);
                    para.Add("@CreatorCDSId", CurrentCDSID, DbType.String);
                    
                    var results = conn.Query<UserDataItem>("dbo.Fdp_User_Save", para, commandType: CommandType.StoredProcedure);
                    var enumerable = results as IList<UserDataItem> ?? results.ToList();
                    if (enumerable.Any()) {
                        retVal = enumerable.First().ToUser();
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return retVal;
        }
 public User FdpUserGet(UserFilter filter)
 {
     User user;
     var results = FdpUserGetMany(filter);
     if (results.CurrentPage.Any())
     {
         user = results.CurrentPage.First().ToUser();
     }
     else
     {
         user = new User
         {
             CDSId = filter.CDSId
         };
     }
     return user;
 }
        public IEnumerable<UserMarketMapping> FdpUserMarketMappingsGetMany(User forUser)
        {
            IEnumerable<UserMarketMapping> retVal;
            
            using (var conn = DbHelper.GetDBConnection())
            {
                try
                {
                    var para = new DynamicParameters();
                    para.Add("@CDSId", forUser.CDSId, DbType.String);

                    retVal = conn.Query<UserMarketMapping>("dbo.Fdp_UserMarket_GetMany", para, commandType: CommandType.StoredProcedure);
                }
                catch (Exception ex)
                {
                    Log.Error(ex);
                    throw;
                }
            }

            return retVal;
        }
 public async Task<User> UnsetAdministrator(User userToUnset)
 {
     return await Task.FromResult(_userDataStore.FdpUserUnSetAdministrator(userToUnset));
 }
 public async Task<User> DisableUser(User userToDisable)
 {
     return await Task.FromResult(_userDataStore.FdpUserDisable(userToDisable));
 }
 public async Task<User> AddUser(User userToAdd)
 {
     return await Task.FromResult(_userDataStore.FdpUserSave(userToAdd));
 }