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);
        }