public void ProcessHouseHoldingRun()
        {
            HouseHoldingRunData houseHoldingRunData = _houseHoldingFileRepository.GetHouseHoldingData();

            var houseHoldingRun = new HouseHoldingRun
            {
                Grid      = houseHoldingRunData.Grid,
                StartDate = houseHoldingRunData.StartDate,
                EndDate   = houseHoldingRunData.EndDate
            };

            _houseHoldingRunRepository.Create(houseHoldingRun);

            foreach (var grid in houseHoldingRunData.ProcessingGridRun)
            {
                var gridRun = _gridRunService.GetGridRun(grid);
                _gridRunService.Update(gridRun.Id, gridRun.StartDate, gridRun.EndDate, gridRun.Status, gridRun.XmlFileId, houseHoldingRun.Id);
            }

            foreach (var documentData in houseHoldingRunData.DocumentRunData)
            {
                var document = _documentService.GetDocument(documentData.DocumentId);

                var houseHold = new HouseHold()
                {
                    HouseHoldDate = DateTime.Now,
                    DocumentId    = document.Id
                };

                _houseHoldRepository.Create(houseHold);

                _documentService.Update(document.Id, houseHoldingRun.Id);
            }
        }
Example #2
0
        public void GivenAHouseHoldingRun_WhenITryToSaveToTheDatabase_ItIsSavedToTheDatabase()
        {
            int             initialCount    = _houseHoldingRunRepository.Entities.Count();
            HouseHoldingRun houseHoldingRun = BuildMeA.HouseHoldingRun(DateTime.Now, DateTime.Now, "grid");

            _houseHoldingRunRepository.Create(houseHoldingRun);

            _houseHoldingRunRepository.Entities.Count().Should().Be(initialCount + 1);
        }
Example #3
0
        public void GivenHouseHoldingRuns_WhenIAskForTheFifteenMostRecentHouseHoldingRuns_IGetTheFifteenMostRecentHouseHeldGrids()
        {
            for (int i = 1; i < 19; i++)
            {
                if (i == 5)
                {
                    Document document1 = BuildMeA.Document("id").WithDocType(_docType).WithSubDocType(_subDocType1).WithManCo(_manCo1);

                    HouseHoldingRun houseHoldingRunDifferentManCo =
                        BuildMeA.HouseHoldingRun(DateTime.Now, DateTime.Now, "grid " + i)
                        .WithDocument(document1);

                    _houseHoldingRunRepository.Create(houseHoldingRunDifferentManCo);
                }
                else
                {
                    Document document2 = BuildMeA.Document("id").WithDocType(_docType).WithSubDocType(_subDocType1).WithManCo(_manCo2);

                    HouseHoldingRun houseHoldingRun =
                        BuildMeA.HouseHoldingRun(DateTime.Now, DateTime.Now, "grid " + i)
                        .WithDocument(document2);

                    _houseHoldingRunRepository.Create(houseHoldingRun);
                }
            }

            var listManCoId = new List <int> {
                _manCo2.Id
            };

            var recentlyHouseHeld = _houseHoldingRunRepository.GetTopFifteenRecentHouseHeldGrids(listManCoId);

            recentlyHouseHeld.Should().HaveCount(15)
            .And.NotContain(g => g.Grid == "grid 1")
            .And.NotContain(g => g.Grid == "grid 2")
            .And.Contain(g => g.Grid == "grid 3")
            .And.Contain(g => g.Grid == "grid 4")
            .And.NotContain(g => g.Grid == "grid 5")
            .And.Contain(g => g.Grid == "grid 6")
            .And.Contain(g => g.Grid == "grid 7")
            .And.Contain(g => g.Grid == "grid 8")
            .And.Contain(g => g.Grid == "grid 9")
            .And.Contain(g => g.Grid == "grid 10")
            .And.Contain(g => g.Grid == "grid 11")
            .And.Contain(g => g.Grid == "grid 12")
            .And.Contain(g => g.Grid == "grid 13");
        }