public IActionResult UpdateLab( [Bind("" + "ID," + "Date," + "LabResult," + "ResultCode," + "")] ResultDataModel data) { if (!ModelState.IsValid) { return(NotFound()); } //Use the Result Code to lookup a Record var dataID = ResultDataHelper.ConvertResultCodeToID(data.ResultCode); if (string.IsNullOrEmpty(dataID)) { return(NotFound()); } //Look up the ID var dataExist = Backend.Read(dataID); if (dataExist == null) { return(NotFound()); } /* * Do not want to update everything, just the Lab Result. * So rather than pass the new data to Update * Will manualy update just the Lab Result field on dataExist to be the data Lab Result passed in * Then will update the dataExist * */ // Update just the LabResult value dataExist.LabResult = data.LabResult; var dataResult = Backend.Update(dataExist); if (dataResult == null) { return(NotFound()); } return(RedirectToAction(nameof(Index))); }
public void ResultDataHelper_ConvertResultCodeToID_InValid_Bogus_Should_Fail() { // Arrange var data = new ResultDataModel { ResultCode = "ResultCode" }; DataSourceBackend.Instance.ResultDataBackend.Create(data); // Act var result = ResultDataHelper.ConvertResultCodeToID("Bogus"); // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(string.Empty, result); }
public void ResultDataHelper_ConvertResultCodeToID_Valid_Should_Pass() { // Arrange var data = new ResultDataModel { ResultCode = "ResultCode" }; DataSourceBackend.Instance.ResultDataBackend.Create(data); // Act var result = ResultDataHelper.ConvertResultCodeToID(data.ResultCode); // Reset DataSourceBackend.Instance.Reset(); // Assert Assert.AreEqual(data.ID, result); }
public IActionResult UpdateLab(string id) { //Use the Result Code to lookup a Record var dataID = ResultDataHelper.ConvertResultCodeToID(id); if (string.IsNullOrEmpty(dataID)) { return(NotFound()); } //Look up the ID var data = Backend.Read(dataID); if (data == null) { return(NotFound()); } return(View(data)); }