Exemplo n.º 1
0
    public async Task CircularDependenciesCheck(AssemblyModel assembly)
    {
        await busyService.RunActionAsync(async() =>
        {
            var assemblies = assembly.ReferenceProvider.Select(x => x.Value.LoadedAssembly)
                             .Distinct()
                             .Select(x => x.ToCheckModel())
                             .ToDictionary(x => x.Name);

            if (!assemblies.ContainsKey(assembly.Name))
            {
                assemblies.Add(assembly.Name, assembly.ToCheckModel());
            }


            var service = serviceFactory.Create <ICircularReferenceCheck>();

            var results = await service.AnalyseAsync(assembly.Name, assemblies).ConfigureAwait(true);

            var view = new CheckResultsView
            {
                DataContext = new CheckResultsViewModel <CircularReferenceError>("Circular Dependencies results", results)
            };

            await DialogHost.Show(view, mainViewIdentifier.Id).ConfigureAwait(false);
        }).ConfigureAwait(false);
    }
Exemplo n.º 2
0
        private void FrmCreateBatchObservation_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create <IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);
                SetWeekAndDay(_batch.DateOfBirth, DateTime.Now);
                dtpObservationDate.Value = DateTime.Now;
                formTitle = string.Format("Lote {0} - Crear Observación", _batch.Number.ToString());
            }

            if (_observationId != Guid.Empty)
            {
                using (var batchObservationService = _serviceFactory.Create <IBatchObservationService>())
                {
                    _batchObservation = batchObservationService.GetById(_observationId);
                    SetWeekAndDay(_batch.DateOfBirth, _batchObservation.ObservationDate);
                    txtObservation.Text      = _batchObservation.Content;
                    dtpObservationDate.Value = _batchObservation.ObservationDate;
                    formTitle = string.Format("Lote {0} - Editar Observación", _batch.Number.ToString());
                }
            }

            this.Text       = formTitle;
            txtDay.Enabled  = false;
            txtWeek.Enabled = false;
        }
Exemplo n.º 3
0
 private static void TestFactoryCreate(IServiceFactory serviceFactory)
 {
     Assert.NotNull(serviceFactory.Create <Customer>());
     Assert.NotNull(serviceFactory.Create <Customer, int>());
     Assert.NotNull(serviceFactory.Create <CustomerWithTwoCompositePrimaryKey, int, string>());
     Assert.NotNull(serviceFactory.Create <CustomerWithThreeCompositePrimaryKey, int, string, int>());
     Assert.NotNull(serviceFactory.CreateInstance <Service <Customer> >());
 }
Exemplo n.º 4
0
 private void UpdateGrid()
 {
     using (var siloEmptyingService = _serviceFactory.Create <ISiloEmptyingService>())
     {
         var items = siloEmptyingService.GetByBatch(_stateController.CurrentSelectedBatch.Id);
         gvSilos.DataSource = items;
     }
 }
Exemplo n.º 5
0
        private void FrmObservationList_Load(object sender, EventArgs e)
        {
            using (var batchService = _serviceFactory.Create <IBatchService>())
            {
                batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);
            }

            UpdateGrid();
        }
        private void LoadActiveBatches()
        {
            using (var batchService = _serviceFactory.Create <IBatchService>())
            {
                var allActiveBatches = batchService.GetAllActive();

                gvBatches.DataSource = allActiveBatches;
            }
        }
Exemplo n.º 7
0
 private void RefreshClientsDropdown()
 {
     using (var clientService = _serviceFactory.Create <IClientService>())
     {
         var clients = clientService.GetAll().OrderBy(x => x.Name).ToList();
         ddlClient.ValueMember   = "Id";
         ddlClient.DisplayMember = "Name";
         clients.Insert(0, new Client {
             Name = "(SELECCIONE CLIENTE)"
         });
         ddlClient.DataSource = clients;
     }
 }
