public RegisterModel SecondRegisterModel() { var secondRegisterModel = new RegisterModel { UserName = null, Email = null, Password = null, ConfirmPassword = null, Role = null }; return secondRegisterModel; }
public RegisterModel ThirdRegisterModel() { var thirdRegisterModel = new RegisterModel { UserName = null, Email = null, Password = null, ConfirmPassword = null, Role = null }; return thirdRegisterModel; }
public RegisterModel FirstRegisterModel() { var firstRegisterModel = new RegisterModel { UserName = null, Email = null, Password = null, ConfirmPassword = null, Role = null }; return firstRegisterModel; }
public ActionResult Register(RegisterModel model) { if (!ModelState.IsValid) return View(model); MembershipCreateStatus createStatus; MembershipService.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); if (createStatus == MembershipCreateStatus.Success) { FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); Roles.AddUserToRole(model.UserName, model.Role); AccountHelper.RegisterAccountByType(model); return RedirectToAction("Index", model.Role); } ModelState.AddModelError("", new ErrorCode().ErrorCodeToString(createStatus)); return View(model); }
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(); } }
/// Initialize ProfileByType public void SpecialistInitialProfileValues(RegisterModel model, int specialistId) { if (specialistId != 0) { var nextCompanyId = UnitofWork.MaintenanceCompanyLookUpRepository.All.OrderByDescending(x => x.CompanyId) .First() .CompanyId + 1; var newMaintenanceCompanyLookUp = new MaintenanceCompanyLookUp { CompanyId = nextCompanyId, UserId = specialistId, Role = (int) LookUpRoles.Roles.Specialist }; var newMaintenanceCompany = new MaintenanceCompany { CompanyId = nextCompanyId, Name = model.UserName, EmailAddress = model.Email, GoogleMap = "USA", Country = "US", MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp // CountryCode = "US" }; var newMaintenanceCompanySpecialization = new MaintenanceCompanySpecialization { CompanyId = nextCompanyId, NumberofEmployee = 1, NumberofCertifitedEmplyee = 1, IsInsured = true, Rate = 50, CurrencyID = 1, Currency = "USD", MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var newMaintenanceCustomService = new MaintenanceCustomService { CompanyId = nextCompanyId, MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var newMaintenanceExterior = new MaintenanceExterior { CompanyId = nextCompanyId, MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var newMaintenanceInterior = new MaintenanceInterior { CompanyId = nextCompanyId, MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var newMaintenanceNewConstruction = new MaintenanceNewConstruction { CompanyId = nextCompanyId, MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var newMaintenanceRepair = new MaintenanceRepair { CompanyId = nextCompanyId, MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var newMaintenanceUtility = new MaintenanceUtility { CompanyId = nextCompanyId, MaintenanceCompanyLookUp = newMaintenanceCompanyLookUp }; var specialistwork = new SpecialistWork { PhotoPath = "./../images/dotimages/home-handyman-projects.jpg", SpecialistId = specialistId }; UnitofWork.MaintenanceCompanyLookUpRepository.Add(newMaintenanceCompanyLookUp); UnitofWork.MaintenanceCompanyRepository.Add(newMaintenanceCompany); UnitofWork.MaintenanceCompanySpecializationRepository.Add(newMaintenanceCompanySpecialization); UnitofWork.MaintenanceCustomServiceRepository.Add(newMaintenanceCustomService); UnitofWork.MaintenanceExteriorRepository.Add(newMaintenanceExterior); UnitofWork.MaintenanceInteriorRepository.Add(newMaintenanceInterior); UnitofWork.MaintenanceNewConstructionRepository.Add(newMaintenanceNewConstruction); UnitofWork.MaintenanceRepairRepository.Add(newMaintenanceRepair); UnitofWork.MaintenanceUtilityRepository.Add(newMaintenanceUtility); UnitofWork.SpecialistWorkRepository.Add(specialistwork); UnitofWork.Save(); } }
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 void RegisterSpecialist(RegisterModel model) { var nextspecialistId = UnitofWork.SpecialistRepository.All.OrderByDescending(x => x.SpecialistId) .First() .SpecialistId + 1; var newspecialist = new Specialist { EmailAddress = model.Email, SpecialistId = nextspecialistId }; var user = MembershipService.GetUser(model.UserName); if (user != null) { if (user.ProviderUserKey != null) newspecialist.GUID = new Guid(user.ProviderUserKey.ToString()); newspecialist.FirstName = model.UserName; newspecialist.Photo = "./../images/dotimages/avatar-placeholder.png"; newspecialist.GoogleMap = "USA"; newspecialist.PercentageofCompletion = 50; UnitofWork.SpecialistRepository.Add(newspecialist); UnitofWork.Save(); SpecialistInitialProfileValues(model, newspecialist.SpecialistId); } }
/// RegisterAccount public void RegisterAccountByType(RegisterModel model) { if (model.Role == LookUpRoles.TenantRole) { RegisterTenant(model); } if (model.Role == LookUpRoles.OwnerRole) { RegisterOwner(model); } if (model.Role == LookUpRoles.AgentRole) { RegisterAgent(model); } if (model.Role == LookUpRoles.SpecialistRole) { RegisterSpecialist(model); } if (model.Role == LookUpRoles.ProviderRole) { RegisterProvider(model); } }
public void RegisterTenant() { var newTenant = new RegisterModel { UserName = "******", Email = "New Jeff Email Address", Password = "******", ConfirmPassword = "******", Role = "Tenant" }; Controller.UserHelper.UserIdentity.MockTenantFred(); Controller.MembershipService = new MockMemberShipService().MockFredTenantMembership(); Controller.RegisterTenant(newTenant); var newtenantCount = Uow.TenantRepository.Count(x => x.GUID.ToString() == new FakeMembershipProvider().FakeUserJeff.ProviderUserKey.ToString() && x.EmailAddress == "New Jeff Email Address"); Assert.AreEqual(newtenantCount, 1); }
public void RegisterSpecialist() { var newSpecialist = new RegisterModel { UserName = "******", Email = "New Sara Email Address", Password = "******", ConfirmPassword = "******", Role = LookUpRoles.SpecialistRole }; Controller.UserHelper.UserIdentity.MockSaraSpecialist(); Controller.MembershipService = new MockMemberShipService().MockSaraSpecialistMembership(); Controller.RegisterSpecialist(newSpecialist); var newAddedSpecialist = Uow.SpecialistRepository.FindBy(x => x.GUID.ToString() == new FakeMembershipProvider().FakeUserSara.ProviderUserKey.ToString() && x.EmailAddress == "New Sara Email Address").FirstOrDefault(); var newAddedSpecialistCompanyLookUp = Uow.MaintenanceCompanyLookUpRepository.FindBy( x => x.UserId == newAddedSpecialist.SpecialistId && x.Role == (int)LookUpRoles.Roles.Specialist) .FirstOrDefault(); var newAddedSpecialistCompanySpecialization = Uow.MaintenanceCompanySpecializationRepository.FirstOrDefault(x => x.CompanyId == newAddedSpecialistCompanyLookUp.CompanyId); Assert.AreEqual(newAddedSpecialistCompanySpecialization.Rate, 50); }
public void RegisterProvider() { var newProvider = new RegisterModel { UserName = "******", Email = "New Jeff Email Address", Password = "******", ConfirmPassword = "******", Role = LookUpRoles.ProviderRole }; Controller.UserHelper.UserIdentity.MockJeffProvider(); Controller.MembershipService = new MockMemberShipService().MockJeffProviderMembership(); Controller.RegisterProvider(newProvider); var newAddedProvider = Uow.MaintenanceProviderRepository.FindBy(x => x.GUID.ToString() == new FakeMembershipProvider().FakeUserJeff.ProviderUserKey.ToString() && x.EmailAddress == "New Jeff Email Address").FirstOrDefault(); var newAddedProviderCompanyLookUp = Uow.MaintenanceCompanyLookUpRepository.FindBy( x => x.UserId == newAddedProvider.MaintenanceProviderId && x.Role == (int)LookUpRoles.Roles.Provider) .FirstOrDefault(); var newAddedProviderCompanySpecialization = Uow.MaintenanceCompanySpecializationRepository.FirstOrDefault(x => x.CompanyId == newAddedProviderCompanyLookUp.CompanyId); Assert.AreEqual(newAddedProviderCompanySpecialization.NumberofEmployee, 1); }
public void RegisterOwner() { var newOwner = new RegisterModel { UserName = "******", Email = "New lisa Email Address", Password = "******", ConfirmPassword = "******", Role = "Owner" }; Controller.UserHelper.UserIdentity.MockLisaOwner(); Controller.MembershipService = new MockMemberShipService().MockLisaOwnerMembership(); Controller.RegisterOwner(newOwner); var newOwnerCount = Uow.OwnerRepository.Count(x => x.GUID.ToString() == new FakeMembershipProvider().FakeUserLisa.ProviderUserKey.ToString() && x.EmailAddress == "New lisa Email Address"); Assert.AreEqual(newOwnerCount, 1); }