private static KundeIndexItem Create(Kunder k)
 {
     return new KundeIndexItem()
     {
         Id = k.Kunde_GUID.ToString(),
         Navn1 = k.Kunde_Navn_1,
         Navn2 = k.Kunde_Navn_2,
         Adresse1 = k.Kunde_Adresse_1,
         Adresse2 = k.Kunde_Adresse_2,
         Adresse3 = k.Kunde_Adresse_3,
         Postnummer = k.Kunde_Postnummer,
         Postdistrikt = k.Kunde_Postdistrikt,
         Telefonnummer = k.Kunde_Telefonnummer,
         Email = k.Kunde_EMail,
         DefaultInvoiceTypeId = k.KundeExtensions.Any() ? k.KundeExtensions.Single().DefaultInvoiceTypeId.ToString() : string.Empty,
         Kontakter = k.Contacts.Where(c => c.IsThrash == 0).Select(c => new KundeKontaktIndexItem
         {
             Id = c.Contact_GUID.ToString(),
             Name = c.Contact_Name,
             Title = c.Contact_Title,
             Occupation = c.Contact_Occupation,
             Email1 = c.Contact_Work_EMail,
             Email2 = c.Contact_Work_EMail1,
             Email3 = c.Contact_Work_EMail2,
             Phone = c.Contact_Work_Phone
         }).ToList()
     };
 }
        public static Guid? FindStandardFakturaType(Kunder company)
        {
            var invoiceType = company.KundeExtensions.Any()
                    ? company.KundeExtensions.Single().DefaultInvoiceTypeId
                    : new Nullable<Guid>();

            return invoiceType;
        }
        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;
        }