public UserIdentity FredTenantUserIdentity()
        {
            //BaseController With Identity
            var userIdentity = new UserIdentity(Uow, new FakeMembershipProvider());

            //Context
            var controllerContext = new Mock<ControllerContext>();
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.Name).Returns("fred");
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.IsAuthenticated).Returns(true);
            controllerContext.Setup(x => x.HttpContext.User.IsInRole(It.Is<string>(s => s.Equals("Tenant")))).Returns(true);
            userIdentity.ControllerContext = controllerContext.Object;
            return userIdentity;
        }
        public AgentPrivateProfileHelper AgentPrivateProfileHelperMock()
        {
            var agentUserIdentity = new UserIdentity(Uow, new FakeMembershipProvider());
            agentUserIdentity.MockHttpContext();
            agentUserIdentity.MockMikeAgent();

            var agentPrivatemockHelper = new Mock<IUserHelper>();
            agentPrivatemockHelper.Setup(x => x.UserIdentity).Returns(agentUserIdentity);

            var agentPrivateProfileHelper = new AgentPrivateProfileHelper(Uow, new FakeMembershipProvider(), agentPrivatemockHelper.Object);
            agentPrivateProfileHelper.MockHttpContext();
            agentPrivateProfileHelper.MockMikeAgent();
            return agentPrivateProfileHelper;
        }
        public CoreUserHelper(IGenericUnitofWork uow, IMembershipService membershipService)
        {
            MembershipService = membershipService;
            UnitofWork = uow;

            #region PrivateProfileHelper
            SpecialistPrivateProfileHelper = new SpecialistPrivateProfileHelper(uow, membershipService, this);
            OwnerPrivateProfileHelper = new OwnerPrivateProfileHelper(uow, membershipService, this);
            AgentPrivateProfileHelper = new AgentPrivateProfileHelper(uow, membershipService, this);
            TenantPrivateProfileHelper = new TenantPrivateProfileHelper(uow, membershipService, this);
            ProviderPrivateProfileHelper = new ProviderPrivateProfileHelper(uow, membershipService, this);
            #region Associated
            ProviderTeamPrivateProfileHelper = new ProviderTeamPrivateProfileHelper(uow, membershipService, this);
            #endregion
            #endregion

            #region PublicProfileHelper
            SpecialistPublicProfileHelper = new SpecialistPublicProfileHelper(uow, membershipService, this);
            OwnerPublicProfileHelper = new OwnerPublicProfileHelper(uow, membershipService);
            AgentPublicProfileHelper = new AgentPublicProfileHelper(uow, membershipService);
            TenantPublicProfileHelper = new TenantPublicProfileHelper(uow, membershipService);
            ProviderPublicProfileHelper = new ProviderPublicProfileHelper(uow, membershipService, this);
            #endregion

            #region Common
            LocationHelper = new LocationHelper(uow, membershipService);
            PosterHelper = new PosterHelper(uow, membershipService);
            UserIdentity = new UserIdentity(uow, membershipService);
            #endregion

            #region Job
            TenantRentalApplicationHelper = new TenantRentalApplicationHelper(uow, membershipService);
            JobOffer = new JobOffer(uow, membershipService);
            #endregion

            #region Unit
            UnitHelper = new UnitHelper(uow, membershipService, this);
            #endregion
        }
        public void MembershipServiceMocking()
        {
            //IStaticMembershipService
            var membershipMock = new Mock<IMembershipService>();
            var userMock = new Mock<MembershipUser>();
            var userGuid = new Guid();
            userMock.Setup(u => u.ProviderUserKey).Returns(userGuid);
            userMock.Setup(u => u.UserName).Returns("jack1");
            membershipMock.Setup(s => s.GetUser(It.IsAny<string>())).Returns(userMock.Object);

            //Identity
            var userIdentity = new UserIdentity(Uow, membershipMock.Object);

            //Context
            var controllerContext = new Mock<ControllerContext>();
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.Name).Returns("Robert");
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.IsAuthenticated).Returns(true);
            userIdentity.ControllerContext = controllerContext.Object;

            Assert.AreEqual(userIdentity.GetUserName(), "jack1");
            Assert.AreEqual(userIdentity.GetUserGuid(), userGuid);
        }
        public UserIdentity JeffProviderUserIdentityFromMemberShipProvider()
        {
            //BaseController With Identity
            var userIdentity = new UserIdentity { MembershipProvider = new FakeMembershipProvider() };

            //Context
            var controllerContext = new Mock<ControllerContext>();
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.Name).Returns("jeff");
            controllerContext.SetupGet(x => x.HttpContext.User.Identity.IsAuthenticated).Returns(true);
            controllerContext.Setup(x => x.HttpContext.User.IsInRole(It.Is<string>(s => s.Equals("MaintenanceProvider")))).Returns(true);
            userIdentity.ControllerContext = controllerContext.Object;
            return userIdentity;
        }
        public TenantPrivateProfileHelper TenantPrivateProfileHelperMock()
        {
            var tenantUserIdentity = new UserIdentity(Uow, new FakeMembershipProvider());
            tenantUserIdentity.MockHttpContext();
            tenantUserIdentity.MockTenantFred();

            var tenantPrivatemockHelper = new Mock<IUserHelper>();
            tenantPrivatemockHelper.Setup(x => x.UserIdentity).Returns(tenantUserIdentity);

            var tenantPrivateProfileHelper = new TenantPrivateProfileHelper(Uow, new FakeMembershipProvider(), tenantPrivatemockHelper.Object);
            tenantPrivateProfileHelper.MockHttpContext();
            tenantPrivateProfileHelper.MockTenantFred();
            return tenantPrivateProfileHelper;
        }
        public SpecialistPrivateProfileHelper SpecialistPrivateProfileHelperMock()
        {
            var specialistUserIdentity = new UserIdentity(Uow, new FakeMembershipProvider());
            specialistUserIdentity.MockHttpContext();
            specialistUserIdentity.MockSaraSpecialist();

            var specialistPrivatemockHelper = new Mock<IUserHelper>();
            specialistPrivatemockHelper.Setup(x => x.UserIdentity).Returns(specialistUserIdentity);

            var specialistPrivateProfileHelper = new SpecialistPrivateProfileHelper(Uow, new FakeMembershipProvider(), specialistPrivatemockHelper.Object);
            specialistPrivateProfileHelper.MockHttpContext();
            specialistPrivateProfileHelper.MockSaraSpecialist();
            return specialistPrivateProfileHelper;
        }
        public ProviderPrivateProfileHelper ProviderPrivateProfileHelperMock()
        {
            var providerUserIdentity = new UserIdentity(Uow, new FakeMembershipProvider());
            providerUserIdentity.MockHttpContext();
            providerUserIdentity.MockJeffProvider();

            var providerPrivatemockHelper = new Mock<IUserHelper>();
            providerPrivatemockHelper.Setup(x => x.UserIdentity).Returns(providerUserIdentity);

            var providerPrivateProfileHelper = new ProviderPrivateProfileHelper(Uow, new FakeMembershipProvider(), providerPrivatemockHelper.Object);
            providerPrivateProfileHelper.MockHttpContext();
            providerPrivateProfileHelper.MockJeffProvider();
            return providerPrivateProfileHelper;
        }
        public OwnerPrivateProfileHelper OwnerPrivateProfileHelperMock()
        {
            var ownerUserIdentity = new UserIdentity(Uow, new FakeMembershipProvider());
            ownerUserIdentity.MockHttpContext();
            ownerUserIdentity.MockLisaOwner();

            var ownerPrivatemockHelper = new Mock<IUserHelper>();
            ownerPrivatemockHelper.Setup(x => x.UserIdentity).Returns(ownerUserIdentity);

            var ownerPrivateProfileHelper = new OwnerPrivateProfileHelper(Uow, new FakeMembershipProvider(), ownerPrivatemockHelper.Object);
            ownerPrivateProfileHelper.MockHttpContext();
            ownerPrivateProfileHelper.MockMikeAgent();
            return ownerPrivateProfileHelper;
        }
