Exemplo n.º 1
0
        public ActionResult EditAgent(string identifier)
        {
            var agentVM = new AgentVM();

            agentVM.Agent     = service.FindAgentById(identifier);
            ViewBag.countries = GetCountries();
            agentVM.Aliases   = Alias.All();
            agentVM.SynchToAgentAliases();
            agentVM.SynchToSelectedAliasIds();
            return(View(agentVM));
        }
Exemplo n.º 2
0
        public ActionResult EditAgent(AgentVM agentVM, string currentIdentifier)
        {
            agentVM.Aliases = Alias.All();
            agentVM.SynchToAgentAliases();
            agentVM.SynchToSelectedAliasIds();
            if (!ModelState.IsValid)
            {
                return(View(agentVM));
            }
            var result = service.EditAgent(agentVM.Agent, currentIdentifier);

            if (!result.Success)
            {
                foreach (var e in result.Messages)
                {
                    ModelState.AddModelError("", e);
                }
                agentVM.Agent = result.Payload;
                return(View(agentVM));
            }
            return(RedirectToAction("Index"));
        }