Exemplo n.º 8
0
        private void FrmAddStock_Load(object sender, EventArgs e)
        {
            using (var depositService = _serviceFactory.Create <IDepositService>())
            {
                var deposits = depositService.GetAll().OrderBy(x => x.Name).ToList();
                ucDepositSelection.Deposits = deposits;
            }

            using (var productService = _serviceFactory.Create <IProductService>())
            {
                var products = productService.GetAll().OrderBy(x => x.Name).ToList();
                ddlProducts.ValueMember   = "Id";
                ddlProducts.DisplayMember = "Name";

                var product = new Product();
                product.Id   = Guid.Empty;
                product.Name = "Seleccione un producto..";
                products.Insert(0, product);

                ddlProducts.DataSource = products;
            }

            using (var providerService = _serviceFactory.Create <IProviderService>())
            {
                var providers = providerService.GetAll().OrderBy(x => x.Name).ToList();
                ddlProviders.ValueMember   = "Id";
                ddlProviders.DisplayMember = "Name";

                var provider = new Provider();
                provider.Id   = Guid.Empty;
                provider.Name = "Seleccione un proveedor..";
                providers.Insert(0, provider);

                ddlProviders.DataSource = providers;
            }

            using (var shiftService = _serviceFactory.Create <IShiftService>())
            {
                var shifts = shiftService.GetAll().OrderBy(x => x.Name).ToList();
                ddlShifts.ValueMember   = "Id";
                ddlShifts.DisplayMember = "Name";

                var shift = new Shift();
                shift.Id   = Guid.Empty;
                shift.Name = "Seleccione un turno..";
                shifts.Insert(0, shift);

                ddlShifts.DataSource = shifts;
            }
        }
Exemplo n.º 9
0
        private void LoadBatchProgress()
        {
            using (var batchService = _serviceFactory.Create <IBatchService>())
            {
                var batchBarnsDetails = batchService.GetBarnsDetails(_stateController.CurrentSelectedBatch.Id);

                foreach (var batchBarnDetailDto in batchBarnsDetails)
                {
                    StageProgressContainer.Controls.Add(new UcBatchBarnDetails()
                    {
                        BatchBarnDetail = batchBarnDetailDto
                    });
                }
            }
        }
Exemplo n.º 10
0
 private void FrmCreateEditClient_Load(object sender, EventArgs e)
 {
     if (_clientId != Guid.Empty)
     {
         using (var service = _serviceFactory.Create <IClientService>())
         {
             _client   = service.GetById(_clientId);
             this.Text = "Editar Cliente";
         }
     }
     else
     {
         this.Text = "Crear Cliente";
     }
 }
Exemplo n.º 11
0
        public Result <IEnumerable <Tag> > CreateTags(IEnumerable <WordInfo> words)
        {
            var layouterResult = layouterFactory.Create();

            return(layouterResult
                   .Then(layouter => GetTagsFormWords(layouter, words)));
        }
        private static void TestGetAllWithSortingOptionsAscending(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            var entities = new List <Customer>
            {
                new Customer {
                    Name = "Random Name 2"
                },
                new Customer {
                    Name = "Random Name 1"
                }
            };

            var options = new QueryOptions <Customer>().OrderBy(x => x.Name);

            Assert.Null(service.GetAll().FirstOrDefault()?.Name);
            Assert.Null(service.GetAll(options).Result.FirstOrDefault()?.Name);
            Assert.Null(service.GetAll <string>(x => x.Name).FirstOrDefault());
            Assert.Null(service.GetAll <string>(options, x => x.Name).Result.FirstOrDefault());

            service.Create(entities);

            Assert.Equal("Random Name 2", service.GetAll().First().Name);
            Assert.Equal("Random Name 1", service.GetAll(options).Result.First().Name);
            Assert.Equal("Random Name 2", service.GetAll <string>(x => x.Name).First());
            Assert.Equal("Random Name 1", service.GetAll <string>(options, x => x.Name).Result.First());

            options = new QueryOptions <Customer>().OrderBy(x => x.Name).OrderBy(x => x.Id);

            Assert.Equal("Random Name 2", service.GetAll().First().Name);
            Assert.Equal("Random Name 1", service.GetAll(options).Result.First().Name);
            Assert.Equal("Random Name 2", service.GetAll <string>(x => x.Name).First());
            Assert.Equal("Random Name 1", service.GetAll <string>(options, x => x.Name).Result.First());
        }
