diff options
| author | Michael <[email protected]> | 2017-05-23 11:25:37 -0400 |
|---|---|---|
| committer | Michael <[email protected]> | 2017-05-23 11:25:44 -0400 |
| commit | 52d46877c988edc471cd8ed15c290c8af77db5b2 (patch) | |
| tree | 857bae3bac8eb2c8e4bf58fc553419607765f025 | |
| parent | a4a75f39bbf496b6b24fef6859198e4d4f8d26e4 (diff) | |
| download | project-unite-52d46877c988edc471cd8ed15c290c8af77db5b2.tar.gz project-unite-52d46877c988edc471cd8ed15c290c8af77db5b2.tar.bz2 project-unite-52d46877c988edc471cd8ed15c290c8af77db5b2.zip | |
fix contest submissions
| -rw-r--r-- | Project-Unite/Models/IdentityModels.cs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/Project-Unite/Models/IdentityModels.cs b/Project-Unite/Models/IdentityModels.cs index 8959a8e..3d55b2f 100644 --- a/Project-Unite/Models/IdentityModels.cs +++ b/Project-Unite/Models/IdentityModels.cs @@ -76,9 +76,19 @@ namespace Project_Unite.Models var roleList = new List<Role>(); foreach (var role in this.Roles) { - roleList.Add(new ApplicationDbContext().Roles.First(r => r.Id == role.RoleId) as Role); + var found = (new ApplicationDbContext().Roles.FirstOrDefault(r => r.Id == role.RoleId) as Role); + if (found != null) + roleList.Add(found); } + if(roleList.Count()==0) + { + var roles = new List<Role>(); + var db = new ApplicationDbContext(); + foreach (var r in db.Roles.ToArray()) + roles.Add(r as Role); + return roles.OrderBy(x => x.Priority).First(); + } return roleList.OrderByDescending(x => x.Priority).First(); } } |
