public ActionResult AddAgent() { var agentVM = new AgentVM(); agentVM.Aliases = Alias.All(); return(View(agentVM)); }
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)); }
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")); }
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")); }