Ejemplo n.º 1
0
        public async Task <ActionResult> Create()
        {
            logger.Info($"Action Start | Controller name: {nameof(AgentsController)} | Action name: {nameof(Create)}");

            AgentCreateViewModel agentCreateViewModel = new AgentCreateViewModel
            {
                Groups     = new SelectList(await repository.GetGroupsAsync(), "Id", "Name"),
                Algorithms = new SelectList(Agent.algorithmDictionary.Select(algo => new { Algorithm = algo.Key.ToString(), AlgorithmNAme = algo.Value }), "Algorithm", "AlgorithmName")
            };

            return(View(agentCreateViewModel));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Edit(int?id)
        {
            logger.Info($"Action Start | Controller name: {nameof(AgentsController)} | Action name: {nameof(Edit)} | Input params: {nameof(id)}={id}");
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Agent agent = await repository.FindAgentByIdAsync(id);

            if (agent == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.NotFound));
            }

            AgentCreateViewModel agentCreateViewModel = new AgentCreateViewModel
            {
                Agent      = agent,
                Groups     = new SelectList(await repository.GetGroupsAsync(), "Id", "Name"),
                Algorithms = new SelectList(Agent.algorithmDictionary.Select(algo => new { Algorithm = algo.Key.ToString(), AlgorithmNAme = algo.Value }), "Algorithm", "AlgorithmName", agent.Algorithm)
            };

            return(View(agentCreateViewModel));
        }