internal static OwnerVm MapToOwnerVm(this Owner owner, OwnerType ownerType) { OwnerVm result = new OwnerVm(); result.Id = owner.Id; result.NewOwner = new NewOwnerVm { Address = AdminViewModelsProvider.GetAddressVm(), PhoneList = AdminViewModelsProvider.GetPhoneList(ownerType), EmailList = AdminViewModelsProvider.GetEmailListVm(ownerType), Contacts = new List <ContactVm> { AdminViewModelsProvider.GetContactVm(ownerType) }, LogoImages = new ImageListVm(ownerType.MapToDisplayName()), OwnerType = ownerType }; result.Owners = (from m in OwnerBc.Instance.GetAllByOwnerType(owner.OwnerType) select new SelectListItem { Value = m.Id.ToString(), Text = m.Name, Selected = (result.Id == m.Id) }).ToList(); return(result); }
internal static OwnerVm MapToOwnerVm(this Owner owner, OwnerType ownerType) { OwnerVm ownerVm = new OwnerVm() { Id = owner.Id, NewOwner = new NewOwnerVm() { Address = AdminViewModelsProvider.GetAddressVm(), PhoneList = AdminViewModelsProvider.GetPhoneList(ownerType), EmailList = AdminViewModelsProvider.GetEmailListVm(ownerType), Contacts = new List <ContactVm>() { AdminViewModelsProvider.GetContactVm(ownerType) }, LogoImages = new ImageListVm(ownerType.MapToDisplayName()), OwnerType = ownerType }, Owners = OwnerBc.Instance.GetAllByOwnerType(owner.OwnerType).Select <Owner, SelectListItem>((Owner m) => { SelectListItem selectListItem = new SelectListItem(); long?id = m.Id; selectListItem.set_Value(id.ToString()); selectListItem.set_Text(m.Name); id = ownerVm.Id; long?nullable = m.Id; selectListItem.set_Selected(id.GetValueOrDefault() == nullable.GetValueOrDefault() & id.HasValue == nullable.HasValue); return(selectListItem); }).ToList <SelectListItem>() }; return(ownerVm); }
internal static NewOwnerVm MapToNewOwnerVm(this Owner owner) { NewOwnerVm result = new NewOwnerVm() { Id = owner.Id, Name = owner.Name, OwnerType = owner.OwnerType, WebsiteUrl = owner.WebsiteUrl, DisplayName = owner.DisplayName, DisplayAddress = owner.DisplayAddress, DisplayPhone = owner.DisplayPhone, DisplayWebsiteUrl = owner.DisplayWebsiteUrl, DisplayLogo = owner.DisplayLogo, Address = owner.Address.MapToAddressVm(), PhoneList = (owner.Phones.Any <Phone>() ? owner.Phones.MapToPhoneListVm(owner.OwnerType) : AdminViewModelsProvider.GetPhoneList(owner.OwnerType)), EmailList = (owner.Emails.Any <Email>() ? owner.Emails.MapToEmailListVm(owner.OwnerType) : AdminViewModelsProvider.GetEmailListVm(owner.OwnerType)) }; if (owner.Contacts.Any <Contact>()) { result.Contacts = new List <ContactVm>(); List <KeyValuePair <int, string> > contactTypes = ItemTypeBc.Instance.GetContactTypes(owner.OwnerType); foreach (Contact contactItem in owner.Contacts) { ContactVm contactViewModel = new ContactVm() { Id = contactItem.Id, ContactTypeId = contactItem.ContactTypeId, FirstName = contactItem.FirstName, LastName = contactItem.LastName, ContactTypes = contactTypes.ToSelectListItemList(contactItem.ContactTypeId) }; result.Contacts.Add(contactViewModel); } } else { result.Contacts = new List <ContactVm>() { AdminViewModelsProvider.GetContactVm(owner.OwnerType) }; } result.LogoImages = owner.LogoImages.MapToImageListVm(owner.OwnerType.MapToDisplayName()); return(result); }
public static List <ContactVm> Repopulate(this IEnumerable <ContactVm> contacts, CommunityType type) { List <ContactVm> result; if (contacts == null || !contacts.Any <ContactVm>()) { result = new List <ContactVm>() { AdminViewModelsProvider.GetContactVm(type) }; } else { result = contacts.ToList <ContactVm>(); List <SelectListItem> contactTypes = MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetContactTypes(type).ToSelectListItemList(); foreach (ContactVm contactVm in result) { contactVm.ContactTypes = contactTypes; } } return(result); }