public bool UserIsAssociated(UserApplication editor, Abc.Services.Contracts.Application application) { Contract.Requires <ArgumentNullException>(null != editor); Contract.Requires <ArgumentNullException>(null != application); Contract.Requires <ArgumentNullException>(null != editor.User); Contract.Requires <ArgumentNullException>(null != editor.Application); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != editor.User.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != editor.Application.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != application.Identifier); using (new PerformanceMonitor()) { var source = new DomainSource(); var user = source.GetUserById(editor.Application.Identifier, editor.User.Identifier); if (null != user) { if (user.RoleValue == (int)RoleType.Manager) { return(true); } } var table = new AzureTable <ApplicationInfoData>(ServerConfiguration.Default); var data = table.QueryBy(string.Empty, application.Identifier.ToString()); if (null != data) { if (data.Owner == editor.User.Identifier) { return(true); } } return(this.Get(editor) != null); } }
public bool PermitApplicationCreation(Abc.Services.Contracts.Application application, User user) { Contract.Requires <ArgumentNullException>(null != user); Contract.Requires <ArgumentNullException>(null != application); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != application.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != user.Identifier); var source = new DomainSource(); var editorData = source.GetUserById(application.Identifier, user.Identifier); if (editorData.RoleValue == (int)RoleType.Manager) { return(true); } else { var editorPreference = new UserPreference() { User = user, Application = application, }; var userCore = new UserCore(); editorPreference = userCore.Get(editorPreference); return(editorPreference.MaximumAllowedApplications.HasValue && editorPreference.MaximumAllowedApplications.Value > this.ApplicationCount(user)); } }
public ActionResult Edit(FormCollection collection) { var twitterHandle = collection["TwitterHandle"]; if (string.IsNullOrWhiteSpace(twitterHandle)) { return(base.RedirectToAction("Index", "Home")); } else { var source = new DomainSource(); var user = source.GetUserByEmail(Application.Default.Identifier, base.User.Identity.Name); var preference = new UserPreference() { TwitterHandle = twitterHandle, User = user.Convert(), Application = Application.Default, }; var core = new UserCore(); core.Save(preference); return(this.Edit()); } }
public void InsertInvalidPartitionKey() { var source = new DomainSource(); var user = User(); user.PartitionKey = StringHelper.NullEmptyWhiteSpace(); source.Insert(user); }
public void InsertInvalidLastLoggedInOn() { var source = new DomainSource(); var user = User(); user.LastLoggedInOn = DateTime.UtcNow.AddDays(1); source.Insert(user); }
public void InsertInvalidNameIdentifier() { var source = new DomainSource(); var user = User(); user.NameIdentifier = StringHelper.NullEmptyWhiteSpace(); source.Insert(user); }
public void UpdateInvalidLastLockedOutOn() { var source = new DomainSource(); var user = User(); user.LastLockedOutOn = DateTime.UtcNow.AddDays(1); source.Update(user); }
public void UpdateInvalidPasswordLastChangedOn() { var source = new DomainSource(); var user = User(); user.PasswordLastChangedOn = DateTime.UtcNow.AddDays(1); source.Update(user); }
public void UpdateInvalidRoleValuePositive() { var source = new DomainSource(); var user = User(); user.RoleValue = 2; source.Update(user); }
public void UpdateInvalidRowKey() { var source = new DomainSource(); var user = User(); user.RowKey = StringHelper.NullEmptyWhiteSpace(); source.Update(user); }
public void InsertInvalidRoleValuePositive() { var source = new DomainSource(); var user = User(); user.RoleValue = 2; source.Insert(user); }
public void InsertInvalidRoleValueNegative() { var source = new DomainSource(); var user = User(); Random random = new Random(); user.RoleValue = random.Next(-1); source.Insert(user); }
public EnterRadioGraphyReport() : base() { InitializeComponent(); this.ExcludePropertiesFromTracking.Add("RGReport"); this.ExcludePropertiesFromTracking.Add("RGReportRows"); this.ExcludePropertiesFromTracking.Add("CanDelete"); this.ExcludePropertiesFromTracking.Add("RowsDeleted"); this.ExcludePropertiesFromTracking.Add("ThicknessRangeUI"); this.ExcludePropertiesFromTracking.Add("Thickness"); this.ExcludePropertiesFromTracking.Add("FilmSizeWithCount"); this.ExcludePropertiesFromTracking.Add("FilmSizeStringInCms"); this.ExcludePropertiesFromTracking.Add("FilmSizeWithCountInCms"); this.ExcludePropertiesFromTracking.Add("TotalAreaInCms"); this.ExcludePropertiesFromTracking.Add("RetakeReasonText"); this.OnCancelNavigation = "/RadiographyReports"; if (App.RGReport == null) { //Means new RG Report, allow add this.IsEditMode = false; //clerk or not string currentRole = WebContext.Current.User.Roles.FirstOrDefault(); if (currentRole.ToLower() == "clerk") { clerkMode = true; this.RGReportDataGrid.Visibility = Visibility.Collapsed; this.RGReportDataGridClerk.Visibility = Visibility.Visible; //make sure the rows are not frozen for the clerk-specific datagrid CustomGrid.IsEditAllowed = true; } } else { this.RGReport = App.RGReport; DataContext = this.RGReport; this.IsEditMode = true; //set the query parameter here, the binding in the xaml is not working fine this.EditRGReportsSource.QueryParameters[0].Value = this.RGReport.ID; } //wire up event handlers AddEventHandlers(); SetBindings(); if (IsEditMode) { DomainSource.Load(); } UpdateEnergyWiseArea(); }
/// <summary> /// Register user on site /// </summary> /// <param name="userIdentity">user Identity</param> /// <returns>New User</returns> private bool Register(IIdentity userIdentity) { using (new Service.PerformanceMonitor()) { if (userIdentity.IsAuthenticated) { var identity = (IClaimsIdentity)userIdentity; var register = new RegisterModel() { Email = User.Identity.EmailAddress(), NameIdentifier = User.Identity.NameIdentifier(), UserName = identity.Name, }; var source = new DomainSource(); UserData user = null; if (!string.IsNullOrWhiteSpace(register.NameIdentifier) && null != (user = source.GetUserByNameIdentifier(ServerConfiguration.ApplicationIdentifier, register.NameIdentifier))) { user.LastLoggedInOn = DateTime.UtcNow; user.LastActivityOn = DateTime.UtcNow; source.Update(user); } else if (!string.IsNullOrWhiteSpace(register.Email) && null != (user = source.GetUserByEmail(ServerConfiguration.ApplicationIdentifier, register.Email))) { user.LastLoggedInOn = DateTime.UtcNow; user.LastActivityOn = DateTime.UtcNow; user.NameIdentifier = register.NameIdentifier; source.Update(user); } else { var provider = new TableMembershipProvider(); MembershipCreateStatus status; provider.CreateUser(register.UserName, Guid.NewGuid().ToString(), register.Email, null, null, true, register.NameIdentifier, out status); if (status == MembershipCreateStatus.Success) { log.Log("New user signed up."); return(true); } else { log.Log("New user failed to signed up; status: '{0}'".FormatWithCulture(status)); } } } } return(false); }
public User GetByIdentifier(UserApplication userApp) { Contract.Requires <ArgumentNullException>(null != userApp); Contract.Requires <ArgumentNullException>(null != userApp.Application); Contract.Requires <ArgumentNullException>(null != userApp.User); Contract.Requires <ArgumentException>(Guid.Empty != userApp.Application.Identifier); Contract.Requires <ArgumentException>(Guid.Empty != userApp.User.Identifier); var source = new DomainSource(); var userData = source.GetUserById(userApp.Application.Identifier, userApp.User.Identifier); return(userData == null ? (User)null : userData.Convert()); }
public User GetByNameIdentifier(UserApplication userApp) { Contract.Requires <ArgumentNullException>(null != userApp); Contract.Requires <ArgumentNullException>(null != userApp.Application); Contract.Requires <ArgumentNullException>(null != userApp.User); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != userApp.Application.Identifier); Contract.Requires <ArgumentOutOfRangeException>(!string.IsNullOrWhiteSpace(userApp.User.NameIdentifier)); var source = new DomainSource(); var userData = source.GetUserByNameIdentifier(userApp.Application.Identifier, userApp.User.NameIdentifier); return(userData == null ? (User)null : userData.Convert()); }
public void UpdateUser() { var source = new DomainSource(); var user = User(); source.Insert(user); var saved = source.GetUserById(user.ApplicationId, user.Id); Assert.IsNotNull(saved); Assert.AreEqual <DateTime>(saved.CreatedOn, user.CreatedOn); Assert.AreEqual <DateTime>(saved.LastLoggedInOn, user.LastLoggedInOn); Assert.AreEqual <DateTime>(saved.LastActivityOn, user.LastActivityOn); Assert.AreEqual <DateTime>(saved.PasswordLastChangedOn, user.PasswordLastChangedOn); Assert.AreEqual <string>(saved.Email, user.Email); Assert.AreEqual <string>(saved.OpenId, user.OpenId); Assert.AreEqual <string>(saved.UserName, user.UserName); Assert.AreEqual <int>(saved.RoleValue, user.RoleValue); Assert.AreEqual <bool>(saved.IsApproved, user.IsApproved); Assert.AreEqual <bool>(saved.IsLockedOut, user.IsLockedOut); Assert.AreEqual <DateTime>(saved.LastLockedOutOn, user.LastLockedOutOn); var preUpdate = user; preUpdate.LastLoggedInOn = DateTime.UtcNow.AddHours(-34); preUpdate.IsLockedOut = true; preUpdate.IsApproved = false; preUpdate.LastActivityOn = DateTime.UtcNow.AddHours(-88); preUpdate.Email = StringHelper.ValidString(); preUpdate.OpenId = StringHelper.ValidString(); preUpdate.PasswordLastChangedOn = DateTime.UtcNow.AddHours(-22); source.Update(preUpdate); var updated = source.GetUserById(user.ApplicationId, user.Id); Assert.IsNotNull(preUpdate); Assert.AreEqual <DateTime>(preUpdate.CreatedOn, updated.CreatedOn); Assert.AreEqual <DateTime>(preUpdate.LastLoggedInOn.Date, updated.LastLoggedInOn.Date); Assert.AreEqual <DateTime>(preUpdate.LastActivityOn.Date, updated.LastActivityOn.Date); Assert.AreEqual <DateTime>(preUpdate.PasswordLastChangedOn.Date, updated.PasswordLastChangedOn.Date); Assert.AreEqual <string>(preUpdate.Email, updated.Email); Assert.AreEqual <string>(preUpdate.OpenId, updated.OpenId); Assert.AreEqual <string>(preUpdate.UserName, updated.UserName); Assert.AreEqual <int>(preUpdate.RoleValue, updated.RoleValue); Assert.AreEqual <bool>(preUpdate.IsApproved, updated.IsApproved); Assert.AreEqual <bool>(preUpdate.IsLockedOut, updated.IsLockedOut); Assert.AreEqual <DateTime>(preUpdate.LastLockedOutOn, updated.LastLockedOutOn); }
private bool Login(GitHubProfile profile) { var newUser = false; var register = new RegisterModel() { Email = profile.Email, NameIdentifier = string.Format("github{0}", profile.Id), UserName = profile.Name, }; var source = new DomainSource(); UserData user = null; if (!string.IsNullOrWhiteSpace(register.NameIdentifier) && null != (user = source.GetUserByNameIdentifier(Application.Default.Identifier, register.NameIdentifier))) { user.LastLoggedInOn = DateTime.UtcNow; user.LastActivityOn = DateTime.UtcNow; source.Update(user); } else if (!string.IsNullOrWhiteSpace(register.Email) && null != (user = source.GetUserByEmail(Application.Default.Identifier, register.Email))) { user.LastLoggedInOn = DateTime.UtcNow; user.LastActivityOn = DateTime.UtcNow; user.NameIdentifier = register.NameIdentifier; source.Update(user); } else { var provider = new TableMembershipProvider(); MembershipCreateStatus status; provider.CreateUser(register.UserName, Guid.NewGuid().ToString(), register.Email, null, null, true, register.NameIdentifier, out status); if (status == MembershipCreateStatus.Success) { log.Log("New user signed up."); newUser = true; } else { log.Log(string.Format("New user failed to signed up; status: '{0}'", status)); } } FormsAuthentication.SetAuthCookie(register.Email, true); return(newUser); }
private void FetchOperation(object sender, RoutedEventArgs e) { //ensure that the mandatory fields are filled if (String.IsNullOrEmpty(this.txtFPNo.Text) || String.IsNullOrEmpty(this.txtRTNo.Text) || this.cmbCoverage.SelectedIndex == -1) { MessageBox.Show("Please fill FP No, Coverage and RT No before fetching"); return; } this.IsEditMode = false; this.RGReportDataGrid.CommitEdit(); if (DomainSource.HasChanges) { DomainSource.RejectChanges(); } DomainSource.Load(); }
public ActionResult AddUserToTribe(string tribe) { try { if (string.IsNullOrWhiteSpace(tribe)) { return(this.Json(WebResponse.Bind((int)Fault.Unknown, "Tribe must be specified."), JsonRequestBehavior.AllowGet)); } var source = new DomainSource(); var user = source.GetUserByEmail(Application.Default.Identifier, base.User.Identity.Name); var core = new UserCore(); core.Save(user.Convert(), tribe); } catch (Exception ex) { logger.Log(ex, EventTypes.Warning, 999); return(this.Json(WebResponse.Bind((int)Fault.Unknown, ex.Message), JsonRequestBehavior.AllowGet)); } return(View()); }
public ActionResult Profile(FormCollection collection) { using (new Service.PerformanceMonitor()) { try { var preference = new UserPreference() { Application = Application.Current, User = User.Identity.Data(), }; var timeZoneId = collection["TimeZone.Id"]; preference = userCore.Get(preference); preference.TimeZone = TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); preference.TwitterHandle = collection["TwitterHandle"]; preference.GitHubHandle = collection["GitHubHandle"]; preference.AbcHandle = collection["AbcHandle"]; preference.Country = collection["Country"]; preference.City = collection["City"]; userCore.Save(preference); var source = new DomainSource(); var user = source.GetUserByNameIdentifier(Application.Current.Identifier, User.Identity.NameIdentifier()); user.Email = collection["Email"]; user.UserName = collection["UserName"]; user.LastActivityOn = DateTime.UtcNow; source.Update(user); } catch (Exception ex) { log.Log(ex, EventTypes.Warning, (int)Fault.Unknown); } return(this.Profile()); } }
public void GetUserById() { var source = new DomainSource(); var user = User(); source.Insert(user); var saved = source.GetUserById(user.ApplicationId, user.Id); Assert.IsNotNull(saved); Assert.AreEqual <DateTime>(saved.CreatedOn, user.CreatedOn); Assert.AreEqual <DateTime>(saved.LastLoggedInOn, user.LastLoggedInOn); Assert.AreEqual <DateTime>(saved.LastActivityOn, user.LastActivityOn); Assert.AreEqual <DateTime>(saved.PasswordLastChangedOn, user.PasswordLastChangedOn); Assert.AreEqual <string>(saved.Email, user.Email); Assert.AreEqual <string>(saved.OpenId, user.OpenId); Assert.AreEqual <string>(saved.UserName, user.UserName); Assert.AreEqual <int>(saved.RoleValue, user.RoleValue); Assert.AreEqual <bool>(saved.IsApproved, user.IsApproved); Assert.AreEqual <bool>(saved.IsLockedOut, user.IsLockedOut); Assert.AreEqual <DateTime>(saved.LastLockedOutOn, user.LastLockedOutOn); }
public FinalRadioGraphyReport() : base() { InitializeComponent(); if (App.FinalReport == null) { //Means we came here by mistake go to casting status page Navigate("/CastingStatusReport"); } else { this.FinalReport = App.FinalReport; //set the query parameter here, the binding in the xaml won't work fine this.DomainSource.QueryParameters[0].Value = this.FinalReport.RTNo; } //wire up event handlers AddEventHandlers(); SetBindings(); DomainSource.Load(); }
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { DomainSource.Load(); }
public void GetUserByUsernameInvalidUserName() { var source = new DomainSource(); source.GetUserByUserName(Guid.NewGuid(), StringHelper.NullEmptyWhiteSpace()); }
public void GetUserByUsernameInvalidApplicationId() { var source = new DomainSource(); source.GetUserByUserName(Guid.Empty, StringHelper.ValidString()); }
/// <summary> /// GitHub Auth API /// </summary> /// <remarks> /// GET: /Auth/GitHub /// </remarks> /// <returns></returns> public ActionResult GitHub() { var code = Request.Params["code"]; if (!string.IsNullOrWhiteSpace(code)) { try { string responseData = null; using (var client = new WebClient()) { var nameValuePairs = new NameValueCollection(); nameValuePairs.Add("code", code); nameValuePairs.Add("client_secret", ServerConfiguration.GitHubSecret); nameValuePairs.Add("client_id", ServerConfiguration.GitHubClientId); client.Headers.Add("content-type", "application/x-www-form-urlencoded"); var response = client.UploadValues(GitHubAuthorizationPost, nameValuePairs); responseData = client.Encoding.GetString(response); } if (!string.IsNullOrWhiteSpace(responseData)) { var gitHubResponse = GitHubResponse.Parse(responseData); string profileJson = null; using (var client = new WebClient()) { profileJson = client.DownloadString(string.Format(GitHubApi, "user", gitHubResponse.AccessToken)); } if (!string.IsNullOrWhiteSpace(profileJson)) { var serializer = new JavaScriptSerializer(); var profile = serializer.Deserialize <GitHubProfile>(profileJson); if (this.Login(profile)) //New User { var source = new DomainSource(); var user = source.GetUserByNameIdentifier(Application.Default.Identifier, string.Format("github{0}", profile.Id)); var preference = profile.Convert(); preference.Application = Application.Default; preference.User = user.Convert(); var core = new UserCore(); core.Save(preference); var profilePage = ((IConvert <ProfilePage>)profile).Convert(); profilePage.ApplicationIdentifier = Application.Default.Identifier; profilePage.OwnerIdentifier = user.Id; profilePage.GitCode = code; profilePage.GitAccessToken = gitHubResponse.AccessToken; core.Save(profilePage); return(this.RedirectToAction("Welcome", "Home")); } else { return(this.RedirectToAction("Index", "Profile", new { username = profile.Login })); } } } } catch (Exception ex) { log.Log(ex, Abc.Services.Contracts.EventTypes.Critical, (int)ServiceFault.Unknown); } } return(this.RedirectToAction("Index", "Auth")); }
public ActionResult Edit() { try { var source = new DomainSource(); var user = source.GetUserByEmail(Application.Default.Identifier, base.User.Identity.Name); if (null != user) { var preference = new UserPreference() { Application = Application.Default, User = user.Convert(), }; var userCore = new UserCore(); preference = userCore.Get(preference); var page = new ProfilePage() { ApplicationIdentifier = Application.Default.Identifier, Handle = preference.AbcHandle, }; page = userCore.Get(page); var profile = new UserProfile() { CreatedOn = user.CreatedOn, Gravatar = string.IsNullOrWhiteSpace(user.Email) ? null : user.Email.GetHexMD5(), UserName = user.UserName, Email = user.Email, TimeZone = preference.TimeZone, MaximumAllowedApplications = preference.MaximumAllowedApplications, CurrentApplicationIdentifier = preference.CurrentApplication == null ? Guid.Empty : preference.CurrentApplication.Identifier, TwitterHandle = preference.TwitterHandle, AbcHandle = preference.AbcHandle, City = preference.City, Country = preference.Country, GitHubHandle = preference.GitHubHandle, GitId = page.GitId, GitAvatarUrl = page.GitAvatarUrl, GitGravatarId = page.GitGravatarId, GitUrl = page.GitUrl, GitBlog = page.GitBlog, GitHireable = page.GitHireable, GitBiography = page.GitBiography, GitPublicGists = page.GitPublicGists, GitPublicRepos = page.GitPublicRepos, GitFollowers = page.GitFollowers, GitFollowing = page.GitFollowing, GitHtmlUrl = page.GitHtmlUrl, GitCreatedAt = page.GitCreatedAt, GitType = page.GitType, GitAccessToken = page.GitAccessToken, GitCode = page.GitCode, Word = page.Word, }; profile.TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(tz => new SelectListItem() { Text = tz.DisplayName, Value = tz.Id, Selected = tz.Id == profile.TimeZone.Id, }); return(View(profile)); } else { return(base.RedirectToAction("Index", "Home")); } } catch (Exception ex) { logger.Log(ex, EventTypes.Warning, 999); } return(base.RedirectToAction("Index", "Home")); }
public ApplicationInformation Save(ApplicationInformation data, UserApplication editor, Abc.Services.Contracts.Application application) { Contract.Requires <ArgumentNullException>(null != data); Contract.Requires <ArgumentNullException>(null != editor); Contract.Requires <ArgumentNullException>(null != editor.Application); Contract.Requires <ArgumentNullException>(null != editor.User); Contract.Requires <ArgumentNullException>(null != application); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != data.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != editor.Application.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != editor.User.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != application.Identifier); Contract.Ensures(Contract.Result <ApplicationInformation>() != null); using (new PerformanceMonitor()) { var source = new DomainSource(); var editorData = source.GetUserById(application.Identifier, editor.User.Identifier); var serverDetails = ((IConvert <Details>)data).Convert(); if (data.IsNew) { if (this.PermitApplicationCreation(application, editor.User)) { if (data.IsNew) { serverDetails.IsValid = true; app.Create(serverDetails); if (userApplicationCache.ContainsKey(editor.User.Identifier)) { userApplicationCache.Remove(editor.User.Identifier); } } } else { Logging.Log("User tried to create an application without authorization."); } } else { if (editorData.RoleValue == (int)RoleType.Manager) { app.Update(serverDetails); if (userApplicationCache.ContainsKey(editor.User.Identifier)) { userApplicationCache.Remove(editor.User.Identifier); } } else { Logging.Log("User tried to update an application without authorization."); } } var appInfoData = ((IConvert <ApplicationInfoData>)data).Convert(); appInfoData.Load(editorData); var table = new AzureTable <ApplicationInfoData>(ServerConfiguration.Default, new ApplicationInfoValidator()); var existing = this.Get(appInfoData); if (null != existing) { existing.Environment = appInfoData.Environment; existing.Name = appInfoData.Name; existing.Description = appInfoData.Description; existing.Deleted = appInfoData.Deleted; existing.Active = appInfoData.Active; appInfoData = existing; } else { appInfoData.CreatedBy = editor.User.Identifier; appInfoData.Owner = editor.User.Identifier; appInfoData.CreatedOn = DateTime.UtcNow; } appInfoData.LastUpdatedBy = editor.User.Identifier; appInfoData.LastUpdatedOn = DateTime.UtcNow; table.AddOrUpdateEntity(appInfoData); if (data.IsNew && editorData.RoleValue == (int)RoleType.Client) { var save = new Abc.Services.Contracts.Application() { Identifier = serverDetails.ApplicationId, }; var ua = new UserApplication() { Application = save, User = editor.User, Deleted = false, Active = true, }; this.Save(ua, editor); } return(data); } }
public IList <ApplicationInformation> Get(User user, Guid applicationId) { Contract.Requires <ArgumentNullException>(null != user); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != user.Identifier); Contract.Requires <ArgumentOutOfRangeException>(Guid.Empty != applicationId); using (new PerformanceMonitor()) { if (userApplicationCache.ContainsKey(user.Identifier)) { return(userApplicationCache[user.Identifier]); } else { var source = new DomainSource(); var webUser = source.GetUserById(applicationId, user.Identifier); var allAppDetails = app.Search(); if (null != allAppDetails) { IList <Details> usersAppDetails = null; var role = (RoleType)webUser.RoleValue; switch (role) { case RoleType.Client: var appTable = new AzureTable <ApplicationInfoData>(ServerConfiguration.Default); var userApplications = (from data in appTable.QueryByPartition(ApplicationInfoData.Key) where data.Owner == webUser.Id select data).ToList(); var table = new AzureTable <UserApplicationData>(ServerConfiguration.Default); var assignedUsers = table.QueryByPartition(webUser.Id.ToString()).ToList(); usersAppDetails = (from all in allAppDetails where userApplications.Any(ua => ua.ApplicationId == all.ApplicationId) || assignedUsers.Any(ua => ua.ApplicationId == all.ApplicationId) select all).ToList(); break; case RoleType.Manager: usersAppDetails = allAppDetails.ToList(); break; default: Logging.Log("Unknown Role Type."); break; } if (null != usersAppDetails) { var infos = new List <ApplicationInformation>(usersAppDetails.Count); foreach (var usersApp in usersAppDetails) { var info = this.Get(new ApplicationInfoData(usersApp.ApplicationId)); ApplicationInformation appInfo; if (null == info) { appInfo = new ApplicationInformation() { Identifier = usersApp.ApplicationId, }; } else { appInfo = info.Convert(); } appInfo.Load(usersApp); infos.Add(appInfo); } if (!userApplicationCache.ContainsKey(user.Identifier) && null != infos && 0 < infos.Count) { userApplicationCache.Add(user.Identifier, infos); } return(infos); } } return(null); } } }