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)); }
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)); }