protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            string valueString = "";
            try
            {
                valueString = (string)value;
            }
            catch (Exception)
            {
                return new ValidationResult("Property is invalid");
            }
            if (string.IsNullOrEmpty(valueString))
            {
                return ValidationResult.Success;
            }

            using (edisDbEntities db = new edisDbEntities())
            {
                var clientGroup = db.ClientGroups.SingleOrDefault(s => s.ClientGroupId == valueString);
                if (clientGroup != null)
                {
                    return ValidationResult.Success;
                }
                else
                {
                    return new ValidationResult(ErrorMessage);
                }
            }
        }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            string valueString = "";
            try
            {
                valueString = (string)value;
            }
            catch (Exception)
            {
                return new ValidationResult("Property is invalid");
            }
            if (string.IsNullOrEmpty(valueString))
            {
                return ValidationResult.Success;
            }

            using (edisDbEntities db = new edisDbEntities())
            {
                var user = db.AspNetUsers.FirstOrDefault(u => u.Email == valueString);
                if (user == null)
                {
                    return ValidationResult.Success;
                }
                else
                {
                    return new ValidationResult(ErrorMessage);
                }
            }
        }
        public async static Task<IEnumerable<Claim>> GetClaims(ClaimsIdentity user)
        {
            List<Claim> claims = new List<Claim>();
            using (edisDbEntities db = new edisDbEntities())
            {
                if (user.HasClaim(c => c.Type == ClaimTypes.Role && c.Value == AuthorizationRoles.Role_Client))
                {

                    var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    var userProfile = await userManager.FindByNameAsync(user.Name);

                    var client = db.Clients.FirstOrDefault(c => c.ClientUserID == userProfile.Id);
                    if (client != null)
                    {
                        var clientGroup = db.ClientGroups.FirstOrDefault(c => c.ClientGroupID == client.ClientGroupID);
                        if (clientGroup != null && clientGroup.MainClientID == client.ClientUserID)
                        {
                            claims.Add(CreateClaim(ClaimType_ClientGroupLeader, ClaimValue_ClientGroupLeader_Leader));
                        }
                        else
                        {
                            claims.Add(CreateClaim(ClaimType_ClientGroupLeader, ClaimValue_ClientGroupLeader_Member));
                        }
                    }
                }
            }
            return claims;
        }
        public async static Task<IEnumerable<Claim>> GetClaims(ClaimsIdentity user)
        {
            List<Claim> claims = new List<Claim>();
            //Only client account will be processed for this type of claim
            if (user != null && user.IsAuthenticated && user.HasClaim(c => c.Type == ClaimTypes.Role && c.Value == AuthorizationRoles.Role_Client))
            {
                using (edisDbEntities db = new edisDbEntities())
                {

                    var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));
                    var userProfile = await userManager.FindByNameAsync(user.Name);
                    if (userProfile != null)
                    {
                        var profile = db.RiskProfiles.FirstOrDefault(c => c.Client.ClientUserID == userProfile.Id);
                        if (profile != null)
                        {
                            claims.Add(CreateClaim(ClaimType_clientRiskProfileCompletion, ClaimValue_clientRiskProfile_Completed));
                        }
                        else
                        {
                            claims.Add(CreateClaim(ClaimType_clientRiskProfileCompletion, ClaimValue_clientRiskProfile_Incomplete));
                        }
                    }
                }
            }

            return claims;
        }
 public CorrespondenceController()
 {
     edisDbEntities db = new edisDbEntities();
     comRepo = new CommonReferenceDataRepository(db);
     corresRepo = new CorrespondenceRepository(db);
     //advRepo = new AdviserRepository(db);
     edisRepo = new EdisRepository();
 }
        protected override ValidationResult IsValid(object value, ValidationContext validationContext)
        {
            string valueString = "";
            try
            {
                valueString = value.ToString();
            }
            catch (Exception)
            {
                return new ValidationResult("Property is invalid");
            }
            if (string.IsNullOrEmpty(valueString))
            {
                return ValidationResult.Success;
            }
            //int valueNumber = -1;
            //try
            //{
            //    valueNumber = Convert.ToInt32(valueString);
            //}
            //catch (Exception)
            //{

            //    //return new ValidationResult("Property is invalid");
            //}
            //if (valueNumber < 0)
            //{

            //    return new ValidationResult("Property is invalid");
            //}

            using (edisDbEntities db = new edisDbEntities())
            {
                var adviser = db.Advisers.SingleOrDefault(s => (s.AdviserNumber == valueString) || s.AdviserId == valueString); //AccountNumber --> AdviserNumber
                if (adviser != null)
                {
                    return ValidationResult.Success;
                }
                else
                {
                    return new ValidationResult(ErrorMessage);
                }
            }
        }
 /// <summary>
 /// Incomplete implementation, currently will return administration role for every login.
 /// </summary>
 /// <param name="user">User needed to be verified with new claims</param>
 /// <returns></returns>
 public static IEnumerable<Claim> GetClaims(ClaimsIdentity user)
 {
     if (user == null)
     {
         throw new ArgumentNullException();
     }
     List<Claim> claims = new List<Claim>();
     using (edisDbEntities db = new edisDbEntities())
     {
         var userManager = new ApplicationUserManager(new UserStore<ApplicationUser>(new ApplicationDbContext()));//HttpContext.Current.GetOwinContext().GetUserManager<ApplicationUserManager>();
         var userFull = userManager.FindByNameAsync(user.Name).Result;
         var userId = userFull.Id;
         if (db.Advisers.Where(a => a.AdviserId == userId && a.VerifiedId == BusinessLayerParameters.verificationStatus_Verified).Count() > 0)
         {
             claims.Add(CreateClaim(AuthorizationClaims.ClaimType_VerificationStatus,
                 AuthorizationClaims.ClaimValue_VerificationStatus_Verified));
         }
     }
     return claims;
 }
Пример #8
0
 public AdviserRepository(edisDbEntities database)
     :base(database)
 {
 }
 public BaseRepository(edisDbEntities database)
 {
     db = database;
 }
 public BaseRepository()
 {
     db = new edisDbEntities();
 }
Пример #11
0
 public AdminController()
 {
     db = new edisDbEntities();
     edisRepo = new EdisRepository();
 }
Пример #12
0
 // public DBWrapper dbService;
  public PortfolioRepository(edisDbEntities database)
      : base(database)
  {
  }
 public ClientRepository(edisDbEntities database)
 {
     db = database;
 }
Пример #14
0
 public RebalanceRepository(edisDbEntities database)
 {
     db = database;
     //comRepo = new CommonReferenceDataRepository(db);
 }
 public CorrespondenceRepository(edisDbEntities database)
 {
     db = database;
 }
 public CorrespondenceRepository()
 {
     db = new edisDbEntities();
 }
 public CommonReferenceDataRepository(edisDbEntities database)
 {
     db = database;
 }
 public CommonReferenceDataRepository()
 {
     db = new edisDbEntities();
 }
Пример #19
0
 public RebalanceRepository()
 {
     db = new edisDbEntities();
    // comRepo = new CommonReferenceDataRepository(db);
 }
 public ClientRepository()
 {
     repo = new EdisRepository();
     db = new edisDbEntities();
 }