/// <summary>
        ///     Updates an given Testvalue from the view model
        /// </summary>
        /// <param name="viewModel">the data from the view</param>
        /// <returns>the updated test value</returns>
        public TestValue UpdateAquisitionTest(InkoAquisitionEditViewModel viewModel)
        {
            var testValue = TestBll.GetTestValue(viewModel.TestValueId);

            if (testValue.IsNull() || (testValue.ArticleTestType != ArticleType.IncontinencePad) ||
                (testValue.IncontinencePadTestValue.TestType != TestTypeIncontinencePad.AcquisitionTimeAndRewet))
            {
                Logger.Error("Old Test not found in DB");
                return(null);
            }
            testValue.LastEditedDateTime         = DateTime.Now;
            testValue.LastEditedPerson           = viewModel.TestPerson;
            testValue.DayInYearOfArticleCreation = viewModel.ProductionCodeDay;
            testValue.IncontinencePadTestValue.IncontinencePadTime   = viewModel.ProductionCodeTime;
            testValue.IncontinencePadTestValue.ExpireMonth           = viewModel.ExpireMonth;
            testValue.IncontinencePadTestValue.ExpireYear            = viewModel.ExpireYear;
            testValue.IncontinencePadTestValue.AcquisitionTimeFirst  = viewModel.AquisitionAddition1;
            testValue.IncontinencePadTestValue.AcquisitionTimeSecond = viewModel.AquisitionAddition2;
            testValue.IncontinencePadTestValue.AcquisitionTimeThird  = viewModel.AquisitionAddition3;
            testValue.IncontinencePadTestValue.AcquisitionWeight     = viewModel.InkoWeight;
            testValue.IncontinencePadTestValue.RewetAfterAcquisitionTimeDryWeight = viewModel.FPDry;
            testValue.IncontinencePadTestValue.RewetAfterAcquisitionTimeWetWeight = viewModel.FPWet;
            testValue.IncontinencePadTestValue.TestType = TestTypeIncontinencePad.AcquisitionTimeAndRewet;

            TestServiceHelper.UpdateNotes(viewModel.Notes, testValue);

            testValue.IncontinencePadTestValue = CalculateInkoAquisitionValues(testValue.IncontinencePadTestValue, viewModel.TestSheetId);

            TestBll.UpdateTestValue(testValue);
            return(testValue);
        }
Exemple #2
0
        /// <summary>
        ///     Updates an given Testvalue from the view model
        /// </summary>
        /// <param name="viewModel">the data from the view</param>
        /// <returns>the updated test value</returns>
        public TestValue UpdateRetentionTest(InkoRetentionEditViewModel viewModel)
        {
            var testValue = TestBll.GetTestValue(viewModel.TestValueId);

            if (testValue.IsNull() || (testValue.ArticleTestType != ArticleType.IncontinencePad) ||
                (testValue.IncontinencePadTestValue.TestType != TestTypeIncontinencePad.Retention))
            {
                Logger.Error("Old Test not found in DB");
                return(null);
            }
            testValue.LastEditedDateTime         = DateTime.Now;
            testValue.LastEditedPerson           = viewModel.TestPerson;
            testValue.DayInYearOfArticleCreation = viewModel.ProductionCodeDay;
            testValue.IncontinencePadTestValue.IncontinencePadTime      = viewModel.ProductionCodeTime;
            testValue.IncontinencePadTestValue.ExpireMonth              = viewModel.ExpireMonth;
            testValue.IncontinencePadTestValue.ExpireYear               = viewModel.ExpireYear;
            testValue.IncontinencePadTestValue.RetentionWeight          = viewModel.InkoWeight;
            testValue.IncontinencePadTestValue.RetentionWetValue        = viewModel.InkoWeightWet;
            testValue.IncontinencePadTestValue.RetentionAfterZentrifuge = viewModel.InkoWeightAfterZentrifuge;
            testValue.IncontinencePadTestValue.TestType = TestTypeIncontinencePad.Retention;

            TestServiceHelper.UpdateNotes(viewModel.Notes, testValue);

            testValue.IncontinencePadTestValue = CalculateInkoRetentionValues(testValue.IncontinencePadTestValue, viewModel.TestSheetId);

            TestBll.UpdateTestValue(testValue);
            return(testValue);
        }
