Beispiel #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));
        }
Beispiel #2
0
        public ActionResult AddAgent(AgentVM agentVM)
        {
            agentVM.Aliases = Alias.All();
            agentVM.SynchToAgentAliases();
            if (!ModelState.IsValid)
            {
                return(View(agentVM));
            }
            var result = service.AddAgent(agentVM.Agent);

            if (!result.Success)
            {
                foreach (var e in result.Messages)
                {
                    ModelState.AddModelError("", e);
                }
                return(View(agentVM));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #3
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"));
        }