Ejemplo n.º 1
0
        public static TProviderType Resolve <TProviderType>(string providerName)
            where TProviderType : class
        {
            var tenantContainer = TenantFactory.GetNamedContainer(providerName);

            return(tenantContainer.GetInstance <TProviderType>());
        }
Ejemplo n.º 2
0
    static void Main(string[] args)
    {
        var tenant = TenantFactory.Create("A");
        var app    = var SomeTenantApp(tenant);

        app.DoSomething();
    }
Ejemplo n.º 3
0
        public IHttpActionResult GetTenantInformation()
        {
            AdalClient _client = new AdalClient(_appConfig, CredentialType.Client, null);

            try
            {
                TenantFactory _f          = new TenantFactory();
                var           _manager    = _f.CreateInstance(_client);
                var           _tenantInfo = _manager.GetTenantInformation();
                return(Ok(_tenantInfo));
            }
            catch (TIPException _ex)
            {
                var _errorResponse = new ErrorResponse();
                _errorResponse.Error = _ex.Error;
                return(Content(HttpStatusCode.InternalServerError, _errorResponse));
            }
            catch (Exception ex)
            {
                var _response = new ErrorResponse();
                _response.Error = new Error
                {
                    Code    = Common.Constants.ErrorCodes.GENERAL,
                    Message = ex.Message
                };
                return(Content(HttpStatusCode.InternalServerError, _response));
            }
        }
Ejemplo n.º 4
0
        public ActionResult InitPost(ServiceInit payload)
        {
            if (String.IsNullOrEmpty(payload.BadgeNbr))
            {
                payload.Status = "Error - Badge nbr can't be empty!";
                payload.Links  = null;
                return(new HttpStatusCodeResult(400, payload.Status));
            }

            var badgeService = TenantFactory.Create <IRepository <Badge, string> >();
            var badge        = badgeService.GetBy(n => n.Nbr == payload.BadgeNbr);

            if (badge == null)
            {
                payload.Status = String.Format("Badge with number {0} not found!", payload.BadgeNbr);
                payload.Links  = null;
                return(new HttpStatusCodeResult(404, payload.Status));
            }

            payload.Status = badge.IsActive ? "Activate" : "Declare";
            payload.Links  = new[] { new Link
                                     {
                                         Href = _serviceHelper.Root
                                                + payload.Status + "/"
                                                + payload.BadgeNbr
                                     } };

            string result = Serialize(payload);

            return(Content(result, "text/xml", Encoding.UTF8));
        }
Ejemplo n.º 5
0
 public void TestMethodInit()
 {
     tenantId        = Convert.ToInt32(Mozu.Api.Test.Helpers.Environment.GetConfigValueByEnvironment("TenantId"));
     ApiMsgHandler   = ServiceClientMessageFactory.GetTestClientMessage();
     TestBaseTenant  = TenantFactory.GetTenant(handler: ApiMsgHandler, tenantId: tenantId);
     masterCatalogId = TestBaseTenant.MasterCatalogs.First().Id;
     catalogId       = TestBaseTenant.MasterCatalogs.First().Catalogs.First().Id;
     ApiMsgHandler   = ServiceClientMessageFactory.GetTestClientMessage(tenantId, masterCatalogId: masterCatalogId, catalogId: catalogId);
 }
Ejemplo n.º 6
0
        public void Add(TenantDTO tenantDTO)
        {
            var tenant = TenantFactory.Create(tenantDTO.Descricao);

            ValideTenant(tenant);

            _repositoryFactory.TenantRepository.Add(tenant);
            _repositoryFactory.Commit();
        }
Ejemplo n.º 7
0
 public void TestMethodInit()
 {
     tenantId              = Convert.ToInt32(ConfigurationManager.AppSettings["TenantId"]);
     ApiMsgHandler         = ServiceClientMessageFactory.GetTestClientMessage();
     TestBaseTenant        = TenantFactory.GetTenant(handler: ApiMsgHandler, tenantId: tenantId);
     masterCatalogId       = TestBaseTenant.MasterCatalogs.First().Id;
     catalogId             = TestBaseTenant.MasterCatalogs.First().Catalogs.First().Id;
     ApiMsgHandler         = ServiceClientMessageFactory.GetTestClientMessage(tenantId, masterCatalogId: masterCatalogId, catalogId: catalogId);
     AnonShopperMsgHandler = ServiceClientMessageFactory.GetTestShopperMessage(tenantId, siteId: TestBaseTenant.Sites.First().Id);
 }
