Пример #1
0
        public ActionResult AddAgent()
        {
            var agentVM = new AgentVM();

            agentVM.Aliases = Alias.All();
            return(View(agentVM));
        }
Пример #2
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));
        }
Пример #3
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"));
        }
Пример #4
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"));
        }