Example #1
0
        private Data.Entity.Models.Tenant Map(TenantCreateModel model, Company company, User user)
        {
            var result = new Data.Entity.Models.Tenant
            {
                CompanyId         = company.Id,
                Slug              = model.Name,
                OwnerId           = user.Id,
                Name              = model.Name,
                BusinessHours     = GetBusinessHours(model.BusinessHours),
                PaymentMethodType = model.PaymentMethodTypes.ToFlag(),
                NotificationType  = model.NotificationTypes.ToFlag(),
                Description       = model.Description,
                Tags              = model.Tags,
                DeliveryTime      = model.DeliveryTime ?? default,
                DeliveryFee       = model.DeliveryFee ?? default,
                IsActive          = true,
                PhoneNumber       = model.PhoneNumber,
                FacebookUrl       = model.FacebookUrl,
                WhatsAppNumber    = model.WhatsAppNumber
            };

            if (model.LogoUrl != null)
            {
                result.Logo = new TenantImage
                {
                    Url = model.LogoUrl
                };
            }

            return(result);
        }
Example #2
0
        public async Task <CreateObjectResult> Create(string companySlug, TenantCreateModel model)
        {
            var user = await _userManager.GetUserAsync(User);

            var tenantSlug = await _tenantService.CreateAsync(companySlug, model, user);

            return(Created(tenantSlug));
        }
        public ActionResult Index(TenantCreateModel model)
        {
            if (!ModelState.IsValid)
            {
                model.TimeZones = TimeZoneInfo.GetSystemTimeZones().ToList();
                return(View(model));
            }

            TenantDto tenantDto = this.tenantService.Create(model.TenantName, model.TenantFriendlyName,
                                                            model.TimeZoneId, model.ClientID, new Uri(model.Authority), model.UserEmail);

            return(Redirect($"/{tenantDto.NameFriendly}/usersetup/init/?initKey={tenantDto.Id}&email={ HttpUtility.HtmlEncode(model.UserEmail)}"));
        }
Example #4
0
        public ActionResult Create(TenantCreateModel model)
        {
            // The model must contain a zip file.
            // check the zip file for validity
            // copy the zip (as a zip) file into the workspace's temp folder and provide the path
            var zipFolder = "";
            // provide the filename and the folder to the Register function. the file name must be the tenant id
            var tenantId        = "the file name";
            var tenantRegistrar = MultiTenantFactory.GetTenantRegistrar();

            tenantRegistrar.Register(tenantId, zipFolder);
            return(PartialView("_Create", model));
        }
Example #5
0
        public async Task <string> CreateAsync(string companySlug, TenantCreateModel model, User user)
        {
            var company = await ValidateAsync(companySlug, user);

            var tenant = Map(model, company, user);

            _dbContext.Tenants.Add(tenant);
            await _dbContext.SaveChangesAsync();

            tenant.Slug = _slugService.GetSlug(tenant.Name, tenant.Id);

            _dbContext.Tenants.Update(tenant);
            await _dbContext.SaveChangesAsync();

            return(tenant.Slug);
        }
Example #6
0
        public async Task CreateTenant()
        {
            var mediator = ServiceProvider.GetService <IMediator>();

            mediator.Should().NotBeNull();

            var createModel = new TenantCreateModel
            {
                Slug        = "Test" + DateTime.Now.Ticks,
                Name        = "Test Department " + DateTime.Now.Ticks,
                Description = "Created from Unit Test",
                TimeZone    = "Central Standard Time"
            };

            var command = new EntityCreateCommand <TenantCreateModel, TenantReadModel>(MockPrincipal.Default, createModel);

            var result = await mediator.Send(command).ConfigureAwait(false);

            result.Should().NotBeNull();
        }