예제 #1
0
        public IHttpActionResult Get(int id)
        {
            var tenant = _tenantsRepository.GetById(id);

            if (tenant == null)
            {
                return(this.Error().ResourceNotFound("Tenant was not found"));
            }

            var tenantModel = _mapper.Map <TenantModel>(tenant);

            return(Ok(tenantModel));
        }
예제 #2
0
        public IHttpActionResult Put([FromUri] int tenantId)
        {
            // Check tenant exists
            var tenant = _tenantsRepository.GetById(tenantId);

            if (tenant == null)
            {
                return(NotFound());
            }

            var featureManager = new FeatureManager(_featureSettingsProvider.GetForTenant(tenantId));

            ApplicationModulesLoader.SetupTenant(tenant, _configuration, _testEnvironment, featureManager);
            return(Ok());
        }
예제 #3
0
        public IHttpActionResult Get()
        {
            var user      = HttpContext.Current.GetCurrentUser();//_requestExecutionContext.User;
            var userModel = _mapper.Map <CurrentUserModel>(user);

            userModel.Tenant = _mapper.Map <CurrentUserTenantModel>(_tenantsRepository.GetById(user.TenantId));
            return(Ok(userModel));
        }
예제 #4
0
        public IHttpActionResult Post([FromUri] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (!Request.Content.IsMimeMultipartContent())
            {
                return(StatusCode(HttpStatusCode.UnsupportedMediaType));
            }

            var multipartStreamProvider = Request.Content.ReadAsMultipartAsync().Result;
            var sContent = multipartStreamProvider.Contents.SingleOrDefault();

            if (sContent == null)
            {
                return(StatusCode(HttpStatusCode.NotAcceptable));
            }

            var user = _tenantsRepository.GetById(id);

            if (user == null)
            {
                return(NotFound());
            }

            var headers     = sContent.Headers;
            var previewFile = PreviewFile.Create(
                filename: headers.ContentDisposition?.FileName,
                contentType: headers.ContentType.MediaType,
                contentLength: headers.ContentLength,
                location: "tenants");

            using (var contentStream = sContent.ReadAsStreamAsync().Result)
            {
                _tenantsRepository.SetPreviewFile(entityId: id, previewFile, contentStream);
            }
            _tenantsRepository.SaveChanges();
            return(Ok());
        }
예제 #5
0
 public void Delete(int id)
 {
     try
     {
         var tenant = Context.GetById(id);
         Context.Delete(tenant);
     }
     catch (Exception)
     {
         throw;
     }
 }