public ResellersModule()
            : base("/Resellers")
        {
            Get["/"] = _ =>
                {
                    //this.RequiresAuthentication();
                    //this.RequiresClaims(new[] { "SuperAdmin" });

                    try
                    {
                        Resellers resellers = new Resellers();
                        return View["resellers.cshtml", resellers.GetAll()];
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = ex.Message;
                        log.ErrorFormat("Failed to retrieve resellers. Exception: {0}", ex.ToString());

                        return View["resellers.cshtml"];
                    }
                };

            Get["/{ResellerCode}"] = _ =>
                {
                    //this.RequiresAuthentication();
                    //this.RequiresClaims(new[] { "SuperAdmin" });

                    try
                    {
                        Resellers resellers = new Resellers();
                        Company foundReseller = resellers.GetReseller(_.ResellerCode);

                        return Response.AsJson(foundReseller, HttpStatusCode.OK);
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = ex.Message;
                        return View["resellers.cshtml", GetResellers()];
                    }
                };

            Put["/"] = _ =>
            {
                //this.RequiresAuthentication();
                //this.RequiresClaims(new[] { "SuperAdmin" });

                try
                {
                    var reseller = this.Bind<Company>();

                    Resellers resellers = new Resellers();
                    resellers.Update(reseller);

                    return View["resellers.cshtml", resellers.GetAll()];
                }
                catch (Exception ex)
                {
                    ViewBag.Error = ex.Message;
                    return View["resellers.cshtml", GetResellers()];
                }
            };

            Delete["/"] = _ =>
                {
                    try
                    {
                        string companyName = Request.Form.CompanyNameValidation;
                        if (string.IsNullOrEmpty(companyName))
                            throw new MissingFieldException("Resellers", "CompanyName");

                        string companyCode = Request.Form.CompanyCode;
                        if (string.IsNullOrEmpty(companyCode))
                            throw new MissingFieldException("Resellers", "CompanyCode");

                        Resellers resellers = new Resellers();
                        resellers.Delete(companyCode);

                        return View["resellers.cshtml", resellers.GetAll()];
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = ex.Message;
                        return View["resellers.cshtml", GetResellers()];
                    }
                };

            Post["/"] = _ =>
                {
                    Resellers resellers = new Resellers();

                    try
                    {
                        var data = this.Bind<Company>();
                        resellers.Create(data);

                        return View["resellers.cshtml", resellers.GetAll()];
                    }
                    catch (Exception ex)
                    {
                        ViewBag.Error = ex.Message;
                        return View["resellers.cshtml", GetResellers()];
                    }
                };
        }
 /// <summary>
 /// This is used for the catch station to pull the 
 /// resellers so we don't send back a blank page
 /// It doesn't throw an exception which is why we can use it 
 /// </summary>
 /// <returns></returns>
 private dynamic GetResellers()
 {
     try
     {
         Resellers resellers = new Resellers();
         return resellers.GetAll();
     }
     catch (Exception ex)
     {
         log.ErrorFormat("Failed to retrieve resellers from the database. Error: {0}", ex.ToString());
         return null;
     }
 }