Exemplo n.º 13
0
        private static void TestUpdateRange(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            const string expectedName = "New Random Name";
            const string name         = "Random Name";

            var entities = new List <Customer>
            {
                new Customer {
                    Name = name
                },
                new Customer {
                    Name = name
                }
            };

            service.Create(entities);

            var entitiesInDb = service.GetAll(x => x.Name.Equals(name));

            foreach (var entityInDb in entitiesInDb)
            {
                entityInDb.Name = expectedName;
            }

            service.Update(entitiesInDb);

            Assert.Equal(2, service.GetCount(x => x.Name.Equals(expectedName)));
        }
Exemplo n.º 14
0
        private static async Task TestDeleteRangeAsync(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            const string name = "Random Name";

            var entities = new List <Customer>
            {
                new Customer {
                    Name = name
                },
                new Customer {
                    Name = name
                }
            };

            await service.CreateAsync(entities);

            Assert.Equal(2, await service.GetCountAsync());

            var entitiesInDb = await service.GetAllAsync(x => x.Name.Equals(name));

            await service.DeleteAsync(entitiesInDb);

            Assert.Equal(0, await service.GetCountAsync());
        }
Exemplo n.º 15
0
        private static async Task TestGetAllWithSortingOptionsAscendingAsync(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            var entities = new List <Customer>
            {
                new Customer {
                    Name = "Random Name 2"
                },
                new Customer {
                    Name = "Random Name 1"
                }
            };

            var options = new QueryOptions <Customer>().WithSortBy(x => x.Name);

            Assert.Null((await service.GetAllAsync()).FirstOrDefault()?.Name);
            Assert.Null((await service.GetAllAsync(options)).Result.FirstOrDefault()?.Name);
            Assert.Null((await service.GetAllAsync <string>(x => x.Name)).FirstOrDefault());
            Assert.Null((await service.GetAllAsync <string>(options, x => x.Name)).Result.FirstOrDefault());

            await service.CreateAsync(entities);

            Assert.Equal("Random Name 2", (await service.GetAllAsync()).First().Name);
            Assert.Equal("Random Name 1", (await service.GetAllAsync(options)).Result.First().Name);
            Assert.Equal("Random Name 2", (await service.GetAllAsync <string>(x => x.Name)).First());
            Assert.Equal("Random Name 1", (await service.GetAllAsync <string>(options, x => x.Name)).Result.First());

            options = new QueryOptions <Customer>().WithSortBy(x => x.Name).WithSortBy(x => x.Id);

            Assert.Equal("Random Name 2", (await service.GetAllAsync()).First().Name);
            Assert.Equal("Random Name 1", (await service.GetAllAsync(options)).Result.First().Name);
            Assert.Equal("Random Name 2", (await service.GetAllAsync <string>(x => x.Name)).First());
            Assert.Equal("Random Name 1", (await service.GetAllAsync <string>(options, x => x.Name)).Result.First());
        }
Exemplo n.º 16
0
        private static void TestDeleteRange(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            const string name = "Random Name";

            var entities = new List <Customer>
            {
                new Customer {
                    Name = name
                },
                new Customer {
                    Name = name
                }
            };

            service.Create(entities);

            Assert.Equal(2, service.GetCount());

            var entitiesInDb = service.GetAll(x => x.Name.Equals(name));

            service.Delete(entitiesInDb);

            Assert.Equal(0, service.GetCount());
        }
Exemplo n.º 17
0
        private static async Task TestGetAllAsync(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            const string name = "Random Name";

            var options = new QueryOptions <Customer>().WithSortBy(x => x.Name);
            var entity  = new Customer {
                Name = name
            };

            Assert.Empty(await service.GetAllAsync());
            Assert.Empty(await service.GetAllAsync(x => x.Name.Equals(name)));
            Assert.Empty((await service.GetAllAsync(options)).Result);
            Assert.Empty(await service.GetAllAsync <string>(x => x.Name.Equals(name), x => x.Name));
            Assert.Empty(await service.GetAllAsync <string>(x => x.Name));
            Assert.Empty((await service.GetAllAsync <string>(options, x => x.Name)).Result);

            await service.CreateAsync(entity);

            Assert.Single(await service.GetAllAsync());
            Assert.Single(await service.GetAllAsync(x => x.Name.Equals(name)));
            Assert.Single((await service.GetAllAsync(options)).Result);
            Assert.Single(await service.GetAllAsync <string>(x => x.Name.Equals(name), x => x.Name));
            Assert.Single(await service.GetAllAsync <string>(x => x.Name));
            Assert.Single((await service.GetAllAsync <string>(options, x => x.Name)).Result);
        }
