TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Marius Vasile
594
1.9k
145.6k
asp.net core foreach and if not working properly
Feb 19 2021 9:16 AM
I have the below procedure
var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);
var orgid = await _context.UsersData.Where(s => s.Id == userId).Select(s => s.OrgID).FirstOrDefaultAsync();
var roles = await (from a in _context.UsersData.Where(a => a.Id == userId)
join b in _context.CompanyDatas on a.OrgID equals b.OrgID into TempData1
from c in TempData1
join d in _context.AppIdentityRoles on a.Id equals d.UserId into TempData2
from e in TempData2
join f in _context.UsersRole on e.RoleId equals f.Id into TempData3
from g in TempData3
select
new
{
RoleName = g.Name
}).ToListAsync();
string myS =
"WOCraftTL"
;
var status = await _context.WOMains.Where(s => s.WOMainID == womainid).Select(s => s.WOStatus).SingleOrDefaultAsync();
foreach (var a in roles)
{
if
(a.RoleName.Contains(myS) && status ==
"In Progress"
)
{
return
RedirectToPage(
"/WO/WOReport"
,
new
{ womainid = womainid });
}
else
{
var womainidP = await _context.WOMains.Where(s => s.WONumber == won && s.WONumberS == 0).Select(s => s.WOMainID).FirstOrDefaultAsync();
return
RedirectToPage(
"/WO/WOForm"
,
new
{ womainid = womainidP, woS = womainid, status = WOStatusT });
}
}
the user can have multiple roles, however, WOCraftTL is assigned, I verified that and the status for one specific item is "In Progress" but when I run the program the if doesn't work, always else is activated. What am I doing wrong?
Reply
Answers (
4
)
How to get values from old Session after changing the SessionId ?
Uploading an Excel File to MS ACCESS Table using FileUpload