Exemplo n.º 1
0
        // Get all basic tables
        // DEFAULT CRUD
        public IEnumerable <TenantMapper> GetTenants()
        {
            var content = db.Tenants.ToList();

            if (content.Count() == 0)
            {
                return(null);
            }
            else
            {
                List <TenantMapper> tenants = new List <TenantMapper>();
                foreach (var item in content)
                {
                    TenantMapper tenant = new TenantMapper
                    {
                        TenantId      = item.tenantId,
                        ContactId     = item.contactId ?? 0,
                        BatchId       = item.batchId ?? 0,
                        HousingUnitId = item.housingUnitId ?? 0,
                        GenderId      = item.genderId ?? 0,
                        MoveInDate    = item.moveInDate,
                        HasMoved      = item.hasMoved ?? default(bool),
                        HasKey        = item.hasKey ?? default(bool)
                    };
                    tenants.Add(tenant);
                }
                return(tenants);
            }
        }
Exemplo n.º 2
0
        public async Task <IActionResult> UpdateTenant(
            [HttpTrigger(AuthorizationLevel.Function, "put", Route = "tenant/{id}")] HttpRequest req,
            [FromRoute(Name = "id")] string id,
            ILogger log)
        {
            var parseResult = Guid.TryParse(id, out Guid tenantId);

            if (!parseResult)
            {
                return(new BadRequestObjectResult("Invalid tenantId"));
            }

            var body = await req.GetBodyAsync <TenantRequestModel>();

            if (!body.IsValid)
            {
                return(new BadRequestObjectResult(body.ValidationMessage));
            }
            var tenantRequestModel = body.Value;

            var existingTenant = await tenantStoreService.GetTenantAsync(tenantId);

            if (existingTenant == null)
            {
                return(new NotFoundObjectResult("Tenant not found"));
            }

            TenantMapper.Map(tenantRequestModel, existingTenant);
            await tenantStoreService.UpdateTenantAsync(existingTenant);

            return(new NoContentResult());
        }
Exemplo n.º 3
0
        public IEnumerable <TenantDto> GetAllTenants()
        {
            IEnumerable <Tenant>    tenantList    = _unitOfWork.TenantRepository.GetAll();
            IEnumerable <TenantDto> tenantDtoList = tenantList.Select(tenent => TenantMapper.EntityMapToDto(tenent)); // .ToList();

            return(tenantDtoList);
        }
        public override void PreInitialize()
        {
            // 权限认证提供者
            Configuration.Authorization.Providers.Add <YoyoCmsTemplateAuthorizationProvider>();
            Configuration.Authorization.Providers.Add <EditionAuthorizationProvider>();

            // 类型映射
            Configuration.Modules.AbpAutoMapper().Configurators.Add(EditionMapper.CreateMappings);

            // 自定义类型映射
            Configuration.Modules.AbpAutoMapper().Configurators.Add(configuration =>
            {
                // Add your custom AutoMapper mappings here...
                CustomerLanguageMapper.CreateMappings(configuration);

                // Permission
                CustomerPermissionsMapper.CreateMappings(configuration);

                // OrganizationUnit
                CustomerOranizationMapper.CreateMappings(configuration);

                //
                TenantMapper.CreateMappings(configuration);
            });
        }
Exemplo n.º 5
0
        public async Task <IActionResult> CreateTenant(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "tenant")] HttpRequest req,
            ILogger log)
        {
            var body = await req.GetBodyAsync <TenantRequestModel>();

            if (!body.IsValid)
            {
                return(new BadRequestObjectResult(body.ValidationMessage));
            }

            var tenant = TenantMapper.Map(body.Value);
            await tenantStoreService.CreateTenantAsync(tenant);

            return(new CreatedResult(new Uri($"api/tenant/{tenant.id}", UriKind.Relative), tenant.id));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="TenancyService"/> class.
 /// </summary>
 /// <param name="tenantStore">The tenant store.</param>
 /// <param name="propertyBagFactory">Provides property bag initialization and modification services.</param>
 /// <param name="tenantMapper">The mapper from tenants to tenant resources.</param>
 /// <param name="tenantCollectionResultMapper">The mapper from tenant collection results to the result resource.</param>
 /// <param name="linkResolver">The link resolver.</param>
 /// <param name="cacheConfiguration">Cache configuration.</param>
 /// <param name="logger">The logger for the service.</param>
 public TenancyService(
     ITenantStore tenantStore,
     IPropertyBagFactory propertyBagFactory,
     TenantMapper tenantMapper,
     TenantCollectionResultMapper tenantCollectionResultMapper,
     IOpenApiWebLinkResolver linkResolver,
     TenantCacheConfiguration cacheConfiguration,
     ILogger <TenancyService> logger)
 {
     this.tenantStore  = tenantStore ?? throw new ArgumentNullException(nameof(tenantStore));
     this.tenantMapper = tenantMapper ?? throw new ArgumentNullException(nameof(tenantMapper));
     this.tenantCollectionResultMapper = tenantCollectionResultMapper ?? throw new ArgumentNullException(nameof(tenantCollectionResultMapper));
     this.linkResolver       = linkResolver ?? throw new ArgumentNullException(nameof(linkResolver));
     this.cacheConfiguration = cacheConfiguration ?? throw new ArgumentNullException(nameof(cacheConfiguration));
     this.logger             = logger ?? throw new ArgumentNullException(nameof(logger));
     this.propertyBagFactory = propertyBagFactory;
 }
Exemplo n.º 7
0
        // Get one basic table
        // DEFAULT CRUD
        public TenantMapper GetTenant(int id)
        {
            var content = db.Tenants.FirstOrDefault(j => j.tenantId == id);

            if (content == null)
            {
                return(null);
            }
            else
            {
                TenantMapper tenant = new TenantMapper
                {
                    TenantId      = content.tenantId,
                    ContactId     = content.contactId ?? 0,
                    BatchId       = content.batchId ?? 0,
                    HousingUnitId = content.housingUnitId ?? 0,
                    GenderId      = content.genderId ?? 0,
                    MoveInDate    = content.moveInDate,
                    HasMoved      = content.hasMoved ?? default(bool),
                    HasKey        = content.hasKey ?? default(bool)
                };
                return(tenant);
            }
        }