Пример #10
0
        public PosterAttributes GetUserPosterAttributes(string currenturl)
        {
            string photoPath;
            var role = new UserIdentity(UnitofWork, MembershipService).SetPhotoPathByCurrentRole(out photoPath);
            if (role == "Tenant")
            {
                var tenantId = new UserIdentity(UnitofWork, MembershipService).GetTenantId();
                var tenant = UnitofWork.TenantRepository.FindBy(x => x.TenantId == tenantId).FirstOrDefault();
                if (tenant != null)
                {
                    return new PosterAttributes(tenant.FirstName, tenant.LastName,
                        currenturl + "/tenantprofile/index/" + tenant.TenantId, tenant.Photo,
                        tenant.EmailAddress, "tenant", tenant.TenantId);
                }
            }

            if (role == "Owner")
            {
                var ownerId = new UserIdentity(UnitofWork, MembershipService).GetOwnerId();
                var owner = UnitofWork.OwnerRepository.FindBy(x => x.OwnerId == ownerId).FirstOrDefault();
                if (owner != null)
                {
                    return new PosterAttributes(owner.FirstName, owner.LastName,
                        currenturl + "/ownerprofile/index/" + owner.OwnerId, owner.Photo,
                        owner.EmailAddress, "owner", owner.OwnerId);
                }
            }
            if (role == "Agent")
            {
                var agentId = new UserIdentity(UnitofWork, MembershipService).GetAgentId();
                var agent = UnitofWork.AgentRepository.FindBy(x => x.AgentId == agentId).FirstOrDefault();
                if (agent != null)
                {
                    return new PosterAttributes(agent.FirstName, agent.LastName,
                        currenturl + "/agentprofile/index/" + agent.AgentId, agent.Photo,
                        agent.EmailAddress, "tenant", agent.AgentId);
                }
            }

            if (role == "Specialist")
            {
                var specialistId = new UserIdentity(UnitofWork, MembershipService).GetSpecialistId();
                var specialist = UnitofWork.SpecialistRepository.FindBy(x => x.SpecialistId == specialistId).FirstOrDefault();
                if (specialist != null)
                {
                    return new PosterAttributes(specialist.FirstName, specialist.LastName,
                        currenturl + "/SpecialistProfile/" + specialist.SpecialistId, specialist.Photo,
                        specialist.EmailAddress, "specialist", specialist.SpecialistId);
                }
            }

            if (role == "Provider")
            {
                var providerId = new UserIdentity(UnitofWork, MembershipService).GetProviderId();
                var provider = UnitofWork.MaintenanceProviderRepository.FindBy(x => x.MaintenanceProviderId == providerId).FirstOrDefault();
                if (provider != null)
                {
                    return new PosterAttributes(provider.FirstName, provider.LastName,
                        currenturl + "/ProviderProfile/" + provider.MaintenanceProviderId, provider.Photo,
                        provider.EmailAddress, "provider", provider.MaintenanceProviderId);
                }
            }

            return DefaultPoster;
        }
