Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        public static PhoneListVm Repopulate(this PhoneListVm model, ServiceType serviceType)
        {
            if (model == null)
            {
                return(AdminViewModelsProvider.GetPhoneList(serviceType));
            }
            if (model.AdditionalPhones == null || !model.AdditionalPhones.Any <PhoneVm>())
            {
                model.AdditionalPhones = new List <PhoneVm>()
                {
                    new PhoneVm()
                };
            }
            List <SelectListItem> phoneTypes = MSLivingChoices.Bcs.Admin.Components.ItemTypeBc.Instance.GetPhoneTypes(serviceType).ToSelectListItemList();

            foreach (PhoneVm additionalPhone in model.AdditionalPhones)
            {
                additionalPhone.PhoneTypes = phoneTypes;
            }
            return(model);
        }
Ejemplo n.º 4
0
        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);
        }