/// <summary> /// Constructor /// </summary> public ApiResponse(SessionAuthUser authUser, ApiRequest request) : base(authUser) { if (request == null) throw new ArgumentNullException("request"); TrackingID = request.TrackingID; Function = request.Function; ErrorMessages = new StringList(); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static DiscussionForumDataList ViewForums(SessionAuthUser authUser) { ForumController controller = BaseCallController.GetController<ForumController>(authUser); ActionResult actionResult = controller.ViewForums(); DiscussionForumDataList model = AssertModel<DiscussionForumDataList, DiscussionForumData>(actionResult, PageLevel.Development); Assert.IsNotNull(model); Assert.AreNotEqual(0, model.Count); return model; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void EditSubscription(SessionAuthUser authUser) { ClientController controller = GetController<ClientController>(authUser); ActionResult actionResult = controller.EditSubscription(); ClientData model = AssertModel<ClientData>(actionResult); Assert.IsNull(model.Addresses); model.LegalName = String.Empty; controller = GetController<ClientController>(authUser, model, ClientController.EditSubscriptionAction); actionResult = controller.EditSubscription(model); AssertModel<ClientData>(actionResult); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static AddressData AddAddressBadData(SessionAuthUser authUser, AddressData template) { string originalName = template.Name; template.Name = String.Empty; AddressController controller = GetController<AddressController>(authUser, template, AddressController.AddAddressAction); ActionResult result = controller.AddAddress(template); Assert.IsNotNull(result); ViewResult viewResult = result as ViewResult; AddressData model = AssertModel<AddressData>(viewResult); model.Name = originalName; return model; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static Address CreateAddress(SessionAuthUser authUser, string name, string addressLine1, string addressLine2, string city, string zip) { AddressData template = CallAddressController.GetAddAddressTemplate(authUser); template = CallAddressController.AddAddressBadData(authUser, template); template.Name = name; template.AddressLine1 = addressLine1; template.AddressLine2 = addressLine2; template.City = city; template.ZipCode = zip; return CallAddressController.AddAddress(authUser, template); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static ApiResponse CallApi(SessionAuthUser authUser, string function, object dataObject = null) { CommonApiController controller = BaseCallApiController.GetController<CommonApiController>(); ApiRequest request = new ApiRequest(authUser, function); request.DataObject = dataObject; IHttpActionResult actionResult = controller.ProcessRequest(request); ApiResponse response = AssertAsValid<ApiResponse>(actionResult); Assert.IsNotNull(response.DataObject); return response; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void EditConfiguration(SessionAuthUser authUser) { //ClientController controller = GetController<ClientController>(authUser); //ActionResult actionResult = controller.EditConfiguration(); //ClientConfigurationTypeDataList model = AssertModel<ClientConfigurationTypeDataList, ClientConfigurationTypeData>(actionResult); //model.NextBatchNumber = Int32.MinValue; //controller = GetController<ClientController>(authUser, model, ClientController.EditConfigurationAction); //Assert.IsNull(model.TTBReports); //actionResult = controller.EditConfiguration(model); //model = AssertModel<ClientConfigurationData>(actionResult); //Assert.IsNotNull(model.TTBReports); throw new NotImplementedException(); }
/// <summary> /// Changes the active client for the specified user. /// </summary> public MethodStatus ChangeActiveClient(string identityUser, int clientID, out SessionAuthUser updatedAuthUser) { updatedAuthUser = null; SystemUser systemUser = FindSystemUser(identityUser); if (systemUser == null) return MethodStatus.InvalidData; Client client = Context.FindSystemItem<Client>(clientID); if (client == null) return MethodStatus.InvalidData; IQueryable<ClientAuthorization> allItems = Context.GetAllSystem<ClientAuthorization>(); ClientAuthorization auth = (from item in allItems where (item.SystemUserID == systemUser.ID) && (item.ClientID == clientID) select item).FirstOrDefault(); if (auth == null) { if (systemUser.IsAdministrator) { auth = GetNewApplicationClientAuthorization(systemUser); auth.ClientID = client.ID; auth.SystemUserID = systemUser.ID; } else return MethodStatus.NotAuthorized; } auth.IsActiveClient = true; IQueryable<ClientAuthorization> userItems = (from item in allItems where (item.SystemUserID == systemUser.ID) select item); foreach (ClientAuthorization current in userItems) { if (current.ID != auth.ID) current.IsActiveClient = false; } Context.SaveChanges(); updatedAuthUser = GetAuthUser(identityUser); return MethodStatus.Pass; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static Address AddAddress(SessionAuthUser authUser, AddressData template) { MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); List<int> ids = BaseCallController.GetIdList<Address>(context); AddressController controller = GetController<AddressController>(authUser, template, AddressController.AddAddressAction); ActionResult result = controller.AddAddress(template); AssertRedirect(result, ClientController.ViewSubscriptionAction, ClientController.Controller); Address foundItem = BaseCallController.FindNewItem<Address>(context, ids); Assert.AreEqual(template.Name, foundItem.Name); Assert.AreEqual(template.AddressLine1, foundItem.AddressLine1); Assert.AreEqual(template.AddressLine2, foundItem.AddressLine2); Assert.AreEqual(template.City, foundItem.City); Assert.AreEqual(template.ZipCode, foundItem.ZipCode); Assert.AreEqual(RecordVisibility.Active, foundItem.Visibility); return foundItem; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void CancelSubscription(SessionAuthUser authUser) { ClientController controller = GetController<ClientController>(authUser); ActionResult actionResult = controller.CancelSubscription(); ClientCancellationData model = AssertModel<ClientCancellationData>(actionResult); controller = GetController<ClientController>(authUser, model, ClientController.CancelSubscriptionAction); actionResult = controller.CancelSubscription(model); model = AssertModel<ClientCancellationData>(actionResult); Assert.IsNotNull(model.Client); model.ConfirmCancellation = true; controller = GetController<ClientController>(authUser, model, ClientController.CancelSubscriptionAction); actionResult = controller.CancelSubscription(model); AssertRedirect(actionResult, ClientController.ViewSubscriptionAction, ClientController.Controller); MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); Client foundClient = context.FindClient(); Assert.IsNotNull(foundClient); Assert.AreEqual(ClientStatus.Cancelled, foundClient.Status); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static Address EditAddress(SessionAuthUser authUser, AddressData template) { MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); AddressController controller = GetController<AddressController>(authUser, template, AddressController.EditAddressAction); ActionResult result = controller.EditAddress(template); AssertRedirect(result, ClientController.ViewSubscriptionAction, ClientController.Controller); Address foundItem = context.FindClientItem<Address>(template.ID); if (template.Visibility == RecordVisibility.Deleted) { Assert.IsNull(foundItem); } else { Assert.AreEqual(template.Name, foundItem.Name); Assert.AreEqual(template.AddressLine1, foundItem.AddressLine1); Assert.AreEqual(template.AddressLine2, foundItem.AddressLine2); Assert.AreEqual(template.City, foundItem.City); Assert.AreEqual(template.ZipCode, foundItem.ZipCode); Assert.AreEqual(template.Visibility, foundItem.Visibility); } return foundItem; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void UpdateBilling(SessionAuthUser authUser, CheckingAccountType accountType, string routingNumber, string accountNumber, string bankName, string street, string city, string state, string zip, string country) { MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); ClientController controller = GetController<ClientController>(authUser); ActionResult actionResult = controller.UpdateBilling(); UpdateBillingTemplate model = AssertModel<UpdateBillingTemplate>(actionResult); //model.BankName = String.Empty; // controller = GetController<ClientController>(authUser, model, ClientController.UpdateBillingAction, ignoreValidation: true); //actionResult = controller.UpdateBilling(model); //model = AssertModel<UpdateBillingTemplate>(actionResult); model.AccountType = accountType; model.RoutingNumber = routingNumber; model.RoutingNumberConfirm = routingNumber; model.AccountNumber = accountNumber; model.AccountNumberConfirm = accountNumber; model.BankName = bankName; model.Street = street; model.City = city; model.State = state; model.Zip = zip; model.Country = country; controller = GetController<ClientController>(authUser, model, ClientController.UpdateBillingAction, ignoreValidation: true); actionResult = controller.UpdateBilling(model); AssertRedirect(actionResult, ClientController.ViewSubscriptionAction, ClientController.Controller); Client client = context.FindClient(); Assert.IsNotNull(client); Assert.IsTrue(client.BillingConfigured); if (client.IsMemberOfProgram(CoreConstants.PROGRAM_EARLY_ADOPTER_ID)) Assert.AreEqual(BillingInterval.Annual, client.BillingInterval); else Assert.AreEqual(BillingInterval.Monthly, client.BillingInterval); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void ViewEditions(SessionAuthUser authUser) { ClientController controller = GetController<ClientController>(authUser); ViewResult viewResult = controller.ViewEditions() as ViewResult; AssertModel<PageLevelModel>(viewResult); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static AddressDataList ViewAddresses(SessionAuthUser authUser) { AddressController controller = BaseCallController.GetController<AddressController>(authUser); ActionResult actionResult = controller.ViewAddresses(null); return AssertModel<AddressDataList, AddressData>(actionResult); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static ClientSignupData GetSignupTemplate(SessionAuthUser authUser) { ClientController controller = GetController<ClientController>(authUser); ActionResult result = controller.SignUp(); Assert.IsNotNull(result); ViewResult viewResult = result as ViewResult; return AssertModel<ClientSignupData>(viewResult); }
public void SessionAuthUserAccessTest() { SessionAuthUser authUser = new SessionAuthUser("UNIT_TEST", 1, "Tester", "Mr. Tester", 1); Assert.IsNotNull(authUser); IntList allAcceessLevelIds = new IntList(); allAcceessLevelIds.Add(CoreConstants.MODULE_ADMINISTRATION_ACCESS_NONE); allAcceessLevelIds.Add(CoreConstants.MODULE_ADMINISTRATION_ACCESS_READ_ONLY); allAcceessLevelIds.Add(CoreConstants.MODULE_ADMINISTRATION_ACCESS_EDIT); allAcceessLevelIds.Add(CoreConstants.MODULE_ADMINISTRATION_ACCESS_FULL); allAcceessLevelIds.Add(CoreConstants.MODULE_AUTH_ACCESS_NONE); allAcceessLevelIds.Add(CoreConstants.MODULE_AUTH_ACCESS_READ_ONLY); allAcceessLevelIds.Add(CoreConstants.MODULE_AUTH_ACCESS_EDIT); allAcceessLevelIds.Add(CoreConstants.MODULE_AUTH_ACCESS_FULL); allAcceessLevelIds.Add(CoreConstants.MODULE_BILLING_ACCESS_NONE); allAcceessLevelIds.Add(CoreConstants.MODULE_BILLING_ACCESS_READ_ONLY); allAcceessLevelIds.Add(CoreConstants.MODULE_BILLING_ACCESS_EDIT); allAcceessLevelIds.Add(CoreConstants.MODULE_BILLING_ACCESS_FULL); allAcceessLevelIds.Add(CoreConstants.MODULE_SAAS_ACCESS_NONE); allAcceessLevelIds.Add(CoreConstants.MODULE_SAAS_ACCESS_READ_ONLY); allAcceessLevelIds.Add(CoreConstants.MODULE_SAAS_ACCESS_EDIT); allAcceessLevelIds.Add(CoreConstants.MODULE_SAAS_ACCESS_FULL); allAcceessLevelIds.Add(CoreConstants.MODULE_GLOBAL_ACCESS_NONE); allAcceessLevelIds.Add(CoreConstants.MODULE_GLOBAL_ACCESS_READ_ONLY); allAcceessLevelIds.Add(CoreConstants.MODULE_GLOBAL_ACCESS_EDIT); allAcceessLevelIds.Add(CoreConstants.MODULE_GLOBAL_ACCESS_FULL); IntList acceessLevelIds = new IntList(); authUser.AccessLevels = new IntList(); foreach (int acceessLevelID in acceessLevelIds) Assert.IsFalse(authUser.IsAuthorized(acceessLevelID), "Default access should be off"); #region Administrator Check authUser.IsAdministrator = true; foreach (int acceessLevelID in allAcceessLevelIds) Assert.IsTrue(authUser.IsAuthorized(acceessLevelID), "IsAdministrator should have access to all"); authUser.IsAdministrator = false; foreach (int acceessLevelID in allAcceessLevelIds) Assert.IsFalse(authUser.IsAuthorized(acceessLevelID), "IsAdministrator turned off should disable access to all"); #endregion #region Limited Access Check authUser.AccessLevels = new IntList(); authUser.AccessLevels.Add(CoreConstants.MODULE_AUTH_ACCESS_NONE); authUser.AccessLevels.Add(CoreConstants.MODULE_AUTH_ACCESS_READ_ONLY); authUser.AccessLevels.Add(CoreConstants.MODULE_AUTH_ACCESS_EDIT); foreach (int acceessLevelIDtoCheck in allAcceessLevelIds) { bool isAuthorized = authUser.IsAuthorized(acceessLevelIDtoCheck); bool shouldBeAuthorized = ( (acceessLevelIDtoCheck == CoreConstants.MODULE_AUTH_ACCESS_NONE) || (acceessLevelIDtoCheck == CoreConstants.MODULE_AUTH_ACCESS_READ_ONLY) || (acceessLevelIDtoCheck == CoreConstants.MODULE_AUTH_ACCESS_EDIT) ); Assert.AreEqual(isAuthorized, shouldBeAuthorized, "Failed to correctly authorize the only set item."); } #endregion }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static Client SignUp(SessionAuthUser authUser, int subscriptionTypeID, int subscriptionLevelID, string acronym, string legalName, string companyName, string website, string addressLine1, string addressLine2, string city, string zipCode, bool eulaAccepted) { MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); List<int> ids = BaseCallController.GetSystemIdList<Client>(context); ClientController controller = GetController<ClientController>(authUser); ActionResult actionResult = controller.SignUp(); ClientSignupData model = AssertModel<ClientSignupData>(actionResult); controller = GetController<ClientController>(authUser, model, ClientController.SignUpAction); Assert.IsNull(model.SubscriptionLevelOptions); Assert.IsNull(model.SubscriptionTypeOptions); actionResult = controller.SignUp(model); model = AssertModel<ClientSignupData>(actionResult); Assert.IsNotNull(model.SubscriptionLevelOptions); Assert.IsNotNull(model.SubscriptionTypeOptions); model.SubscriptionTypeID = subscriptionTypeID; model.SubscriptionLevelID = subscriptionLevelID; model.Acronym = acronym; model.LegalName = legalName; model.CompanyName = companyName; model.AddressLine1 = addressLine1; model.AddressLine2 = addressLine2; model.City = city; model.ZipCode = zipCode; model.EulaAccepted = eulaAccepted; controller = GetController<ClientController>(authUser, model, ClientController.SignUpAction); actionResult = controller.SignUp(model); AssertRedirect(actionResult, ClientController.UpdateBillingAction, ClientController.Controller); Client foundItem = BaseCallController.FindNewSystemItem<Client>(context, ids); Assert.IsNotNull(foundItem); authUser.OperateAsClientID = foundItem.ID; Assert.AreEqual(subscriptionTypeID, foundItem.SubscriptionTypeID); Assert.AreEqual((int)subscriptionLevelID, foundItem.SubscriptionLevelID); Assert.AreEqual(acronym, foundItem.Acronym); Assert.AreEqual(legalName, foundItem.LegalName); Assert.AreEqual(companyName, foundItem.CompanyName); Address foundAddress = context.GetAllClient<Address>().FirstOrDefault(); Assert.IsNotNull(foundAddress); Assert.AreEqual(addressLine1, foundAddress.AddressLine1); Assert.AreEqual(addressLine2, foundAddress.AddressLine2); Assert.AreEqual(city, foundAddress.City); Assert.AreEqual(zipCode, foundAddress.ZipCode); //Assert.AreEqual(1, foundItem.ClientBillingDetails.Count); //ClientBillingDetail currentBilling = foundItem.ClientBillingDetails.FirstOrDefault(); //if (joinEarlyAdopterProgram) // Assert.AreEqual(12, currentBilling.BillingIntervalInMonths); //else // Assert.AreEqual(1, currentBilling.BillingIntervalInMonths); //Assert.IsTrue(currentBilling.BillingProfileID.IsNotNullOrEmptyTrimmed()); //Assert.IsTrue(currentBilling.PaymentProfileID.IsNotNullOrEmptyTrimmed()); //if (joinEarlyAdopterProgram) // Assert.AreEqual(12, currentBilling.BillingIntervalInMonths); //else // Assert.AreEqual(1, currentBilling.BillingIntervalInMonths); return foundItem; }
/// <summary> /// Gets the current client for the specified user. /// </summary> public SessionAuthUser GetAuthUser(string identityUser) { if (identityUser.IsNullOrEmptyTrimmed()) return null; SystemUser systemUser = FindSystemUser(identityUser); ClientAuthorization auth = null; int systemUserID = 0; if (systemUser != null) { systemUserID = systemUser.ID; auth = FindActivePermission(systemUser); } SessionAuthUser authUser = null; if (auth != null) { authUser = new SessionAuthUser(identityUser, systemUser.ID, systemUser.Nickname, systemUser.Name, auth.ClientID, GetActiveToggles(auth.ClientID, systemUser.IsAdministrator)); authUser.AccessLevels = new IntList(); foreach (ClientAuthorizationAccess currentAccess in auth.AccessLevels) authUser.AccessLevels.Add(currentAccess.AccessLevelID); } else if (systemUser != null) { authUser = new SessionAuthUser(identityUser, systemUser.ID, systemUser.Nickname, systemUser.Name, CoreConstants.SHARED_CLIENT_ID); } if (authUser == null) authUser = new SessionAuthUser(identityUser, 0, "Visitor", "", Context.SharedClientID); if ((systemUser != null) && (authUser != null)) { systemUser.LastLogin = DateTime.UtcNow; Context.SaveChanges(); authUser.TimeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(systemUser.LocalTimeZone.SystemID); authUser.IsAdministrator = systemUser.IsAdministrator; foreach (SystemUserPreference current in systemUser.Preferences) { switch (current.Preference) { case UserPreferenceOption.HideHelpText: authUser.SetUserPreference(current.Preference, current.BoolValue); break; case UserPreferenceOption.DefaultScheduleDaysToShow: authUser.SetUserPreference(current.Preference, current.IntValue); break; default: throw new InvalidOptionException(typeof(UserPreferenceOption), current.Preference); } } } return authUser; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void ViewSubscription(SessionAuthUser authUser) { ClientController controller = GetController<ClientController>(authUser); ViewResult viewResult = controller.ViewSubscription(null) as ViewResult; ClientData model = AssertModel<ClientData>(viewResult); Assert.IsNull(viewResult.ViewBag.SelectAddressID); controller = GetController<ClientController>(authUser); viewResult = controller.ViewSubscription(5) as ViewResult; AssertModel<ClientData>(viewResult); Assert.AreEqual(5, viewResult.ViewBag.SelectAddressID); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void ViewUsers(SessionAuthUser authUser) { ClientController controller = GetController<ClientController>(authUser); ActionResult actionResult = controller.ViewUsers(); AssertModel<ClientAuthorizationDataList, ClientAuthorizationData>(actionResult); }
/// <summary> /// Constructor /// </summary> protected BaseApiCall(SessionAuthUser authUser) { if (authUser != null) UserIdentifier = authUser.IdentityID; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void JoinProgram(SessionAuthUser authUser, int clientProgramID) { MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); List<int> ids = BaseCallController.GetIdList<ClientProgramMembership>(context); ClientController controller = GetController<ClientController>(authUser); ActionResult actionResult = controller.JoinProgram(clientProgramID); AssertModel<ClientProgramData>(actionResult); actionResult = controller.ConfirmJoinProgram(clientProgramID); AssertRedirect(actionResult, ClientController.ViewSubscriptionAction, ClientController.Controller); ClientProgramMembership foundItem = BaseCallController.FindNewItem<ClientProgramMembership>(context, ids); Assert.IsNotNull(foundItem); Assert.AreEqual(clientProgramID, foundItem.ProgramID); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static AddressData GetAddAddressTemplate(SessionAuthUser authUser) { AddressController controller = BaseCallController.GetController<AddressController>(authUser); ActionResult result = controller.AddAddress(); Assert.IsNotNull(result); ViewResult viewResult = result as ViewResult; return AssertModel<AddressData>(viewResult); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static AddressData GetEditAddressTemplate(SessionAuthUser authUser, Address address) { AddressController controller = BaseCallController.GetController<AddressController>(authUser); ActionResult result = controller.EditAddress(address.ID); Assert.IsNotNull(result); ViewResult viewResult = result as ViewResult; AddressData model = AssertModel<AddressData>(viewResult); Assert.AreEqual(address.ID, model.ID); return model; }
/// <summary> /// Constructor /// </summary> public ApiRequest(SessionAuthUser authUser, string function) : base(authUser) { TrackingID = Guid.NewGuid(); Function = function; }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static Address UpdateAddress(SessionAuthUser authUser, Address address, string name, string addressLine1, string addressLine2, string city, string zip, RecordVisibility visibility) { AddressData template = CallAddressController.GetEditAddressTemplate(authUser, address); template.Name = String.Empty; template = CallAddressController.EditAddressBadData(authUser, template); template.Name = name; template.AddressLine1 = addressLine1; template.AddressLine2 = addressLine2; template.City = city; template.ZipCode = zip; template.Visibility = visibility; return CallAddressController.EditAddress(authUser, template); }
/// <summary> /// Initializes the user. /// </summary> public void InitializeUser(SessionAuthUser authUser) { AuthUser = authUser; if ((AuthUser == null) || (AuthUser.SystemUserID == 0)) { var store = new UserStore<ApplicationUser>(new AuthenticationDbContext()); var userManager = new UserManager<ApplicationUser>(store); ApplicationUser user = userManager.FindByIdAsync(User.Identity.GetUserId()).Result; if (user == null) return; string nickname = user.UserName; if (nickname.Contains(" ")) nickname = user.UserName.Substring(0, user.UserName.IndexOf(" ")); if (nickname.Length > 30) nickname = nickname.Substring(0, 30); using (AuthManager authManager = PublicConfigurationSettings.GetAuthManager.Invoke()) { authManager.RegisterUser(User.Identity.GetUserId(), nickname, user.UserName, user.PhoneNumber, user.Email); AuthUser = authManager.GetAuthUser(User.Identity.GetUserId()); } } ViewBag.AuthUser = AuthUser; bool hasClient = PublicLogicManager.Client.CurrentUserHasClient(); ViewBag.HasClient = hasClient; ViewBag.UserNickname = AuthUser.Nickname; if (hasClient) { ClientData client = PublicLogicManager.Client.LoadClientModel(false); ViewBag.ClientName = client.CompanyName; ViewBag.Client = client; ViewBag.Build = BuildNumber; } PerformClientLogic(); }
/// <summary> /// Calls the listed endpoint on this controller. /// </summary> public static void EnableToggle(SessionAuthUser authUser, FeatureToggleType toggleType) { authUser.EnabledToggles.Add(toggleType); MultiTenantDataContext context = PublicLogicManager.DataContextFactory.Invoke(authUser); IQueryable<EnabledFeatureToggle> allToggles = context.GetAllClient<EnabledFeatureToggle>(); EnabledFeatureToggle existingToggle = (from item in allToggles where (item.ClientID == authUser.ClientID) && (item.ToggleType == toggleType) select item).FirstOrDefault(); if (existingToggle != null) return; existingToggle = context.NewClient<EnabledFeatureToggle>(); existingToggle.ToggleType = toggleType; context.SaveChanges(); }