public static FeatureFlags GetValidFlags(ModifyFeatureFlagsFlightViewModel model)
            {
                var flights = Flags.Flights.ToDictionary(f => f.Key, f => f.Value);

                flights.Remove(model.Name);

                return(new FeatureFlags(
                           Flags.Features,
                           flights));
            }
            public Task ReturnsViewWithFailureForExisting(bool hasLastUpdated, FeatureStatus status)
            {
                var model = new ModifyFeatureFlagsFlightViewModel
                {
                    Name      = Flight1Name,
                    ContentId = "c"
                };

                return(AssertFailure(
                           hasLastUpdated,
                           model,
                           GetTryAddExistingErrorMessage(model)));
            }
            public static FeatureFlags GetValidFlags(ModifyFeatureFlagsFlightViewModel model)
            {
                var flights = Flags.Flights.ToDictionary(f => f.Key, f => f.Value);
                var flight  = new Flight(
                    model.All,
                    model.SiteAdmins,
                    model.Accounts?.ToList() ?? new List <string>(),
                    model.Domains?.ToList() ?? new List <string>());

                flights[model.Name] = flight;

                return(new FeatureFlags(
                           Flags.Features,
                           flights));
            }
            public Task ReturnsViewWithValidationFailure(bool hasLastUpdated)
            {
                var missingAccount1 = "account1";
                var missingAccount2 = "account2";

                var flightName = "flighty-flight";
                var model      = new ModifyFeatureFlagsFlightViewModel
                {
                    Name     = flightName,
                    Accounts = new[] { missingAccount1, ExistingAccount, missingAccount2 }
                };

                return(AssertFailure(
                           hasLastUpdated,
                           model,
                           $"Some accounts specified by the flight '{flightName}' ({string.Join(", ", new[] { missingAccount1, missingAccount2 })}) do not exist. A flight cannot specify accounts that do not exist."));
            }
            public Task ReturnsViewWithFailureForMissing(bool hasLastUpdated, FeatureStatus status)
            {
                var model = new ModifyFeatureFlagsFlightViewModel
                {
                    Name       = "MissingFlight",
                    All        = true,
                    SiteAdmins = true,
                    Accounts   = new[] { ExistingAccount },
                    Domains    = new[] { "a.com", "b.com" },
                    ContentId  = "c"
                };

                return(AssertFailure(
                           hasLastUpdated,
                           model,
                           GetTryDeleteMissingErrorMessage(model)));
            }
 public Task <ActionResult> DeleteFlight(ModifyFeatureFlagsFlightViewModel flight)
 {
     return(MergeChangesAndTrySave <ModifyFeatureFlagsFlightViewModel, FeatureFlagsFlightViewModel>(
                flight,
                ChangeType.Delete));
 }
Example #7
0
 protected override Task <ActionResult> InvokeAsync(FeaturesController controller, ModifyFeatureFlagsFlightViewModel model)
 {
     return(controller.DeleteFlight(model));
 }