public ActionResult Index(IndexForm IndexForm)
{
ViewData["WasAnError"] = 0;
try
{
var errors = DataAnnotationsValidationRunner.GetErrors(IndexForm);
if (errors.Any())
{
ViewData["WasAnError"] = 1;
throw new AtomiaServerSideValidationException(errors);
}
string[] viewDataDomains;
if (IndexForm.Selected == "first" && !string.IsNullOrEmpty(IndexForm.Domains))
{
List<DomainDataFromXML> domainData;
// Get ViewData
IndexHelper.FirstOptionSelected(this, out viewDataDomains, out domainData, IndexForm.Domains.Trim());
Session["firstOption"] = true;
Session["subdomain"] = false;
Session["domains"] = viewDataDomains;
Session["multiDomains"] = domainData;
}
else if (IndexForm.Selected == "second" && !string.IsNullOrEmpty(IndexForm.Domain))
{
DomainDataFromXML domainData;
// Get ViewData
IndexHelper.SecondOptionSelected(out viewDataDomains, out domainData, IndexForm.Domain.Trim(new[] { '.', ' ' }).Trim());
Session["firstOption"] = false;
Session["subdomain"] = false;
Session["domains"] = viewDataDomains;
Session["singleDomain"] = domainData;
}
else if (IndexForm.Selected == "subdomain" && !string.IsNullOrEmpty(IndexForm.SubDomain))
{
//// should this be the same as 'second' option ?
string mainDomain = (string)this.HttpContext.Application["AllowAddSubdomain"];
if (string.IsNullOrEmpty(mainDomain))
{
new AtomiaServerSideValidationException("MainDomain", "Adding subdomains is not allowed. Reason: main domain not set.");
}
DomainDataFromXML domainData;
// Get ViewData
IndexHelper.SecondOptionSelected(out viewDataDomains, out domainData, IndexForm.SubDomain.Trim(new[] { '.', ' ' }).Trim() + "." + mainDomain);
Session["firstOption"] = false;
Session["domains"] = viewDataDomains;
Session["singleDomain"] = domainData;
Session["subdomain"] = true;
}
else
{
return this.View();
}
}
catch (AtomiaServerSideValidationException ex)
{
ViewData["WasAnError"] = 1;
ex.AddModelStateErrors(ModelState, string.Empty);
}
if (ModelState.IsValid)
{
return RedirectToAction("Select", new { controller = "PublicOrder", area = "PublicOrder" });
}
// error
this.ViewData["WasAnError"] = 1;
this.ViewData["RegDomainFront"] = RegularExpression.GetRegularExpression("DomainFront");
this.ViewData["RegDomain"] = RegularExpression.GetRegularExpression("Domain");
int allowedDomainLength;
int numberOfDomainsAllowed;
if (this.HttpContext.Application["DomainSearchAllowedDomainLength"] != null && (string)this.HttpContext.Application["DomainSearchAllowedDomainLength"] != String.Empty
&& this.HttpContext.Application["DomainSearchNumberOfDomainsAllowed"] != null && (string)this.HttpContext.Application["DomainSearchNumberOfDomainsAllowed"] != String.Empty)
{
allowedDomainLength = Int32.Parse((string)this.HttpContext.Application["DomainSearchAllowedDomainLength"]);
numberOfDomainsAllowed = Int32.Parse((string)this.HttpContext.Application["DomainSearchNumberOfDomainsAllowed"]);
}
else
{
throw new ConfigurationErrorsException("Missing AllowedDomainLength or NumberOfDomainsAllowed in configuration");
}
ViewData["AllowedDomainLength"] = allowedDomainLength;
ViewData["NumberOfDomainsAllowed"] = numberOfDomainsAllowed;
string tldBasedRegexesSplited = string.Empty;
List<string> tldBasedRegexes;
try
{
tldBasedRegexes = DomainSearchHelper.GetTLDBasedRegexes(ResellerHelper.GetResellerId());
}
catch (ConfigurationErrorsException ex)
{
OrderPageLogger.LogOrderPageException(ex);
throw;
}
for (int i = 0; i < tldBasedRegexes.Count; i++)
{
if (i < tldBasedRegexes.Count - 1)
{
tldBasedRegexesSplited += tldBasedRegexes[i] + " ";
}
else
{
tldBasedRegexesSplited += tldBasedRegexes[i];
}
}
this.ViewData["RegDomainTLDBased"] = tldBasedRegexesSplited;
return this.View();
}