public ActionResult EditBinding(Guid id, BindingModel model)
        {
            try
            {
                if (!this.ValidateDuplicatedBinding(model.HostName, model.Protocol, model.Port))
                {
                    model.Certificates = this.GetCertificatesList();
                    return View(model);
                }

                if (this.ValidateCertificateAndPort(model.CertificateId, model.Port, model.Protocol))
                {
                    Binding binding = this.webSiteRepository.RetrieveBinding(id);
                    binding.Port = model.Port;
                    binding.Protocol = model.Protocol;
                    binding.HostName = model.HostName;
                    binding.IpAddress = model.IpAddress;
                    binding.CertificateId = model.CertificateId;

                    this.webSiteRepository.UpdateBinding(binding);

                    return RedirectToAction("Edit", new { id = binding.WebSiteId });
                }
                else
                {
                    model.Certificates = this.GetCertificatesList();
                    return View(model);
                }
            }
            catch
            {
                model.Certificates = this.GetCertificatesList();
                return View(model);
            }
        }
        public ActionResult CreateBinding(Guid webSiteId, BindingModel model)
        {
            try
            {
                if (!this.ValidateDuplicatedBinding(model.HostName, model.Protocol, model.Port))
                {
                    model.Certificates = this.GetCertificatesList();
                    return View(model);
                }

                if (this.ValidateCertificateAndPort(model.CertificateId, model.Port, model.Protocol))
                {
                    var binding = new Binding()
                    {
                        Port = model.Port,
                        Protocol = model.Protocol,
                        HostName = model.HostName,
                        IpAddress = model.IpAddress,
                        CertificateId = model.CertificateId
                    };

                    this.webSiteRepository.AddBindingToWebSite(webSiteId, binding);

                    return RedirectToAction("Edit", new { id = webSiteId });
                }
                else
                {
                    model.Certificates = this.GetCertificatesList();
                    return View(model);
                }
            }
            catch
            {
                model.Certificates = this.GetCertificatesList();
                return View(model);
            }
        }
        public ActionResult EditBinding(Guid id)
        {
            var binding = this.webSiteRepository.RetrieveBinding(id);
            var site = this.webSiteRepository.RetrieveWebSite(binding.WebSiteId);

            var model = new BindingModel()
            {
                WebSiteId = id,
                WebSiteName = site.Name,
                Protocol = binding.Protocol,
                IpAddress = binding.IpAddress,
                Port = binding.Port,
                HostName = binding.HostName,
                CertificateId = binding.CertificateId,
                Certificates = this.GetCertificatesList()
            };

            return View(model);
        }
        public ActionResult CreateBinding(Guid webSiteId)
        {
            var site = this.webSiteRepository.RetrieveWebSite(webSiteId);

            var model = new BindingModel()
            {
                WebSiteId = webSiteId,
                WebSiteName = site.Name,
                Protocol = "http",
                Port = 80,
                IpAddress = "*",
                CertificateId = null,
                Certificates = this.GetCertificatesList()
            };

            return View(model);
        }