Exemple #3
0
        /// <summary>
        ///     Gets a new BabyDiaperRetentionEditViewModel
        /// </summary>
        /// <param name="retentionTestId">The Id of the Babydiaper retention test which will be edited</param>
        /// <returns>The BabyDiaperRetentionEditViewModel</returns>
        public BabyDiaperRetentionEditViewModel GetBabyDiapersRetentionEditViewModel(Int32 retentionTestId)
        {
            var testValue = TestBll.GetTestValue(retentionTestId);

            if (testValue.IsNull())
            {
                Logger.Error("TestValue mit id " + retentionTestId + "existiert nicht in DB!");
                return(null);
            }
            var babyDiapersTestValue = testValue.BabyDiaperTestValue;

            if (babyDiapersTestValue.IsNull())
            {
                Logger.Error("BabyDiaperRetentionTestValue mit id " + testValue.TestValueId + "existiert nicht in DB!");
                return(null);
            }
            if (babyDiapersTestValue.TestType != TestTypeBabyDiaper.Retention)
            {
                Logger.Error("Requestet test was not an BabyDiaperRetention Test. Id " + testValue.TestValueId);
                return(null);
            }
            var testSheetInfo = testValue.TestSheet;

            if (testSheetInfo.IsNull())
            {
                Logger.Error("TestBlatt mit id " + testValue.TestSheetId + "existiert nicht in DB!");
                return(null);
            }
            var notes      = testValue.TestValueNote;
            var errors     = TestBll.GetAllNoteCodes();
            var errorCodes = errors.Select(error => new ErrorCode {
                ErrorId = error.ErrorId, Name = error.ErrorCode + " - " + error.Value
            })
                             .ToList();

            if (notes.IsNull())
            {
                notes = new List <TestValueNote>();
            }
            var testNotes = notes.Select(note => new TestNote {
                Id = note.TestValueNoteId, ErrorCodeId = note.ErrorId, Message = note.Message
            })
                            .ToList();

            var viewModel = new BabyDiaperRetentionEditViewModel
            {
                TestValueId        = retentionTestId,
                TestSheetId        = testValue.TestSheetId,
                TestPerson         = testValue.LastEditedPerson,
                ProductionCode     = TestServiceHelper.CreateProductionCode(testSheetInfo),
                ProductionCodeDay  = testValue.DayInYearOfArticleCreation,
                ProductionCodeTime = babyDiapersTestValue.DiaperCreatedTime,
                DiaperWeight       = babyDiapersTestValue.WeightDiaperDry,
                WeightRetentionWet = babyDiapersTestValue.RetentionWetWeight,
                Notes     = testNotes,
                NoteCodes = errorCodes
            };

            return(viewModel);
        }