Exemplo n.º 18
0
        private static async Task TestGetGroupByAsync(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            const string name = "Random Name";

            var options  = new QueryOptions <Customer>();
            var entities = new List <Customer>()
            {
                new Customer {
                    Name = name
                }
            };

            var expectedGetGroupByElementSelector = entities.GroupBy(y => y.Id, y => y.Name);

            Assert.False(expectedGetGroupByElementSelector.All(x =>
                                                               service.GetGroupByAsync(y => y.Id, z => z.Key).Result.Contains(x.Key)));
            Assert.False(expectedGetGroupByElementSelector.All(x =>
                                                               service.GetGroupByAsync(options, y => y.Id, z => z.Key).Result.Result.Contains(x.Key)));

            await service.CreateAsync(entities);

            Assert.True(expectedGetGroupByElementSelector.All(x =>
                                                              service.GetGroupByAsync(y => y.Id, z => z.Key).Result.Contains(x.Key)));
            Assert.True(expectedGetGroupByElementSelector.All(x =>
                                                              service.GetGroupByAsync(options, y => y.Id, z => z.Key).Result.Result.Contains(x.Key)));
        }
Exemplo n.º 19
0
        private static async Task TestGetWithIdAsync(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            int key = 1;

            var fetchStrategy = new FetchQueryStrategy <Customer>()
                                .Fetch(x => x.Address);

            var entity = new Customer {
                Id = key, Name = "Random Name"
            };

            Assert.Null(await service.GetAsync(key));
            Assert.Null(await service.GetAsync(key, fetchStrategy));
            Assert.Null(await service.GetAsync(key, x => x.Address));
            Assert.Null(await service.GetAsync(key, "Address"));

            await service.CreateAsync(entity);

            Assert.NotNull(await service.GetAsync(key));
            Assert.NotNull(await service.GetAsync(key, fetchStrategy));
            Assert.NotNull(await service.GetAsync(key, x => x.Address));
            Assert.NotNull(await service.GetAsync(key, "Address"));
        }
Exemplo n.º 20
0
        private static async Task TestGetWithSortingOptionsAscendingAsync(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            var entities = new List <Customer>
            {
                new Customer {
                    Name = "Random Name 2"
                },
                new Customer {
                    Name = "Random Name 1"
                }
            };

            var options = new QueryOptions <Customer>().WithSortBy(x => x.Name).WithFilter(x => x.Name.Contains("Random Name"));

            Assert.Null((await service.GetAsync(x => x.Name.Contains("Random Name")))?.Name);
            Assert.Null((await service.GetAsync(options))?.Name);
            Assert.Null(await service.GetAsync <string>(x => x.Name.Contains("Random Name"), x => x.Name));
            Assert.Null(await service.GetAsync <string>(options, x => x.Name));

            await service.CreateAsync(entities);

            Assert.Equal("Random Name 2", (await service.GetAsync(x => x.Name.Contains("Random Name"))).Name);
            Assert.Equal("Random Name 1", (await service.GetAsync(options)).Name);
            Assert.Equal("Random Name 2",
                         await service.GetAsync <string>(x => x.Name.Contains("Random Name"), x => x.Name));
            Assert.Equal("Random Name 1", await service.GetAsync <string>(options, x => x.Name));
        }
