public static DefinedCondition Fake(this DefinedCondition condition) { var fake = condition.Clone(); if (RandomBoolean) { fake.Hide = new Hide(); } if (RandomBoolean) { fake.Start = new StartDateTimeCondit() { DateTime = DateTime.Now } } ; if (RandomBoolean) { fake.End = new EndDateTimeCondit() { DateTime = DateTime.Now } } ; while (RandomBoolean) { fake.Communities.Add(new Community { Id = RandomName }); } while (RandomBoolean) { var city = new City { Name = RandomName }; while (RandomBoolean) { var area = new Area { Name = RandomName }; while (RandomBoolean) { area.Villages.Add(new Village { Name = RandomName }); } city.Areas.Add(area); } fake.Cities.Add(city); } return(fake); }
public async Task <ActionResult> PutDefined([FromRoute] string key, [FromBody] DefinedCondition defined) { var config = new ConfigCondition { Key = key, Defined = default }; _conditionDefined.TargetKey = key; await _configConditStrategy.SetAsync(_conditionDefined, config); return(Ok()); }
public ActionResult <List <ConfigCondition> > FakeCondition([FromQuery] int number) { var conditions = new List <ConfigCondition>(); for (int i = 0; i < number; i++) { var fake = new DefinedCondition().Fake(); var config = new ConfigCondition { Key = i.ToString(), Defined = fake }; conditions.Add(config); } return(Ok(conditions)); }