public MaintenanceProvider FirstMaintenanceProvider() { var firstMaintenanceProvider = new MaintenanceProvider { MaintenanceProviderId = 1 , FirstName = null, LastName = null, Address = null, EmailAddress = null, Description = null, GUID = new Guid("dddddddd-dddd-dddd-1122-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, PercentageofCompletion = new Int32(), Rating = new Int32(), YouTubeVideo = new Boolean() , YouTubeVideoURL = "http://www.providerTube.com", VimeoVideo = new Boolean() , VimeoVideoURL = null }; return firstMaintenanceProvider; }
public ActionResult ChangeAddress(MaintenanceProvider provider) { if (ModelState.IsValid) { provider.GoogleMap = UserHelper.ProviderPrivateProfileHelper.ProviderGoogleMap(); UnitofWork.MaintenanceProviderRepository.Edit(provider); UnitofWork.Save(); return RedirectToAction("Index"); } return View(provider); }
public ActionResult Edit(MaintenanceProvider provider) { if (ModelState.IsValid) { UnitofWork.MaintenanceProviderRepository.Edit(provider); UnitofWork.Save(); UserHelper.ProviderPrivateProfileHelper.UpdateProviderMaintenanceCompany(); return RedirectToAction("Index"); } return View(provider); }
public string SocialTitleBuilding(MaintenanceProvider s) { var title = s.FirstName; if (title != null) { title += " , "; } title += s.LastName; if (title.Length >= 1) { title += " , "; } title += s.Address; if (title.Length >= 1) { title += " , "; } title += s.Region; if (title.Length >= 1) { title += " , "; } title += s.City; if (title.Length >= 1) { title += " , "; } if (title.Length >= 50) { title = title.Substring(0, 50); } return title; }
public void ShareProvider(MaintenanceProvider s) { if (Request == null || Request.Url == null) return; var url = Request.Url.AbsoluteUri.ToString(CultureInfo.InvariantCulture); var title = SocialTitleBuilding(s); var summary = s.Description; if (!String.IsNullOrEmpty(summary)) { if (summary.Length >= 140) { summary = summary.Substring(0, 140); } } var tweet = title; if (tweet != null && title.Length >= 1) { tweet += "--"; } tweet += url; if (!String.IsNullOrEmpty(tweet)) { if (tweet.Length >= 140) { tweet = tweet.Substring(0, 140); } } //TODO UPDATE BEFORE RELEASE const string sitename = "http://www.haithem-araissia.com"; //This is the correct one for production because facebook require active url present. after you Register your domain //ViewBag.FaceBook = SocialHelper.FacebookShareOnlyUrl(url); //TOD UPDATE BEFORE RELEASE ViewBag.FaceBook = new SocialHelper().FacebookShareOnlyUrl(sitename); ViewBag.Twitter = new SocialHelper().TwitterShare(tweet); ViewBag.GooglePlusShare = new SocialHelper().GooglePlusShare(url); ViewBag.LinkedIn = new SocialHelper().LinkedInShare(url, title, summary, sitename); }
public void RegisterProvider(RegisterModel model) { var nextproviderId = UnitofWork.MaintenanceProviderRepository.All. OrderByDescending(x => x.MaintenanceProviderId). First().MaintenanceProviderId + 1; var newprovider = new MaintenanceProvider { EmailAddress = model.Email, MaintenanceProviderId = nextproviderId }; var user = MembershipService.GetUser(model.UserName); if (user != null) { if (user.ProviderUserKey != null) newprovider.GUID = new Guid(user.ProviderUserKey.ToString()); newprovider.FirstName = model.UserName; newprovider.Photo = "./../images/dotimages/avatar-placeholder.png"; newprovider.GoogleMap = "USA"; UnitofWork.MaintenanceProviderRepository.Add(newprovider); UnitofWork.Save(); ProviderInitialProfileValues(model, newprovider.MaintenanceProviderId); } }
public MaintenanceProvider SecondMaintenanceProvider() { var secondMaintenanceProvider = new MaintenanceProvider { MaintenanceProviderId = 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, PercentageofCompletion = new Int32(), Rating = new Int32(), YouTubeVideo = new Boolean() , YouTubeVideoURL = null, VimeoVideo = new Boolean() , VimeoVideoURL = null }; return secondMaintenanceProvider; }
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 }
public string SocialTitleBuilding(MaintenanceProvider s) { return ProviderPublicProfileHelper.SocialTitleBuilding(s); }
public void ShareProvider(MaintenanceProvider s) { ProviderPublicProfileHelper.ShareProvider(s); }
public void UpdateproviderProfile(MaintenanceProvider p, MaintenanceCompany m) { ProviderPrivateProfileHelper.UpdateproviderProfile(p, m); }
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 }
// ReSharper disable once FunctionComplexityOverflow public void UpdateproviderProfile(MaintenanceProvider p, MaintenanceCompany m) { var providerId = UserHelper.GetProviderId(); var provider = UnitofWork.MaintenanceProviderRepository.FirstOrDefault(x => x.MaintenanceProviderId == providerId); if (provider == null) return; if (!string.IsNullOrEmpty(m.VCard)) { provider.VCard = m.VCard; } if (!string.IsNullOrEmpty(m.Skype)) { provider.Skype = m.Skype; } if (!string.IsNullOrEmpty(m.Twitter)) { provider.Twitter = m.Twitter; } if (!string.IsNullOrEmpty(m.LinkedIn)) { provider.LinkedIn = m.LinkedIn; } if (!string.IsNullOrEmpty(m.GooglePlus)) { provider.GooglePlus = m.GooglePlus; } if (!string.IsNullOrEmpty(m.Address)) { provider.Address = m.Address; } if (!string.IsNullOrEmpty(m.Country)) { provider.Country = m.Country; } if (!string.IsNullOrEmpty(m.Region)) { provider.City = m.Region; } if (!string.IsNullOrEmpty(m.City)) { provider.City = m.City; } if (!string.IsNullOrEmpty(m.Zip)) { provider.Zip = m.Zip; } if (!string.IsNullOrEmpty(m.Description)) { provider.Description = m.Description; } provider.GoogleMap = m.GoogleMap = string.IsNullOrEmpty(m.Address) ? UserHelper.GetFormattedLocation("", "", "USA") : UserHelper.GetFormattedLocation(m.Address, m.City, m.Country); provider.YouTubeVideo = p.YouTubeVideo; provider.YouTubeVideoURL = p.YouTubeVideoURL; provider.VimeoVideo = p.VimeoVideo; provider.VimeoVideoURL = p.VimeoVideoURL; }