Exemplo n.º 21
0
        private static void TestGetAll(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            const string name = "Random Name";

            var options = new QueryOptions <Customer>().WithSortBy(x => x.Name);
            var entity  = new Customer {
                Name = name
            };

            Assert.Empty(service.GetAll());
            Assert.Empty(service.GetAll(x => x.Name.Equals(name)));
            Assert.Empty(service.GetAll(options).Result);
            Assert.Empty(service.GetAll <string>(x => x.Name.Equals(name), x => x.Name));
            Assert.Empty(service.GetAll <string>(x => x.Name));
            Assert.Empty(service.GetAll <string>(options, x => x.Name).Result);

            service.Create(entity);

            Assert.Single(service.GetAll());
            Assert.Single(service.GetAll(x => x.Name.Equals(name)));
            Assert.Single(service.GetAll(options).Result);
            Assert.Single(service.GetAll <string>(x => x.Name.Equals(name), x => x.Name));
            Assert.Single(service.GetAll <string>(x => x.Name));
            Assert.Single(service.GetAll <string>(options, x => x.Name).Result);
        }
Exemplo n.º 22
0
        private static void TestGetWithSortingOptionsAscending(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            var entities = new List <Customer>
            {
                new Customer {
                    Name = "Random Name 2"
                },
                new Customer {
                    Name = "Random Name 1"
                }
            };

            var options = new QueryOptions <Customer>().WithSortBy(x => x.Name).WithFilter(x => x.Name.Contains("Random Name"));

            Assert.Null(service.Get(x => x.Name.Contains("Random Name"))?.Name);
            Assert.Null(service.Get(options)?.Name);
            Assert.Null(service.Get <string>(x => x.Name.Contains("Random Name"), x => x.Name));
            Assert.Null(service.Get <string>(options, x => x.Name));

            service.Create(entities);

            Assert.Equal("Random Name 2", service.Get(x => x.Name.Contains("Random Name")).Name);
            Assert.Equal("Random Name 1", service.Get(options).Name);
            Assert.Equal("Random Name 2", service.Get <string>(x => x.Name.Contains("Random Name"), x => x.Name));
            Assert.Equal("Random Name 1", service.Get <string>(options, x => x.Name));
        }
Exemplo n.º 23
0
        public void CreateCloud(string textPath, string imageSavePath)
        {
            var words = textProcessor.ReadFromFile(textPath);
            var tags  = tagsGeneratorFactory.Create().CreateTags(words);

            using var image = imageBuilder.BuildImage(tags);
            imageSaverFactory.Create().SaveImage(image, imageSavePath);
        }
Exemplo n.º 24
0
        public void Run()
        {
            var service = serviceFactory.Create();

            service.Print("* Factory example *");
            service.Print(@"Hello, world.");
            serviceFactory.Release(service);
        }
        private void FrmCreateEditBatchMedicine_Load(object sender, EventArgs e)
        {
            var formTitle = "";

            using (var batchService = _serviceFactory.Create <IBatchService>())
            {
                _batch = batchService.GetById(_stateController.CurrentSelectedBatch.Id);

                dtpStartDate.Value  = _batch.DateOfBirth;
                dtpEndDate.Value    = _batch.DateOfBirth.AddDays(_batch.GeneticLine.ProductionWeeks * 7);
                txtObservation.Text = "";
                formTitle           = string.Format("Lote {0} - Crear Medicamento", _batch.Number.ToString());
            }

            using (var medicineService = _serviceFactory.Create <IMedicineService>())
            {
                var vaccines = medicineService.GetAllActive().OrderBy(x => x.Name).ToList();
                ddlMedicines.ValueMember   = "Id";
                ddlMedicines.DisplayMember = "Name";
                Medicine item = new Medicine();
                item.Name = "Selecciona un medicamento..";
                item.Id   = Guid.Empty;
                vaccines.Insert(0, item);
                ddlMedicines.DataSource = vaccines;
            }

            if (_batchMedicineId != Guid.Empty)
            {
                //Editar
                using (var batchMedicineService = _serviceFactory.Create <IBatchMedicineService>())
                {
                    _batchMedicine      = batchMedicineService.GetById(_batchMedicineId);
                    txtObservation.Text = _batchMedicine.Observation;
                    dtpStartDate.Value  = _batchMedicine.StartDate;
                    if (_batchMedicine.EndDate != null)
                    {
                        dtpEndDate.Value = _batchMedicine.EndDate.Value;
                    }
                    ddlMedicines.SelectedValue = _batchMedicine.MedicineId;
                    formTitle = string.Format("Lote {0} - Editar Medicamento", _batch.Number.ToString());
                }
            }

            this.Text = formTitle;
        }