Exemple #4
0
        /// <summary>
        ///     Updates an given Testvalue from the view model
        /// </summary>
        /// <param name="viewModel">the data from the view</param>
        /// <returns>the updated test value</returns>
        public TestValue UpdateRewetTest(BabyDiaperRewetEditViewModel viewModel)
        {
            var testValue = TestBll.GetTestValue(viewModel.TestValueId);

            if (testValue.IsNull() || (testValue.ArticleTestType != ArticleType.BabyDiaper) ||
                ((testValue.BabyDiaperTestValue.TestType != TestTypeBabyDiaper.Rewet) &&
                 (testValue.BabyDiaperTestValue.TestType != TestTypeBabyDiaper.RewetAndPenetrationTime)))
            {
                Logger.Error("Old Test not found in DB");
                return(null);
            }
            testValue.LastEditedDateTime                                = DateTime.Now;
            testValue.LastEditedPerson                                  = viewModel.TestPerson;
            testValue.DayInYearOfArticleCreation                        = viewModel.ProductionCodeDay;
            testValue.BabyDiaperTestValue.DiaperCreatedTime             = viewModel.ProductionCodeTime;
            testValue.BabyDiaperTestValue.WeightDiaperDry               = viewModel.DiaperWeight;
            testValue.BabyDiaperTestValue.Rewet140Value                 = viewModel.RewetAfter140;
            testValue.BabyDiaperTestValue.Rewet210Value                 = viewModel.RewetAfter210;
            testValue.BabyDiaperTestValue.StrikeTroughValue             = viewModel.StrikeThrough;
            testValue.BabyDiaperTestValue.DistributionOfTheStrikeTrough = viewModel.Distribution;
            if (viewModel.TestType == TestTypeBabyDiaper.RewetAndPenetrationTime)
            {
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionFirst  = viewModel.PenetrationTime1;
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionSecond = viewModel.PenetrationTime2;
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionThird  = viewModel.PenetrationTime3;
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionFourth = viewModel.PenetrationTime4;
            }
            else
            {
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionFirst  = 0;
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionSecond = 0;
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionThird  = 0;
                testValue.BabyDiaperTestValue.PenetrationTimeAdditionFourth = 0;
            }
            testValue.BabyDiaperTestValue.TestType = viewModel.TestType;

            TestServiceHelper.UpdateNotes(viewModel.Notes, testValue);

            testValue.BabyDiaperTestValue = CalculateBabyDiaperRewetValues(testValue.BabyDiaperTestValue,
                                                                           viewModel.TestSheetId);

            TestBll.UpdateTestValue(testValue);
            return(testValue);
        }
        /// <summary>
        ///     Updates an given Testvalue from the view model
        /// </summary>
        /// <param name="viewModel">the data from the view</param>
        /// <returns>the updated test value</returns>
        public TestValue UpdateRetentionTest(BabyDiaperRetentionEditViewModel viewModel)
        {
            var testValue = TestBll.GetTestValue(viewModel.TestValueId);

            if (testValue.IsNull() || (testValue.ArticleTestType != ArticleType.BabyDiaper) || (testValue.BabyDiaperTestValue.TestType != TestTypeBabyDiaper.Retention))
            {
                Logger.Error("Old Test not found in DB");
                return(null);
            }
            testValue.LastEditedDateTime                     = DateTime.Now;
            testValue.LastEditedPerson                       = viewModel.TestPerson;
            testValue.DayInYearOfArticleCreation             = viewModel.ProductionCodeDay;
            testValue.BabyDiaperTestValue.DiaperCreatedTime  = viewModel.ProductionCodeTime;
            testValue.BabyDiaperTestValue.WeightDiaperDry    = viewModel.DiaperWeight;
            testValue.BabyDiaperTestValue.RetentionWetWeight = viewModel.WeightRetentionWet;

            TestServiceHelper.UpdateNotes(viewModel.Notes, testValue);

            testValue.BabyDiaperTestValue = CalculateBabyDiaperRetentionValues(testValue.BabyDiaperTestValue,
                                                                               viewModel.TestSheetId);

            TestBll.UpdateTestValue(testValue);
            return(testValue);
        }
        /// <summary>
        ///     Gets a new InkoRetentionEditViewModel
        /// </summary>
        /// <param name="rewetTestId">The Id of the Inko rewet test which will be edited</param>
        /// <returns>The InkoRewetEditViewModel</returns>
        public InkoRetentionEditViewModel GetInkoRetentionEditViewModel(Int32 rewetTestId)
        {
            var testValue = TestBll.GetTestValue(rewetTestId);

            if (testValue.IsNull())
            {
                Logger.Error("TestValue mit id " + rewetTestId + "existiert nicht in DB!");
                return(null);
            }
            var incontinencePadTestValue = testValue.IncontinencePadTestValue;

            if (incontinencePadTestValue.IsNull())
            {
                Logger.Error("IncontinencePadTestValue mit id " + testValue.TestValueId + "existiert nicht in DB!");
                return(null);
            }
            if (incontinencePadTestValue.TestType != TestTypeIncontinencePad.Retention)
            {
                Logger.Error("Requestet test was not an InkoRewet Test. Id " + testValue.TestValueId);
                return(null);
            }
            var testSheet = testValue.TestSheet;

            if (testSheet.IsNull())
            {
                Logger.Error("TestBlatt mit id " + testValue.TestSheetId + "existiert nicht in DB!");
                return(null);
            }
            var notes      = testValue.TestValueNote;
            var errors     = TestBll.GetAllNoteCodes();
            var errorCodes = errors.Select(error => new ErrorCode {
                ErrorId = error.ErrorId, Name = error.ErrorCode + " - " + error.Value
            })
                             .ToList();

            if (notes.IsNull())
            {
                notes = new List <TestValueNote>();
            }
            var testNotes = notes.Select(note => new TestNote {
                Id = note.TestValueNoteId, ErrorCodeId = note.ErrorId, Message = note.Message
            })
                            .ToList();

            var viewModel = new InkoRetentionEditViewModel
            {
                TestValueId               = rewetTestId,
                TestSheetId               = testValue.TestSheetId,
                TestPerson                = testValue.LastEditedPerson,
                ProductionCode            = TestServiceHelper.CreateProductionCode(testSheet),
                ProductionCodeDay         = testValue.DayInYearOfArticleCreation,
                ProductionCodeTime        = incontinencePadTestValue.IncontinencePadTime,
                ExpireMonth               = incontinencePadTestValue.ExpireMonth,
                ExpireYear                = incontinencePadTestValue.ExpireYear,
                InkoWeight                = incontinencePadTestValue.RetentionWeight,
                InkoWeightWet             = incontinencePadTestValue.RetentionWetValue,
                InkoWeightAfterZentrifuge = incontinencePadTestValue.RetentionAfterZentrifuge,
                Notes     = testNotes,
                NoteCodes = errorCodes
            };

            return(viewModel);
        }
        /// <summary>
        ///     Gets a new BabyDiaperRewetEditViewModel or returns null if something is wrong
        /// </summary>
        /// <param name="rewetTestId">The Id of the Babydiaper rewet test which will be edited</param>
        /// <returns>The BabyDiaperRewetEditViewModel</returns>
        public BabyDiaperRewetEditViewModel GetBabyDiaperRewetEditViewModel(Int32 rewetTestId)
        {
            var testValue = TestBll.GetTestValue(rewetTestId);

            if (testValue.IsNull())
            {
                Logger.Error("TestValue mit id " + rewetTestId + "existiert nicht in DB!");
                return(null);
            }
            var babyDiapersTestValue = testValue.BabyDiaperTestValue;

            if (babyDiapersTestValue.IsNull())
            {
                Logger.Error("BabyDiaperRetentionTestValue mit id " + testValue.TestValueId + "existiert nicht in DB!");
                return(null);
            }
            if ((babyDiapersTestValue.TestType != TestTypeBabyDiaper.Rewet) && (babyDiapersTestValue.TestType != TestTypeBabyDiaper.RewetAndPenetrationTime))
            {
                Logger.Error("Requestet test was not an BabyDiaperRetention Test. Id " + testValue.TestValueId);
                return(null);
            }
            var testSheetInfo = testValue.TestSheet;

            if (testSheetInfo.IsNull())
            {
                Logger.Error("TestBlatt mit id " + testValue.TestSheetId + "existiert nicht in DB!");
                return(null);
            }
            var notes      = testValue.TestValueNote;
            var errors     = TestBll.GetAllNoteCodes();
            var errorCodes = errors.Select(error => new ErrorCode {
                ErrorId = error.ErrorId, Name = error.ErrorCode + " - " + error.Value
            })
                             .ToList();

            if (notes.IsNull())
            {
                notes = new List <TestValueNote>();
            }
            var testNotes = notes.Select(note => new TestNote {
                Id = note.TestValueNoteId, ErrorCodeId = note.ErrorId, Message = note.Message
            })
                            .ToList();

            var viewModel = new BabyDiaperRewetEditViewModel
            {
                TestValueId        = rewetTestId,
                TestSheetId        = testValue.TestSheetId,
                TestPerson         = testValue.LastEditedPerson,
                ProductionCode     = TestServiceHelper.CreateProductionCode(testSheetInfo),
                ProductionCodeDay  = testValue.DayInYearOfArticleCreation,
                ProductionCodeTime = babyDiapersTestValue.DiaperCreatedTime,
                DiaperWeight       = babyDiapersTestValue.WeightDiaperDry,
                RewetAfter140      = babyDiapersTestValue.Rewet140Value,
                RewetAfter210      = babyDiapersTestValue.Rewet210Value,
                StrikeThrough      = babyDiapersTestValue.StrikeTroughValue,
                Distribution       = babyDiapersTestValue.DistributionOfTheStrikeTrough,
                PenetrationTime1   = babyDiapersTestValue.PenetrationTimeAdditionFirst,
                PenetrationTime2   = babyDiapersTestValue.PenetrationTimeAdditionSecond,
                PenetrationTime3   = babyDiapersTestValue.PenetrationTimeAdditionThird,
                PenetrationTime4   = babyDiapersTestValue.PenetrationTimeAdditionFourth,
                TestType           = babyDiapersTestValue.TestType,
                Notes     = testNotes,
                NoteCodes = errorCodes
            };

            return(viewModel);
        }