Exemplo n.º 1
0
 public void Setup()
 {
     categoriesClient    = Substitute.For <ICategoriesClient>();
     dashboardsClient    = Substitute.For <IDashboardsClient>();
     httpContextAccessor = Substitute.For <IHttpContextAccessor>();
     mapper = new Mapper(new MapperConfiguration(o => o.AddProfile <WebApiProfile>()));
 }
Exemplo n.º 2
0
 public ListModel(INotesClient client, ICategoriesClient tagsClient, IUsersClient usersClient, IIdentityDataGetter idData)
 {
     this.client      = client;
     this.tagsClient  = tagsClient;
     this.usersClient = usersClient;
     this.idData      = idData;
 }
 public CategoriesProxyService(ICategoriesClient categoriesClient, IDashboardsClient dashboardsClient, IHttpContextAccessor httpContextAccessor, IMapper mapper)
 {
     this.categoriesClient    = categoriesClient;
     this.dashboardsClient    = dashboardsClient;
     this.httpContextAccessor = httpContextAccessor;
     this.mapper = mapper;
 }
Exemplo n.º 4
0
 public IndexModel(IRelationsClient client, INotesClient nodesClient, ICategoriesClient tagsClient, IIdentityDataGetter idData)
 {
     this.client      = client;
     this.nodesClient = nodesClient;
     this.idData      = idData;
     this.tagsClient  = tagsClient;
 }
Exemplo n.º 5
0
 public ViewModel(ICategoriesClient client, INotesClient nodesClient, IRelationsClient relationsClient, IUsersClient usersClient, IIdentityDataGetter idData)
 {
     this.client          = client;
     this.nodesClient     = nodesClient;
     this.idData          = idData;
     this.relationsClient = relationsClient;
     this.usersClient     = usersClient;
 }
Exemplo n.º 6
0
 public IndexModel(ICategoriesClient tagsClient, INotesClient nodesClient, IRelationsClient relationsClient, IUsersClient usersClient, IIdentityDataGetter idData)
 {
     this.tagsClient      = tagsClient;
     this.nodesClient     = nodesClient;
     this.idData          = idData;
     this.relationsClient = relationsClient;
     this.usersClient     = usersClient;
 }
 public MonitoredSystemEventServiceClient(
     ILogger <MonitoredSystemEventServiceClient> logger,
     ISystemEventsClient systemEventsClient,
     ICategoriesClient categoriesClient
     ) : base(logger)
 {
     _systemEventsClient = systemEventsClient ?? throw new ArgumentNullException(nameof(systemEventsClient));
     _categoriesClient   = categoriesClient ?? throw new ArgumentNullException(nameof(categoriesClient));
 }
Exemplo n.º 8
0
 public async Task LoadCategory(ICategoriesClient client, string token)
 {
     if (Data.CategoryId.HasValue)
     {
         Category = await client.Get(token, Data.CategoryId.Value);
     }
     else
     {
         Category = null;
     }
 }
Exemplo n.º 9
0
 public EditModel(INotesClient client, ICategoriesClient tagsClient, IIdentityDataGetter idData)
 {
     this.client     = client;
     this.tagsClient = tagsClient;
     this.idData     = idData;
 }
Exemplo n.º 10
0
 public async Task Load(ICategoriesClient categoriesClient, IUsersClient usersClient, string token)
 {
     await LoadCategory(categoriesClient, token);
     await LoadUser(usersClient, token);
 }
Exemplo n.º 11
0
        public static async Task <D3Graph> GenerateGraph(INotesClient noteC, ICategoriesClient categoryC, IEnumerable <Relation> relations, string token, IEnumerable <Note> nodes = null)
        {
            Random rand = new Random();

            if (nodes == null)
            {
                nodes = await GetNotes(noteC, relations, token);
            }

            List <Category> tags = new List <Category>();
            {
                foreach (Note v in nodes)
                {
                    tags.Add(v.CategoryId == null ? null : await categoryC.Get(token, v.CategoryId.Value));
                }
            }


            Dictionary <int, Dictionary <int, D3GraphLink> > outGraph = new Dictionary <int, Dictionary <int, D3GraphLink> >();
            IEnumerable <D3GraphNode> resNodes;

            Dictionary <int, HashSet <int> > graph = new Dictionary <int, HashSet <int> >();

            if (relations != null)
            {
                foreach (Relation v in relations)
                {
                    if (!graph.ContainsKey(v.From))
                    {
                        graph.Add(v.From, new HashSet <int>());
                    }

                    graph[v.From].Add(v.To);
                }
                foreach (Relation v in relations)
                {
                    if (v.From == v.To)
                    {
                        continue;
                    }

                    int s = Math.Min(v.From, v.To);
                    int t = Math.Max(v.From, v.To);
                    if (!outGraph.ContainsKey(s))
                    {
                        outGraph.Add(s, new Dictionary <int, D3GraphLink>());
                    }

                    Dictionary <int, D3GraphLink> subDic = outGraph[s];
                    if (!subDic.ContainsKey(t))
                    {
                        subDic.Add(t, new D3GraphLink
                        {
                            source = s,
                            target = t,
                            left   = false,
                            right  = false
                        });
                    }

                    D3GraphLink link = subDic[t];
                    if (s == v.From)
                    {
                        link.right = true;
                    }
                    else
                    {
                        link.left = true;
                    }
                }
            }

            {
                HashSet <int> isReflexive = new HashSet <int>();
                foreach (Note v in nodes)
                {
                    if (graph.TryGetValue(v.Id, out HashSet <int> to))
                    {
                        if (to.Contains(v.Id))
                        {
                            isReflexive.Add(v.Id);
                        }
                    }
                }
                resNodes = nodes.Zip(tags, (node, tag) =>
                {
                    D3GraphNode res = new D3GraphNode
                    {
                        id        = node.Id,
                        color     = tag?.Color ?? "grey",
                        name      = node.Title,
                        reflexive = isReflexive.Contains(node.Id),
                    };
                    return(res);
                });
            }

            IEnumerable <D3GraphNode> jns = resNodes;
            IEnumerable <D3GraphLink> jrs = from x in outGraph.Values from y in x.Values select y;

            return(new D3Graph {
                links = jrs.ToList(), nodes = jns.ToList()
            });
        }
Exemplo n.º 12
0
 public IndexModel(ICategoriesClient client, IIdentityDataGetter idData)
 {
     this.client = client;
     this.idData = idData;
 }
 public NoteListWaterfallViewComponent(ICategoriesClient categoriesClient, IUsersClient usersClient)
 {
     this.categoriesClient = categoriesClient;
     this.usersClient      = usersClient;
 }