Exemplo n.º 26
0
        public void Configuration()
        {
            var serviceTypes = (TType[])Enum.GetValues(typeof(TType));

            foreach (var serviceType in serviceTypes)
            {
                _services.Add(serviceType, _factory.Create(serviceType));
            }
        }
Exemplo n.º 27
0
        private void LoadBatchStandards()
        {
            using (var standardService = _serviceFactory.Create <IStandardService>())
            {
                var standards = standardService.GetByBatchId(_stateController.CurrentSelectedBatch.Id).Where(s => !s.IsDeleted).ToList();

                ucStandardSelecction.Standards = standards;
            }
        }
Exemplo n.º 28
0
        private void FrmEnterDailyMeasures_Load(object sender, EventArgs e)
        {
            lbCurrentStandard.Text = Resources.Standard + ": " + _stateController.CurrentSelectedStandard.Name;

            var geneticLineId    = _stateController.CurrentSelectedBatch.GeneticLineId;
            var stageId          = _stateController.CurrentSelectedBatch.StageId;
            var standardId       = _stateController.CurrentSelectedStandard.Id;
            var batchId          = _stateController.CurrentSelectedBatch.Id;
            var batchDateOfBirth = _stateController.CurrentSelectedBatch.DateOfBirth;

            using (var standardItemService = _serviceFactory.Create <IStandardItemService>())
            {
                using (var measureService = _serviceFactory.Create <IMeasureService>())
                {
                    var items    = standardItemService.GetByStandardAndGeneticLine(standardId, stageId.GetValueOrDefault(), geneticLineId);
                    var measures = measureService.GetByStandardAndBatch(standardId, batchId);

                    var model = new List <LoadWeeklyStandardMeasures>();

                    foreach (var item in items)
                    {
                        var measureDateFrom = batchDateOfBirth.AddWeeks(item.Sequence - 1);
                        var measureDateTo   = batchDateOfBirth.AddWeeks(item.Sequence).AddDays(-1);
                        var measure         = measures.FirstOrDefault(x => x.StandardItemId == item.Id);

                        var weekMeasureModel = new LoadWeeklyStandardMeasures()
                        {
                            StandardItemId = item.Id,
                            MeasureId      = measure == null ? Guid.Empty : measure.Id,
                            DateFrom       = measureDateFrom,
                            DateTo         = measureDateTo,
                            Week           = item.Sequence,
                            Value          = measure == null ? (decimal?)null : measure.Value
                        };


                        model.Add(weekMeasureModel);
                    }

                    ucLoadWeeklyMeasures.LoadWeeklyStandardMeasures = model;
                    ucLoadWeeklyMeasures.CurrentWeek = _stateController.CurrentSelectedBatch.Week;
                }
            }
        }
Exemplo n.º 29
0
        private static void TestGetGroupByThrowsExceptionWithSortingOptions(IServiceFactory serviceFactory)
        {
            var service = serviceFactory.Create <Customer>();

            var options = new QueryOptions <Customer>().WithSortBy(x => x.Id);

            var ex = Assert.Throws <InvalidOperationException>(() => service.GetGroupBy(options, y => y.Name, z => z.Key));

            Assert.Equal("This context provider does not support groupby operation with sorting.", ex.Message);
        }
Exemplo n.º 30
0
        private void FrmAssignBarn_Load(object sender, EventArgs e)
        {
            using (var service = _serviceFactory.Create <IBatchService>())
            {
                var batch = service.GetById(_batchId);
                //dtpArrivedToBarn.Value = batch.CalculatedPostureStartDate; //TODO: ARREGLAR

                dtpArrivedToBarn.MinDate = batch.DateOfBirth.AddDays(1);
                dtpArrivedToBarn.MaxDate = batch.DateOfBirth.AddDays((batch.GeneticLine.ProductionWeeks * 7) - 1);
            }

            using (var barnService = _serviceFactory.Create <IBarnService>())
            {
                var barns = barnService.GetAllAvailable().OrderBy(x => x.Name).ToList();
                ddlBarns.ValueMember   = "Id";
                ddlBarns.DisplayMember = "Name";
                ddlBarns.DataSource    = barns;
            }
        }