public string GetAllFactories()
        {
            var result = "";

            using (diplomaDBContext = new DiplomaDBContext())
            {
                var factories = diplomaDBContext.RecycleFactory.ToArray();

                var factoryLocation = new FactoryLocation[factories.Length];
                for (int i = 0; i < factoryLocation.Length; i++)
                {
                    var location = new Diploma_WebControllerAPI.ViewModels.Location
                    {
                        Latitude  = diplomaDBContext.Location.Single(l => l.Id == factories[i].LocationId).Latitude,
                        Longitude = diplomaDBContext.Location.Single(l => l.Id == factories[i].LocationId).Longitude
                    };

                    var region = diplomaDBContext.Region.FirstOrDefault(r => r.RecycleFactoryId == factories[i].Id);

                    factoryLocation[i] = new FactoryLocation
                    {
                        Id       = factories[i].Id,
                        Name     = factories[i].Name,
                        Ready    = factories[i].Ready,
                        Region   = region == null ? "" : region.Name,
                        Location = location
                    };
                }

                result = JsonSerializer.Serialize(factoryLocation, JsonOptions);
            }

            Response.Headers.Add("Access-Control-Allow-Origin", "http://localhost:3000");
            return(result);
        }
Пример #2
0
        public string ReplaceSecretsWithExampleStrings(string jsonActual)
        {
            string ret = jsonActual;

            ret = ReplaceOne(ret, TenantId, ExampleTenantId);
            ret = ReplaceOne(ret, ClientId, ExampleClientId);
            ret = ReplaceOne(ret, ClientSecret, ExampleClientSecret);
            ret = ReplaceOne(ret, SubId, ExampleSubId);
            ret = ReplaceOne(ret, ResourceGroupName, ExampleResourceGroupName);
            ret = ReplaceOne(ret, ResourceGroupName.ToLowerInvariant(), ExampleResourceGroupName.ToLowerInvariant());
            ret = ReplaceOne(ret, FactoryName, ExampleFactoryName);
            ret = ReplaceOne(ret, FactoryName.ToLowerInvariant(), ExampleFactoryName.ToLowerInvariant());
            ret = ReplaceOne(ret, FactoryLocation, ExampleFactoryLocation);
            ret = ReplaceOne(ret, FactoryLocation.ToLowerInvariant(), ExampleFactoryLocation.ToLowerInvariant());
            ret = ReplaceOne(ret, StorageAccountName, ExampleStorageAccountName);
            ret = ReplaceOne(ret, StorageAccountKey, ExampleStorageAccountKey);
            ret = ReplaceOne(ret, BlobContainerName, ExampleBlobContainerName);
            return(ret);
        }
        public IProductFactory GetProductFactory(FactoryLocation factoryLocation)
        {
            IProductFactory factory = null;

            switch (factoryLocation)
            {
            case FactoryLocation.India:
                factory = new IndiaFactory();
                break;

            case FactoryLocation.China:
                factory = new ChinaFactory();
                break;

            default:
                factory = null;
                break;
            }

            return(factory);
        }