public ActionResult Create(NewClientModel model) { try { service.CreateNewClient(model,Request.Params); return RedirectToAction("Index"); } catch(System.Exception ex) { ViewResult view = View(); view.ViewData.Add("AccountSetupException",ex.Message); return view; } }
public void CreateNewClient(NewClientModel newClientModel, NameValueCollection requestParameters) { if (newClientModel.ImportTypeId < 1) throw new System.Exception("You must select an Import Type"); if (String.IsNullOrEmpty(newClientModel.GroupName)) throw new System.Exception("You must select a Group Name"); newClientModel.ClientParametersObject = GetClientParametersObject(newClientModel, requestParameters); XElement result = AllClientsService.CreateAccount(newClientModel.Email, newClientModel.AllClientsPassword, newClientModel.GroupName, newClientModel.Newsletter, newClientModel.Fullname, newClientModel.Company, newClientModel.Address, newClientModel.CityStateZip, newClientModel.Phone, newClientModel.Website, newClientModel.ImportTypeId, newClientModel.EnableUpdates, newClientModel.Active, newClientModel.ClientParametersObject.GetClientParameters); if (result.Descendants("errors").Count() > 0) throw new AIM.Common.AccountSetupException(result.Elements("errors").First().Value); }