public static void ReadOnlyViews() { ControllerTools.ResetExpectedName(); Main RootNode; IReadOnlyRootNodeIndex RootIndex; RootNode = CreateRoot(ValueGuid0, Imperfections.None); RootIndex = new ReadOnlyRootNodeIndex(RootNode); ReadOnlyController Controller = ReadOnlyController.Create(RootIndex); using (ReadOnlyControllerView ControllerView0 = ReadOnlyControllerView.Create(Controller)) { Assert.That(ControllerView0.Controller == Controller); Assert.That(ControllerView0.RootStateView == ControllerView0.StateViewTable[Controller.RootState]); using (ReadOnlyControllerView ControllerView1 = ReadOnlyControllerView.Create(Controller)) { Assert.That(ControllerView0.IsEqual(CompareEqual.New(), ControllerView0)); Assert.That(CompareEqual.CoverIsEqual(ControllerView0, ControllerView1)); } foreach (KeyValuePair <IReadOnlyBlockState, ReadOnlyBlockStateView> Entry in ControllerView0.BlockStateViewTable) { IReadOnlyBlockState BlockState = Entry.Key; Assert.That(BlockState != null); ReadOnlyBlockStateView BlockStateView = Entry.Value; Assert.That(BlockStateView != null); Assert.That(BlockStateView.ControllerView == ControllerView0); } foreach (KeyValuePair <IReadOnlyNodeState, IReadOnlyNodeStateView> Entry in ControllerView0.StateViewTable) { IReadOnlyNodeState State = Entry.Key; Assert.That(State != null); Assert.That(State.Comment != null); IReadOnlyNodeStateView StateView = Entry.Value; Assert.That(StateView != null); Assert.That(StateView.State == State); IReadOnlyIndex ParentIndex = State.ParentIndex; Assert.That(ParentIndex != null); Assert.That(Controller.Contains(ParentIndex)); Assert.That(StateView.ControllerView == ControllerView0); switch (StateView) { case ReadOnlyPatternStateView AsPatternStateView: Assert.That(AsPatternStateView.State == State); break; case ReadOnlySourceStateView AsSourceStateView: Assert.That(AsSourceStateView.State == State); break; case ReadOnlyPlaceholderNodeStateView AsPlaceholderNodeStateView: Assert.That(AsPlaceholderNodeStateView.State == State); break; case ReadOnlyOptionalNodeStateView AsOptionalNodeStateView: Assert.That(AsOptionalNodeStateView.State == State); break; } } } }
public async Task <ApiResponse <GetAllResponse <Product, ProductOutput> > > GetUnavailables() { return(await ReadOnlyController.GetUnavailables()); }
public async Task <ApiResponse <GetAllResponse <ProductRentalHistory, ProductRentalHistoryOutput> > > GetRentalHistory([FromQuery] Guid productId) { return(await ReadOnlyController.GetRentalHistory(productId)); }
public async Task <ApiResponse <CheckProductAvailabilityOutput> > CheckProductAvailability([FromQuery] Guid productId) { return(await ReadOnlyController.CheckProductAvailability(productId)); }
public async Task <ApiResponse <GetLastProductRentOutput> > GetLastRent([FromQuery] Guid productId) { return(await ReadOnlyController.GetLastRent(productId)); }
public async Task <ApiResponse <GetProductsPerRentAverageOutput> > GetProductsPerRentAverage(Guid renterId) { return(await ReadOnlyController.GetProductsPerRentAverage(renterId)); }
public async Task <ApiResponse <GetLastRenterRentOutput> > GetLastRent(Guid renterId) { return(await ReadOnlyController.GetLastRent(renterId)); }
public async Task <ApiResponse <GetAllResponse <RenterRentalHistoryOutput> > > GetRentalHistory(Guid renterId) { return(await ReadOnlyController.GetRentalHistory(renterId)); }
public async Task <ApiResponse <GetAllResponse <RenterOutput> > > GetBirthDaysOnPeriod(GetBirthDaysOnPeriodInput input) { return(await ReadOnlyController.GetBirthDaysOnPeriod(input)); }
static void BrowseNode(ReadOnlyController controller, IReadOnlyIndex index, Stats stats) { Assert.That(index != null, "ReadOnly #0"); Assert.That(controller.Contains(index), "ReadOnly #1"); IReadOnlyNodeState State = controller.IndexToState(index); Assert.That(State != null, "ReadOnly #2"); Assert.That(State.ParentIndex == index, "ReadOnly #4"); Node Node; if (State is IReadOnlyPlaceholderNodeState AsPlaceholderState) { Node = AsPlaceholderState.Node; } else if (State is IReadOnlyPatternState AsPatternState) { Node = AsPatternState.Node; } else if (State is IReadOnlySourceState AsSourceState) { Node = AsSourceState.Node; } else { Assert.That(State is IReadOnlyOptionalNodeState, "ReadOnly #5"); IReadOnlyOptionalNodeState AsOptionalState = (IReadOnlyOptionalNodeState)State; IReadOnlyOptionalInner ParentInner = AsOptionalState.ParentInner; //Assert.That(ParentInner.IsAssigned, "ReadOnly #6"); Node = AsOptionalState.Node; } stats.NodeCount++; Type ChildNodeType; IList <string> PropertyNames = NodeTreeHelper.EnumChildNodeProperties(Node); foreach (string PropertyName in PropertyNames) { if (NodeTreeHelperChild.IsChildNodeProperty(Node, PropertyName, out ChildNodeType)) { stats.PlaceholderNodeCount++; IReadOnlyPlaceholderInner Inner = (IReadOnlyPlaceholderInner)State.PropertyToInner(PropertyName); IReadOnlyNodeState ChildState = Inner.ChildState; IReadOnlyIndex ChildIndex = ChildState.ParentIndex; BrowseNode(controller, ChildIndex, stats); } else if (NodeTreeHelperOptional.IsOptionalChildNodeProperty(Node, PropertyName, out ChildNodeType)) { stats.OptionalNodeCount++; NodeTreeHelperOptional.GetChildNode(Node, PropertyName, out bool IsAssigned, out Node ChildNode); Debug.Assert(ChildNode is not null); //if (IsAssigned) { if (IsAssigned) { stats.AssignedOptionalNodeCount++; } IReadOnlyOptionalInner Inner = (IReadOnlyOptionalInner)State.PropertyToInner(PropertyName); IReadOnlyNodeState ChildState = Inner.ChildState; IReadOnlyIndex ChildIndex = ChildState.ParentIndex; BrowseNode(controller, ChildIndex, stats); } /*else * stats.NodeCount++;*/ } else if (NodeTreeHelperList.IsNodeListProperty(Node, PropertyName, out ChildNodeType)) { stats.ListCount++; IReadOnlyListInner Inner = (IReadOnlyListInner)State.PropertyToInner(PropertyName); for (int i = 0; i < Inner.StateList.Count; i++) { stats.PlaceholderNodeCount++; IReadOnlyPlaceholderNodeState ChildState = Inner.StateList[i]; IReadOnlyIndex ChildIndex = ChildState.ParentIndex; BrowseNode(controller, ChildIndex, stats); } } else if (NodeTreeHelperBlockList.IsBlockListProperty(Node, PropertyName, /*out Type ChildInterfaceType,*/ out ChildNodeType)) { stats.BlockListCount++; IReadOnlyBlockListInner Inner = (IReadOnlyBlockListInner)State.PropertyToInner(PropertyName); for (int BlockIndex = 0; BlockIndex < Inner.BlockStateList.Count; BlockIndex++) { IReadOnlyBlockState BlockState = Inner.BlockStateList[BlockIndex]; stats.PlaceholderNodeCount++; BrowseNode(controller, BlockState.PatternIndex, stats); stats.PlaceholderNodeCount++; BrowseNode(controller, BlockState.SourceIndex, stats); for (int i = 0; i < BlockState.StateList.Count; i++) { stats.PlaceholderNodeCount++; IReadOnlyPlaceholderNodeState ChildState = BlockState.StateList[i]; IReadOnlyIndex ChildIndex = ChildState.ParentIndex; BrowseNode(controller, ChildIndex, stats); } } } else { Type NodeType = Type.FromGetType(Node); PropertyInfo Info = NodeType.GetProperty(PropertyName); if (Info.PropertyType.IsTypeof <Document>()) { } else if (Info.PropertyType.IsTypeof <bool>()) { } else if (Info.PropertyType.IsEnum) { } else if (Info.PropertyType.IsTypeof <string>()) { } else if (Info.PropertyType.IsTypeof <Guid>()) { } else { Assert.That(false, $"State Tree unexpected property: {Info.PropertyType.Name}"); } } } }