Пример #11
0
        //Theorizing
        public void ShareProperty(UnitModelView u)
        {
            if (Request == null || Request.Url == null) return;
            var url = Request.Url.AbsoluteUri.ToString(CultureInfo.InvariantCulture);
            var primaryimagethumbnail = new UserIdentity(UnitofWork, MembershipService).ResolveImageUrl(u.Unit.PrimaryPhoto);
            string title;
            if (String.IsNullOrEmpty(u.Unit.Title))
            {
                title = (u.Unit.Address + " , " + u.Unit.State + " , " + u.Unit.City);
                if (title.Length >= 50)
                {
                    title = title.Substring(0, 50);
                }
            }
            else
            {
                title = u.Unit.Title;
                if (u.Unit.Title.Length >= 50)
                {
                    title = u.Unit.Title.Substring(0, 50);
                }
            }

            var summary = u.Unit.Description;
            if (!String.IsNullOrEmpty(summary))
            {
                if (summary.Length >= 140)
                {
                    summary = summary.Substring(0, 140);
                }
            }

            var unitrentprice = u.UnitPricing.Rent == null
                                    ? ""
                                    : u.UnitPricing.Rent.Value.ToString(CultureInfo.InvariantCulture) + " ";
            unitrentprice += GetCurrencyValue(u.Unit.CurrencyCode);
            var tweet = u.Unit.Title + ": " + unitrentprice + "--" + url;
            if (!String.IsNullOrEmpty(tweet))
            {
                if (tweet.Length >= 140)
                {
                    tweet = tweet.Substring(0, 140);
                }
            }

            const string sitename = "http://www.haithem-araissia.com";

            //TOD REFACTOR SO THAT INVOKING WILL BE CALLING VIEWBAG
            ViewBag.FaceBook = new SocialHelper().FacebookShare(url, primaryimagethumbnail, title, summary);
            ViewBag.Twitter = new SocialHelper().TwitterShare(tweet);
            ViewBag.GooglePlusShare = new SocialHelper().GooglePlusShare(url);
            ViewBag.LinkedIn = new SocialHelper().LinkedInShare(url, title, summary, sitename);
        }