public ActionResult Login(LoginModel model, string returnUrl) { if (ModelState.IsValid) { try { //process login... //Login().IsValid... Tenant.Create(model.UserName, model.CustomerName); //redirect to home page... } catch (Exception e) { ModelState.AddModelError("", e.Message); return(View(model)); } return(RedirectToLocal(returnUrl)); } // If we got this far, something failed, redisplay form ModelState.AddModelError("", "The user name or password provided is incorrect."); return(View(model)); }
public async Task RegisterUser(string tenantName, string cellPhone, string userName) { Ensure.NotNullOrEmpty(tenantName, nameof(tenantName)); Ensure.NotNullOrEmpty(cellPhone, nameof(cellPhone)); Ensure.NotNullOrEmpty(userName, nameof(userName)); var database = await _databaseRepository.FirstOrDefaultAsyncByFunc(q => q.OrderByDescending(e => e.PId)); if (database == null) { throw new AppException($"未找到可用的数据库!"); } //检查租户是否已存在 var tenant = await _tenantRepository.FirstOrDefaultAsync(a => a.TenantName == tenantName); if (tenant != null) { throw new AppException($"公司名称:{tenantName}已注册"); } tenant = Tenant.Create(tenantName, database.PId, cellPhone); var tenantId = await _tenantRepository.InsertAndGetIdAsync(tenant); using (_unitOfWorkManager.Current.SetTenantId(tenantId)) { var user = User.Register(cellPhone, userName); var globalAccount = GlobalAccount.Create(tenantId, user.PId, user.CellPhone, user.Email); _userRepository.Insert(user); _globalAccountRepository.Insert(globalAccount); } }
public void Can_Map_Tenant() { var tenant = Tenant.Create("ttin", "1234", "aasss", "*****@*****.**", "1234", "1234", "1234", "addfdf", "sddd", "sdsd", "12222"); tenant.AddIndividual(DateTime.Today, GenderEnum.Male, "1222", "12131"); var vm = Mapper.Map <TenantRegisterViewModel>(tenant); Assert.AreEqual("1234 1234", vm.FullAddress); }
static void CreateTenants() { //Create Tenants. var agileFx_Tenant = Tenant.Create("AgileFx", "agilefx.org", "premium", "+5:30", DEFAULT_LOGO, context); var agilehead_Tenant = Tenant.Create("AgileHead", "agilehead.com", "premium", "+5:30", DEFAULT_LOGO, context); context.SaveChanges(); CreateWebsite("AgileFx Site", WEBSITE_TYPE.CMS, "AgileFx Framework", "agilefx.org", "/", agileFx_Tenant); CreateWebsite("AgileFx Blog", WEBSITE_TYPE.BLOG, "AgileFx Framework Blog", "blog.agilefx.org", "/", agileFx_Tenant); CreateWebsite("AgileHead Site", WEBSITE_TYPE.CMS, "AgileHead Technology Consulting", "agilehead.com", "/", agilehead_Tenant); CreateWebsite("Technobabble: by AgileHead", WEBSITE_TYPE.BLOG, "AgileHead Blog", "blog.agilehead.com", "/", agilehead_Tenant); }
public TenantDto Create(string tenantName, string friendlyName, string timeZoneId, string clientId, Uri authority, string userEmail) { this.unitOfWork.BeginTransaction(); Tenant tenant = Tenant.Create(tenantName, friendlyName, timeZoneId, clientId, authority, userEmail); this.tenantRepo.Add(tenant); TenantDto tenantDto = Mapper.Map <TenantDto>(tenant); this.unitOfWork.Commit(); return(tenantDto); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddMultiTenant(builder => { builder.SetTenantIdentificationSource(TenantIdentificationSource.Custom); builder.SetTenantIdentificationCustomProvider(context => Guid.NewGuid()); builder.SetTenantStorage(new MemoryTenantStorage(new List <Tenant> { Tenant.Create(Guid.NewGuid(), "", "", "", 0, "", "") })); }); }
public IActionResult Create([FromBody] OaTenant oaTenant) { if (oaTenant == null) { return(BadRequest()); } // Call Models var tenantId = Tenant.Create(_setting, Request, oaTenant); return(CreatedAtRoute( "Root", null, new { tenantId } )); }
public IHttpActionResult Post( [FromBody] CreateTenantModel command) { if (command == null || !ModelState.IsValid) { return(this.Error().InvalidParameters("Tenant body parameters missing")); } var dbProviderConfig = CreateDBProviderConfiguration(command); var tenant = Tenant.Create(0, command.Name, command.DefaultTheme, dbProviderConfig); _tenantsRepository.Add(tenant); _tenantsRepository.SaveChanges(); return(Ok(_mapper.Map <TenantModel>(tenant))); }
static void Main() { Console.Write("Informe o alias do tenant: "); var tenantAlias = Console.ReadLine(); Console.Write("Informe o nome do tenant: "); var tenantBusiness = Console.ReadLine(); Console.Write("Informe a url para database do tenant: "); var tenantDatabase = Console.ReadLine(); var urlDatabase = "http://gabriel-nt:8080"; var repository = new TenantsRepository(urlDatabase); var tenant = Tenant.Create(tenantAlias, tenantBusiness, tenantDatabase); repository.Save(tenant); var canExit = false; while (!canExit) { Console.WriteLine("Inclusão de fatura"); Console.WriteLine(""); Console.Write("Informe o nome do cliente: "); var clientInfo = Console.ReadLine(); Console.Write("Informe o valor da fatura: "); var ammount = Convert.ToDecimal(Console.ReadLine()); var invoice = Invoice.Create(clientInfo, ammount); var invoiceRepository = new InvoicesRepository(tenant); invoiceRepository.Save(invoice); Console.WriteLine(); Console.Write("Incluir outra invoice? "); var pressKey = Console.ReadKey(); if (pressKey.Key == ConsoleKey.N) { canExit = true; } Console.Clear(); } Console.Read(); }
public void Create_AllInformationIsProvided_Success() { Mock <Tenant> expected = new Mock <Tenant>(); expected.SetupGet(x => x.Name).Returns("Test"); expected.SetupGet(x => x.NameFriendly).Returns("Test"); expected.SetupGet(x => x.TimeZoneId).Returns("GMT Standard Time"); expected.SetupGet(x => x.ClientId).Returns("clientid"); expected.SetupGet(x => x.Authority).Returns(new Uri("http://somewebsite.com")); expected.SetupGet(x => x.DateCreated).Returns(new DateTime(2015, 01, 25)); expected.SetupGet(x => x.DateModified).Returns(new DateTime(2015, 01, 25)); Tenant actual = Tenant.Create("Test", "Test", "GMT Standard Time", "clientid", new Uri("http://somewebsite.com"), "*****@*****.**"); actual.ShouldBeEquivalentTo ( expected.Object, options => options.Excluding(p => p.PropertyPath == "Id") ); }
public void Create_TenantTimeZoneMissing_ThrowsException() { Tenant.Create("Test", "Test", String.Empty, String.Empty, null, String.Empty); }
public void AddTenant(TenantDto tenant) { var newTenant = Tenant.Create(tenant.Name, tenant.Description); this._tenantRep.Add(newTenant); }
public void Create_InitUserEmailMissing_ThrowsException() { Tenant.Create("Test", "Test", "TimeZoneId", "ClientID", new Uri("http://somewebsite.com"), String.Empty); }
public void Create_AuthorityMissing_ThrowsException() { Tenant.Create("Test", "Test", "TimeZoneId", "ClientID", null, String.Empty); }
public void Create_TenantFriendlyNameIsMissing_ThrowsException() { Tenant tenant = Tenant.Create("Test", String.Empty, String.Empty, String.Empty, null, String.Empty); }
public void Create_TenantNameIsMissing_ThrowsException() { Tenant tenant = Tenant.Create(String.Empty, String.Empty, String.Empty, String.Empty, null, String.Empty); }
public void Init() { TimeProvider.Current = new TestTimeProvider(new DateTime(2015, 01, 25)); this.tenant = Tenant.Create("tenant", "tenant", "GMT Standard Time", "clientid", new Uri("http://somewebsite.com"), "*****@*****.**"); }