Ejemplo n.º 8
0
        public void TestMethodInit()
        {
            tenantId        = Convert.ToInt32(Mozu.Api.Test.Helpers.Environment.GetConfigValueByEnvironment("TenantId"));
            ApiMsgHandler   = ServiceClientMessageFactory.GetTestClientMessage();
            TestBaseTenant  = TenantFactory.GetTenant(handler: ApiMsgHandler, tenantId: tenantId);
            masterCatalogId = TestBaseTenant.MasterCatalogs.First().Id;
            catalogId       = TestBaseTenant.MasterCatalogs.First().Catalogs.First().Id;

            HttpRequestMessage msg = new HttpRequestMessage();

            msg.Headers.Add(Headers.X_VOL_TENANT, TestBaseTenant.Id.ToString());
            msg.Headers.Add(Headers.X_VOL_TENANT_DOMAIN, TestBaseTenant.Domain);
            msg.Headers.Add(Headers.X_VOL_SITE, TestBaseTenant.Sites[0].Id.ToString());

            ApiMsgHandler = ServiceClientMessageFactory.GetTestClientMessage(msg.Headers);
        }
Ejemplo n.º 9
0
 public void setTenant(string tid)
 {
     ctx = TenantFactory.getTenantCxt(tid);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// clean up products, attributes, productypes and categories since provisioning the tenant
        /// </summary>
        /// <param name="tenantId"></param>
        /// <param name="masterCatalogId"></param>
        /// <param name="siteId"></param>
        public static void CleanUpProducts(int tenantId, int masterCatalogId, int?catalogId = null, int?siteId = null)
        {
            var tenant            = TenantFactory.GetTenant(ServiceClientMessageFactory.GetTestClientMessage(), tenantId);
            var ApiMessageHandler = ServiceClientMessageFactory.GetTestClientMessage(tenantId: tenantId, masterCatalogId: masterCatalogId, catalogId: catalogId, siteId: siteId);
            var products          = ProductFactory.GetProducts(ApiMessageHandler, noCount: null, pageSize: null, q: null, qLimit: null, sortBy: null, startIndex: null, filter: "createdate gt " + SinceWhen(DateTime.Now.AddDays(-1)));

            foreach (var pro in products.Items)
            {
                ProductFactory.DeleteProduct(ApiMessageHandler, pro.ProductCode);
            }
            var productTypes = ProductTypeFactory.GetProductTypes(handler: ApiMessageHandler, successCode: HttpStatusCode.OK, expectedCode: HttpStatusCode.OK);

            foreach (var pt in productTypes.Items)
            {
                if (pt.AuditInfo.CreateDate.Value > DateTime.Now.AddDays(-1))
                {
                    try
                    {
                        ProductTypeFactory.DeleteProductType(ApiMessageHandler, pt.Id.Value);
                    }
                    catch (TestFailException e)   //getaround base product type
                    {
                        // ToDo: e.ActualReturnCode
                    }
                }
            }
            var attributes = AttributeFactory.GetAttributes(handler: ApiMessageHandler, successCode: HttpStatusCode.OK, expectedCode: HttpStatusCode.OK);

            if (attributes.TotalCount != 0)
            {
                foreach (var attr in attributes.Items)
                {
                    if (attr.AuditInfo.CreateDate.Value > DateTime.Now.AddDays(-1))
                    {
                        //bug 18745, should return NoContent
                        try
                        {
                            AttributeFactory.DeleteAttribute(ApiMessageHandler, attr.AttributeFQN);
                        }
                        catch (TestFailException e)  //get around the bug
                        {
                            // ToDo: e.ActualReturnCode
                        }
                    }
                }
            }
            var cates = CategoryFactory.GetCategories(ApiMessageHandler, pageSize: null, sortBy: null, startIndex: null, filter: "createdate gt " + SinceWhen(DateTime.Now.AddDays(-1)));

            foreach (var cate in cates.Items)
            {
                var messageHandler1 = ServiceClientMessageFactory.GetTestClientMessage(tenantId: tenantId, masterCatalogId: masterCatalogId, catalogId: catalogId, siteId: siteId);
                try
                {
                    CategoryFactory.DeleteCategoryById(handler: messageHandler1, categoryId: (int)cate.Id, cascadeDelete: true);
                }
                catch (TestFailException e)   //work around notfound
                {
                    // ToDo: e.ActualReturnCode
                }
            }
        }