public void InsertPendingJobOffer(int providerid, Tenant tenant, int propertyid, DateTime startDate, DateTime endDate)
        {
            var provider = UnitofWork.MaintenanceProviderRepository.FindBy(x=>x.MaintenanceProviderId == providerid).FirstOrDefault();
            if (provider == null) return;
            //var opa = new OwnerPendingApplication
            var mpj = new MaintenanceProviderNewJobOffer
            {
                TenantId = tenant.TenantId,
                TenantName = tenant.FirstName + " " + tenant.LastName,
                TenantEmailAddress = tenant.EmailAddress,
                PropertyId = propertyid,
                StartDate = startDate,
                EndDate = endDate
            };

            try
            {
                UnitofWork.MaintenanceProviderNewJobOfferRepository.Add(mpj);
                UnitofWork.Save();
            }
            catch (DbEntityValidationException e)
            {
                foreach (var eve in e.EntityValidationErrors)
                {
                    Console.WriteLine(@"Entity of type ""{0}"" in state ""{1}"" has the following validation errors:",
                        eve.Entry.Entity.GetType().Name, eve.Entry.State);
                    foreach (var ve in eve.ValidationErrors)
                    {
                        Console.WriteLine(@"- Property: ""{0}"", Error: ""{1}""",
                            ve.PropertyName, ve.ErrorMessage);
                    }
                }
                throw;
            }
            ViewData["confirmationmsg"] = "Your Application had been succesfully submitted to the Owner.";
            ViewData["confirmationmsg"] = "Your Application had been succesfully submitted to the Provider.";
        }
        public Tenant FirstTenant()
        {
            var firstTenant = new Tenant {

                 TenantId = 5
            ,
                 FirstName = null,
                 LastName = null,
                 Address = null,
                 EmailAddress = null,
                 Description = null,
                 GUID = new Guid("ffffffff-dddd-dddd-dddd-dddddddddddd")
            ,
                 VCard = null,
                 Skype = null,
                 Twitter = null,
                 LinkedIn = null,
                 GooglePlus = null,
                 Photo = null,
                 GoogleMap = null,
                 Country = null,
                 Region = null,
                 City = null,
                 Zip = null,
                 CountryCode = null,
                 YouTubeVideo = new Boolean(),
                 YouTubeVideoURL = "http://www.agenttenant.com",
                 VimeoVideo = new Boolean(),
                 VimeoVideoURL = null,
            //Skipping TenantFavorite Collection
            //Skipping TenantSavedSearch Collection
            //Skipping TenantShowing Collection

             };

            return firstTenant;
        }
        public Tenant SecondTenant()
        {
            var secondTenant = new Tenant {

                 TenantId = new Int32()
            ,
                 FirstName = null,
                 LastName = null,
                 Address = null,
                 EmailAddress = null,
                 Description = null,
                 GUID = new Guid()
            ,
                 VCard = null,
                 Skype = null,
                 Twitter = null,
                 LinkedIn = null,
                 GooglePlus = null,
                 Photo = null,
                 GoogleMap = null,
                 Country = null,
                 Region = null,
                 City = null,
                 Zip = null,
                 CountryCode = null,
                 YouTubeVideo = new Boolean(),
                 YouTubeVideoURL = null,
                 VimeoVideo = new Boolean(),
                 VimeoVideoURL = null,
            //Skipping TenantFavorite Collection
            //Skipping TenantSavedSearch Collection
            //Skipping TenantShowing Collection

             };

            return secondTenant;
        }
        public Tenant ThirdTenant()
        {
            var thirdTenant = new Tenant {

                 TenantId = 3
            ,
                 FirstName = "Lynda Tenant",
                 LastName = "Smith",
                 Address = "5412 South Bronx, NY 2008",
                 EmailAddress = "*****@*****.**",
                 Description = "Lynda Description",
                 GUID = new Guid()
            ,
                 VCard = null,
                 Skype = null,
                 Twitter = null,
                 LinkedIn = null,
                 GooglePlus = "Google Map",
                 Photo = null,
                 GoogleMap = null,
                 Country = null,
                 Region = null,
                 City = null,
                 Zip = null,
                 CountryCode = null,
                 YouTubeVideo = new Boolean(),
                 YouTubeVideoURL = null,
                 VimeoVideo = new Boolean(),
                 VimeoVideoURL = null,
            //Skipping TenantFavorite Collection
            //Skipping TenantSavedSearch Collection
            //Skipping TenantShowing Collection

             };

            return thirdTenant;
        }
 public void RegisterTenant(RegisterModel model)
 {
     var newtenant = new Tenant { EmailAddress = model.Email };
     var user = MembershipService.GetUser(model.UserName);
     if (user != null)
     {
         if (user.ProviderUserKey != null) newtenant.GUID = new Guid(user.ProviderUserKey.ToString());
         newtenant.FirstName = model.UserName;
         newtenant.Photo = "./../images/dotimages/avatar-placeholder.png";
         newtenant.GoogleMap = "USA";
         UnitofWork.TenantRepository.Add(newtenant);
         UnitofWork.Save();
     }
 }
        public void Initialize()
        {
            // Arrange
            #region AccountHelperTest

            #region Repo
            var maintenanceCompanyLookUpRepo = new FakeMaintenanceCompanyLookUpRepository();
            var maintenanceCompanyRepo = new FakeMaintenanceCompanyRepository();
            var maintenanceCompanySpecializationRepo = new FakeMaintenanceCompanySpecializationRepository();
            var maintenanceCustomServicesRepo = new FakeMaintenanceCustomServiceRepository();
            var maintenanceExteriorRepo = new FakeMaintenanceExteriorRepository();
            var maintenanceInteriorRepo = new FakeMaintenanceInteriorRepository();
            var maintenanceNewConstructionRepo = new FakeMaintenanceNewConstructionRepository();
            var maintenanceRepairRepo = new FakeMaintenanceRepairRepository();
            var maintenanceUtilityRepo = new FakeMaintenanceUtilityRepository();

            var currencyRepo = new FakeCurrencyRepository();
            var specialistProfileCommentRepo = new FakeSpecialistProfileCommentRepository();
            var specialistWorkRepo = new FakeSpecialistWorkRepository();
            var agentRepo = new FakeAgentRepository();
            var ownerRepo = new FakeOwnerRepository();
            var specialistRepo = new FakeSpecialistRepository();
            var tenantRepo = new FakeTenantRepository();
            var providerRepo = new FakeMaintenanceProviderRepository();
            Uow = new UnitofWork
            {
                MaintenanceCompanyLookUpRepository = maintenanceCompanyLookUpRepo,
                MaintenanceCompanyRepository = maintenanceCompanyRepo,
                MaintenanceCompanySpecializationRepository = maintenanceCompanySpecializationRepo,
                MaintenanceCustomServiceRepository = maintenanceCustomServicesRepo,
                MaintenanceExteriorRepository = maintenanceExteriorRepo,
                MaintenanceInteriorRepository = maintenanceInteriorRepo,
                MaintenanceNewConstructionRepository = maintenanceNewConstructionRepo,
                MaintenanceRepairRepository = maintenanceRepairRepo,
                MaintenanceUtilityRepository = maintenanceUtilityRepo,
                CurrencyRepository = currencyRepo,
                SpecialistProfileCommentRepository = specialistProfileCommentRepo,
                SpecialistWorkRepository = specialistWorkRepo,
                AgentRepository = agentRepo,
                OwnerRepository = ownerRepo,
                SpecialistRepository = specialistRepo,
                TenantRepository = tenantRepo,
                MaintenanceProviderRepository = providerRepo
            };
            #endregion

            #region Mocking IUserHelper

            #region  AccountHelper UserHelper
            var mockHelper = new Mock<IUserHelper>();
            mockHelper.
                Setup(x => x.UserIdentity).
                Returns(new UserIdentity(Uow, new FakeMembershipProvider()));
            mockHelper.
                Setup(x => x.AgentPrivateProfileHelper).
                Returns(AgentPrivateProfileHelperMock);
            mockHelper.
              Setup(x => x.OwnerPrivateProfileHelper).
              Returns(OwnerPrivateProfileHelperMock);
            mockHelper.
              Setup(x => x.ProviderPrivateProfileHelper).
              Returns(ProviderPrivateProfileHelperMock);
            mockHelper.
              Setup(x => x.SpecialistPrivateProfileHelper).
              Returns(SpecialistPrivateProfileHelperMock);
            mockHelper.
                Setup(x => x.TenantPrivateProfileHelper).
                Returns(TenantPrivateProfileHelperMock);
            #endregion

            #endregion

            #region Mocking MemberShipService
            //MembershipService Optional
            var membershipMock = new Mock<IMembershipService>();
            //var userMock = new Mock<MembershipUser>();
            //var secondSpecialist = professionalRepo.MyList[1];
            //userMock.Setup(u => u.ProviderUserKey).Returns(secondSpecialist.GUID);
            //userMock.Setup(u => u.UserName).Returns(secondSpecialist.FirstName);
            //membershipMock.Setup(s => s.GetUser(It.IsAny<string>())).Returns(userMock.Object);
            #endregion

            #region Controller Construction + Mocking Context

            Controller = new AccountHelper(Uow, membershipMock.Object, mockHelper.Object, new MockEmailService());
            Controller.MockHttpContext();

            #endregion

            #region ExpectedResult Helper
            ExpectedOwner = new ExpectedHelper(Uow).GetExpectedOwner();
            ExpectedAgent = new ExpectedHelper(Uow).GetExpectedAgent();
            ExpectedTenant = new ExpectedHelper(Uow).GetExpectedTenant();
            ExpectedProvider = new ExpectedHelper(Uow).GetExpectedProvider();
            ExpectedSpecialist = new ExpectedHelper(Uow).GetExpectedSpecialist();
            #endregion

            #endregion //AccountHelperTest
        }
 /// <summary>
 /// JobOfferHelper Instance
 /// </summary>
 /// <returns></returns>
 public void InsertPendingJobOffer(int providerid, Tenant tenant, int propertyid, DateTime startDate, DateTime endDate)
 {
     JobOffer.InsertPendingJobOffer(providerid, tenant, propertyid, startDate, endDate);
 }
        public void Initialize()
        {
            // Arrange
            #region AccountHelperTest

            #region Repo
            var maintenanceCompanyLookUpRepo = new FakeMaintenanceCompanyLookUpRepository();
            var maintenanceCompanyRepo = new FakeMaintenanceCompanyRepository();
            var maintenanceCompanySpecializationRepo = new FakeMaintenanceCompanySpecializationRepository();
            var maintenanceCustomServicesRepo = new FakeMaintenanceCustomServiceRepository();
            var maintenanceExteriorRepo = new FakeMaintenanceExteriorRepository();
            var maintenanceInteriorRepo = new FakeMaintenanceInteriorRepository();
            var maintenanceNewConstructionRepo = new FakeMaintenanceNewConstructionRepository();
            var maintenanceRepairRepo = new FakeMaintenanceRepairRepository();
            var maintenanceUtilityRepo = new FakeMaintenanceUtilityRepository();

            var currencyRepo = new FakeCurrencyRepository();
            var specialistProfileCommentRepo = new FakeSpecialistProfileCommentRepository();
            var specialistWorkRepo = new FakeSpecialistWorkRepository();
            var agentRepo = new FakeAgentRepository();
            var ownerRepo = new FakeOwnerRepository();
            var specialistRepo = new FakeSpecialistRepository();
            var tenantRepo = new FakeTenantRepository();
            var providerRepo = new FakeMaintenanceProviderRepository();
            Uow = new UnitofWork
            {
                MaintenanceCompanyLookUpRepository = maintenanceCompanyLookUpRepo,
                MaintenanceCompanyRepository = maintenanceCompanyRepo,
                MaintenanceCompanySpecializationRepository = maintenanceCompanySpecializationRepo,
                MaintenanceCustomServiceRepository = maintenanceCustomServicesRepo,
                MaintenanceExteriorRepository = maintenanceExteriorRepo,
                MaintenanceInteriorRepository = maintenanceInteriorRepo,
                MaintenanceNewConstructionRepository = maintenanceNewConstructionRepo,
                MaintenanceRepairRepository = maintenanceRepairRepo,
                MaintenanceUtilityRepository = maintenanceUtilityRepo,
                CurrencyRepository = currencyRepo,
                SpecialistProfileCommentRepository = specialistProfileCommentRepo,
                SpecialistWorkRepository = specialistWorkRepo,
                AgentRepository = agentRepo,
                OwnerRepository = ownerRepo,
                SpecialistRepository = specialistRepo,
                TenantRepository = tenantRepo,
                MaintenanceProviderRepository = providerRepo
            };
            #endregion

            #region Mocking IUserHelper

            #region  AccountHelper UserHelper
            var mockHelper = new Mock<IUserHelper>();
            mockHelper.
                Setup(x => x.UserIdentity).
                Returns(new UserIdentity(Uow, new FakeMembershipProvider()));
            mockHelper.
                Setup(x => x.AgentPrivateProfileHelper).
                Returns(AgentPrivateProfileHelperMock);
            mockHelper.
              Setup(x => x.OwnerPrivateProfileHelper).
              Returns(OwnerPrivateProfileHelperMock);
            mockHelper.
              Setup(x => x.ProviderPrivateProfileHelper).
              Returns(ProviderPrivateProfileHelperMock);
            mockHelper.
              Setup(x => x.SpecialistPrivateProfileHelper).
              Returns(SpecialistPrivateProfileHelperMock);
            mockHelper.
                Setup(x => x.TenantPrivateProfileHelper).
                Returns(TenantPrivateProfileHelperMock);
            #endregion

            #endregion

            #region Mocking MemberShipService
            var fakeMemberShipService = new FakeMemberShipService();
            #endregion

            #region Controller Construction + Mocking Context

            Controller = new TenantController(Uow, fakeMemberShipService, mockHelper.Object);
            Controller.MockHttpContext();

            #endregion

            #region ExpectedResult Helper
            ExpectedOwner = new ExpectedHelper(Uow).GetExpectedOwner();
            ExpectedAgent = new ExpectedHelper(Uow).GetExpectedAgent();
            ExpectedTenant = new ExpectedHelper(Uow).GetExpectedTenant();
            ExpectedProvider = new ExpectedHelper(Uow).GetExpectedProvider();
            ExpectedSpecialist = new ExpectedHelper(Uow).GetExpectedSpecialist();
            #endregion

            #endregion //AccountHelperTest
        }