public IActionResult RegisterOrganization() { var RegisterModel = new RegisterModel(); var IndustryList = new List <Industry>(); string errorMessage = string.Empty; try { var apiCall = new ApiCallerIndustry(_apiUrl.SSChurch); IndustryList = apiCall.GetAll(); var IndustryModelList = from industry in IndustryList select new IndustryModel() { Id = industry.IndustryId, Name = industry.IndustryName }; ViewBag.IndustryList = IndustryModelList.ToList(); } catch (Exception ex) { errorMessage = ex.Message; } ViewBag.ErrorMessage = errorMessage; return(View(RegisterModel)); }
public IActionResult RegisterOrganization(RegisterModel model) { string errorMessage = string.Empty; var IndustryList = new List <Industry>(); try { var apiSecQCall = new ApiCallerSecurityQuestions(_apiUrl.SSAuth); var SecurityQuestionsList = apiSecQCall.GetAllSecurityQuestions(); var SecurityQuestionModelList = from secQuestion in SecurityQuestionsList select new QuestionsModel() { Id = secQuestion.SecurityQuestionId.ToString(), Name = secQuestion.Question }; SecurityQuestionModelList.ToList().Insert(0, new QuestionsModel() { Id = "", Name = "Please select a security question" }); ViewBag.QuestionList = SecurityQuestionModelList.ToList(); var apiCall = new ApiCallerIndustry(_apiUrl.SSChurch); IndustryList = apiCall.GetAll(); var IndustryModelList = from industry in IndustryList select new IndustryModel() { Id = industry.IndustryId, Name = industry.IndustryName }; ViewBag.IndustryList = IndustryModelList.ToList(); if (model.IndustryId == 0) { throw new Exception("Industry must be selected"); } if (string.IsNullOrWhiteSpace(model.OrganizationName)) { throw new Exception("Organization name is required"); } } catch (Exception ex) { errorMessage = ex.Message; } ViewBag.ErrorMessage = errorMessage; if (!string.IsNullOrEmpty(errorMessage)) { return(View("RegisterOrganization", model)); } else { return(View("Register", model)); } }