public DomainsModule() : base("/Company") { Get["/{ResellerCode}/{CompanyCode}/Domains"] = _ => { Companies companies = new Companies(); try { List <Domain> domains = companies.GetDomains(_.CompanyCode); return(View["c_domains.cshtml", domains]); } catch (Exception ex) { log.ErrorFormat("Error retrieving company domains for {0}. Error: {1}", _.CompanyCode, ex.ToString()); ViewBag.Error = ex.Message; return(View["c_domains.cshtml", null]); } }; Get["/{ResellerCode}/{CompanyCode}/Domains/{DomainID}"] = _ => { Companies companies = new Companies(); try { Domain domain = companies.GetDomain(_.CompanyCode, _.DomainID); return(View["c_domainsedit.cshtml", domain]); } catch (Exception ex) { log.ErrorFormat("Error retrieving company domain for {0} with id {1}. Error: {2}", _.CompanyCode, _.DomainID, ex.ToString()); ViewBag.Error = ex.Message; return(View["c_domains.cshtml", null]); } }; Post["/{ResellerCode}/{CompanyCode}/Domains"] = _ => { Companies companies = new Companies(); try { companies.AddDomain(_.CompanyCode, Request.Form.DomainName); } catch (Exception ex) { log.ErrorFormat("Error adding domain {0} for company {1}. Error: {2}", Request.Form.DomainName, _.CompanyCode, ex.ToString()); ViewBag.Error = ex.Message; } return(View["c_domains.cshtml", companies.GetDomains(_.CompanyCode)]); }; }