Exemple #1
0
 //Search Entities
 public async Task <IEnumerable <ContainerType> > SearchContainerType(List <string> lst, List <string> includeLst = null)
 {
     using (var ctx = new ContainerTypeService())
     {
         return(await ctx.GetContainerTypesByExpressionLst(lst, includeLst).ConfigureAwait(false));
     }
 }
 public async Task SaveContainerType(ContainerType i)
 {
     if (i == null)
     {
         return;
     }
     using (var ctx = new ContainerTypeService())
     {
         await ctx.UpdateContainerType(i).ConfigureAwait(false);
     }
 }
Exemple #3
0
        private void CreateTestData(IDataStore dataStore)
        {
            ContainerTypeService.CreateTestData(dataStore);

            ContainerService.CreateTestData(dataStore);

            CarService.CreateTestData(dataStore);

            DriverService.CreateTestData(dataStore);

            PolygonService.CreateTestData(dataStore);

            CustomerService.CreateTestData(dataStore);
        }
        public static void CreateTestData(IDataStore dataStore)
        {
            if (!Settings.TestEnvironment || dataStore.GetAll <Car>().Any())
            {
                return;
            }

            var cars = new[]
            {
                new Car {
                    Number = "Р 261 ТК", Mark = "МАЗ", Serviceability = Enums.CarServiceability.Serviceable
                },
                new Car {
                    Number = "С 013 НЕ", Mark = "МАЗ", Serviceability = Enums.CarServiceability.Serviceable
                },
                new Car {
                    Number = "Х 773 КМ", Mark = "МАЗ", Serviceability = Enums.CarServiceability.Serviceable
                },
                new Car {
                    Number = "А 509 ВН", Mark = "МАЗ", Serviceability = Enums.CarServiceability.Serviceable
                },
                new Car {
                    Number = "А 258 НТ", Mark = "МАЗ", Serviceability = Enums.CarServiceability.Serviceable
                }
            };

            foreach (var car in cars)
            {
                dataStore.Save(car);
            }

            if (!dataStore.GetAll <ContainerType>().Any())
            {
                ContainerTypeService.CreateTestData(dataStore);
            }

            var dict = new Dictionary <string, decimal[]>
            {
                { "Р 261 ТК", new[] { 8m } },
                { "С 013 НЕ", new[] { 8m } },
                { "Х 773 КМ", new[] { 13m, 15m, 20m } },
                { "А 509 ВН", new[] { 13m, 15m, 20m } },
                { "А 258 НТ", new[] { 13m, 15m, 20m } },
            };

            foreach (var kvp in dict)
            {
                var car            = dataStore.GetAll <Car>().FirstOrDefault(x => x.Number == kvp.Key);
                var containerTypes = dataStore.GetAll <ContainerType>()
                                     .Where(x => kvp.Value.Contains(x.Capacity))
                                     .ToList();

                if (car == null || !containerTypes.Any())
                {
                    continue;
                }

                foreach (var containerType in containerTypes)
                {
                    var carContainerType = new CarContainerType
                    {
                        Car           = car,
                        ContainerType = containerType
                    };
                    dataStore.Save(carContainerType);
                }
            }
        }