public ActionResult DailyBudget() { var isOwner = HttpContext.User.IsInRole("CompanyOwner"); ViewBag.Locked = isOwner; var swapBranding = false; if (isOwner) { var userId = _currentUser == null ? Guid.Empty : (Guid)(_currentUser.ProviderUserKey ?? Guid.Empty); using (var ctx = new MembershipConnection()) { swapBranding = ctx.UserFranchise .Where(uf => uf.UserId == userId) .ToArray() .Select(uf => (from f in db.tbl_Franchise where f.FranchiseID == uf.FranchiseID select f).SingleOrDefault()) .Any(f => f.FranchiseTypeID == 6); } } ViewBag.SwapBranding = swapBranding; return(View()); }
public JsonResult Franchises() { var userId = _currentUser == null ? Guid.Empty : (Guid)(_currentUser.ProviderUserKey ?? Guid.Empty); var isCorporate = User.IsInRole("Corporate"); int[] assignedFranchises; using (var ctx = new MembershipConnection()) { assignedFranchises = ctx.UserFranchise .Where(uf => uf.UserId == userId) .Select(f => f.FranchiseID) .ToArray(); } using (var db = GetAuditedContext()) { var franchises = db.tbl_Franchise .Where(f => isCorporate || assignedFranchises.Contains(f.FranchiseID)) .OrderBy(f => f.FranchiseNUmber) .Select(d => new { d.FranchiseID, Name = string.Concat(d.FranchiseNUmber, " - ", d.LegalName) }) .ToArray(); return(Json(new SelectList(franchises, "FranchiseID", "Name"), JsonRequestBehavior.AllowGet)); } }