Ejemplo n.º 1
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);
        }
 public ActionResult AddNote(InkoRetentionEditViewModel viewModel)
 {
     if (viewModel.Notes.IsNull())
     {
         viewModel.Notes = new List <TestNote>();
     }
     viewModel.Notes.Add(new TestNote());
     return(View("Edit", viewModel));
 }
Ejemplo n.º 3
0
        /// <summary>
        ///     Saves or updates the InkoRetentionEditViewModel
        /// </summary>
        /// <param name="viewModel">The viewmodel which will be saved or updated</param>
        /// <returns>The saved or updated TestValue</returns>
        public TestValue Save(InkoRetentionEditViewModel viewModel)
        {
            TestValue testValue;

            try
            {
                testValue = viewModel.TestValueId <= 0
                    ? InkoRetentionServiceHelper.SaveNewRetentionTest(viewModel)
                    : InkoRetentionServiceHelper.UpdateRetentionTest(viewModel);
                InkoRetentionServiceHelper.UpdateRetentionAverageAndStv(viewModel.TestSheetId);
            }
            catch (Exception e)
            {
                Logger.Error("Update oder Create new Test Value ist fehlgeschlagen: " + e.Message);
                testValue = null;
            }
            return(testValue);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Gets the InkoRetentionEditViewModel for edit
        /// </summary>
        /// <param name="testSheetId">The Id of the test sheet where the Inko rewet test is for</param>
        /// <returns>The InkoRewetEditViewModel</returns>
        public InkoRetentionEditViewModel GetNewInkoRetentionEditViewModel(Int32 testSheetId)
        {
            var testSheet = TestBll.GetTestSheetInfo(testSheetId);

            if (testSheet.IsNull() || (testSheet.ArticleType != ArticleType.IncontinencePad))
            {
                Logger.Error("TestBlatt mit id " + testSheetId + "existiert nicht in DB!");
                return(null);
            }

            var errors     = TestBll.GetAllNoteCodes();
            var errorCodes = errors.Select(error => new ErrorCode {
                ErrorId = error.ErrorId, Name = error.ErrorCode + " - " + error.Value
            })
                             .ToList();

            var viewModel = new InkoRetentionEditViewModel
            {
                TestSheetId    = testSheetId,
                TestValueId    = -1,
                ProductionCode = TestServiceHelper.CreateProductionCode(testSheet),
                NoteCodes      = errorCodes,
                Notes          = new List <TestNote>()
            };

            var oldTestValue = testSheet.TestValues.Where(t => t.TestValueType == TestValueType.Single)
                               .ToList()
                               .LastOrDefault();

            if (oldTestValue == null)
            {
                return(viewModel);
            }
            viewModel.TestPerson         = oldTestValue.LastEditedPerson;
            viewModel.ProductionCodeDay  = oldTestValue.DayInYearOfArticleCreation;
            viewModel.ProductionCodeTime = oldTestValue.IncontinencePadTestValue.IncontinencePadTime;
            viewModel.ExpireMonth        = oldTestValue.IncontinencePadTestValue.ExpireMonth;
            viewModel.ExpireYear         = oldTestValue.IncontinencePadTestValue.ExpireYear;

            return(viewModel);
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     Creates an new TestValue from the view model
        /// </summary>
        /// <param name="viewModel">the data from the view</param>
        /// <returns>The created test value</returns>
        public TestValue SaveNewRetentionTest(InkoRetentionEditViewModel viewModel)
        {
            var testValue = TestServiceHelper.CreateNewTestValue(viewModel.TestSheetId, viewModel.TestPerson, viewModel.ProductionCodeDay, viewModel.Notes);

            testValue.ArticleTestType = ArticleType.IncontinencePad;

            var incontinencePadTestValue = new IncontinencePadTestValue
            {
                IncontinencePadTime      = viewModel.ProductionCodeTime,
                ExpireMonth              = viewModel.ExpireMonth,
                ExpireYear               = viewModel.ExpireYear,
                RetentionWeight          = viewModel.InkoWeight,
                RetentionWetValue        = viewModel.InkoWeightWet,
                RetentionAfterZentrifuge = viewModel.InkoWeightAfterZentrifuge,
                TestType = TestTypeIncontinencePad.Retention
            };

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

            TestBll.SaveNewTestValue(testValue);
            return(testValue);
        }
Ejemplo n.º 6
0
        /// <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);
        }
        public ActionResult Save(InkoRetentionEditViewModel viewModel)
        {
            var savedModel = InkoRetentionService.Save(viewModel);

            return(RedirectToAction("Edit", "LaborCreatorInko", new { area = "Labor", id = savedModel.TestSheetId }));
        }