Пример #1
0
        private UserModel CreateUserModel(User user)
        {
            AdminUser adminUser = user as AdminUser;

            if (adminUser != null)
            {
                return(new AdminUserModel(adminUser));
            }

            ShopUser shopUser = user as ShopUser;

            if (shopUser != null)
            {
                return(new ShopUserModel(shopUser, _shopService.GetById(shopUser.ShopId)));
            }

            AccountUser accountUser = user as AccountUser;

            if (accountUser != null)
            {
                return(new AccountUserModel(accountUser, _accountService.QueryByOwnerId(accountUser)));
            }

            DistributorUser distributorUser = user as DistributorUser;

            if (distributorUser != null)
            {
                return(new DistributorUserModel(distributorUser, _distributorService.GetByUserId(distributorUser.UserId)));
            }
            throw new NotSupportedException(user.GetType().FullName);
        }