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));
                }
            }
        }
        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));
                }
            }
        }
        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 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);
        }
Exemplo n.º 5
0
        //  private EdisRepository repo;
        public CorrespondenceController()
        {
            edisDbEntities db = new edisDbEntities();

            //comRepo = new CommonReferenceDataRepository(db);
            corresRepo = new CorrespondenceRepository(db);
            //advRepo = new AdviserRepository(db);
            edisRepo = new EdisRepository();
        }
Exemplo n.º 6
0
        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));
                }
            }
        }
Exemplo n.º 7
0
        /// <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);
        }
Exemplo n.º 8
0
 public BaseRepository()
 {
     db = new edisDbEntities();
 }
Exemplo n.º 9
0
 public BaseRepository(edisDbEntities database)
 {
     db = database;
 }
 public CorporateActionRepository(edisDbEntities database)
 {
     db      = database;
     comRepo = new CommonReferenceDataRepository(db);
 }
 public CorporateActionRepository()
 {
     db      = new edisDbEntities();
     comRepo = new CommonReferenceDataRepository(db);
 }
Exemplo n.º 12
0
 public AdminController()
 {
     db       = new edisDbEntities();
     edisRepo = new EdisRepository();
 }
 public CorrespondenceRepository(edisDbEntities database)
 {
     db = database;
 }
 public CorrespondenceRepository()
 {
     db = new edisDbEntities();
 }