public ActionResult Edit(KundeEditModel model)
        {
            using (var rs = new RequestScope(this))
            {
                var kunde = rs.DC.Kunders.Single(k => k.Kunde_GUID == model.Id);
                kunde.IsSupportSiteEnabled = model.IsSupportSiteEnabled;

                var standardInvoiceTypeId = model.StandardFakturaTypeId != Guid.Empty ? model.StandardFakturaTypeId : new Guid?();

                if (kunde.KundeExtensions.Any() == false)
                {
                    kunde.KundeExtensions.Add(new KundeExtension()
                    {
                        DefaultInvoiceTypeId = standardInvoiceTypeId
                    });
                }
                else
                {
                    kunde.KundeExtensions.Single().DefaultInvoiceTypeId = standardInvoiceTypeId;
                }

                rs.DC.SaveChanges();

                // Reindexer kunder
                var sm = new ElasticSearchManager(Properties.Settings.Default.ElasticSearchUrl);
                sm.IndexCustomer(kunde.Kunde_GUID);

                var kundeEditModel = BuildEditModel(kunde, rs);

                return View(kundeEditModel);
            }
        }
        private KundeEditModel BuildEditModel(Kunder kunde, RequestScope rs)
        {
            var currentStandardFakturaTypeId = kunde.KundeExtensions.Any()
                ? kunde.KundeExtensions.Single().DefaultInvoiceTypeId ?? Guid.Empty
                : Guid.Empty;

            var kundeEditModel = new KundeEditModel()
            {
                Id = kunde.Kunde_GUID,
                Navn1 = kunde.Kunde_Navn_1,
                Navn2 = kunde.Kunde_Navn_2,
                StandardFakturaTypeId = currentStandardFakturaTypeId,
                IsSupportSiteEnabled = kunde.IsSupportSiteEnabled,
                FakturaTypeSelectList =
                    rs.DC.InvoiceTypes.Select(
                        t =>
                            new SelectListItem()
                            {
                                Selected = t.IT_GUID == currentStandardFakturaTypeId,
                                Text = t.IT_Name,
                                Value = t.IT_GUID.ToString()
                            }).ToList()
            };

            return kundeEditModel;
        }