/// <summary> /// /// </summary> /// <param name="updateAttribute"></param> /// <param name="user"></param> /// <returns></returns> public TestTemplateAttributeDto UpdateAttribute(TestResultDto updateAttribute, UserDto user) { MapperConfig.ConfigAutoMapper(); if ((updateAttribute != null) && (user != null)) { PatientTestResultHelper Resulthelp = new PatientTestResultHelper(); // Attribute set according to the visit ID IList <TestResultDto> ResultAttributes = Resulthelp.GetTestResults(updateAttribute.VisitID); //updateAttribute.AttrID = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).AttrID; updateAttribute.ModifiedDate = DateTime.Now; updateAttribute.VisitID = Resulthelp.GetResultByID(updateAttribute.ID).VisitID; updateAttribute.AttrID = Resulthelp.GetResultByID(updateAttribute.ID).AttrID; updateAttribute.CreatedBy = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).CreatedBy; updateAttribute.CreatedDate = Resulthelp.GetResultByVisitID(updateAttribute.VisitID).CreatedDate; updateAttribute.ModifiedBy = user.Username; ResultRepo.Update(Mapper.Map <TestResult>(updateAttribute)); } else { System.Diagnostics.Debug.WriteLine("Null Attribute ! / Null User "); } return(null); }
/// <summary> /// /// </summary> /// <param name="attribute"></param> /// <returns></returns> /// public TestResultDto DeleteAttribute(TestResultDto attribute) { PatientTestResultHelper visitHelper = new PatientTestResultHelper(); MapperConfig.ConfigAutoMapper(); if (attribute != null) { attribute.ModifiedDate = DateTime.Now; attribute.CreatedDate = new DateTime(2017, 7, 6); attribute.CreatedBy = "EMP01"; attribute.ModifiedBy = null; IList <TestResultDto> TestRes = visitHelper.GetTestResults(attribute.VisitID); TestResult Del = context.TestResults.SingleOrDefault(item => item.ID == attribute.ID); context.TestResults.Remove(Mapper.Map <TestResult>(Del)); context.SaveChanges(); return(null); } else { throw new NullReferenceException("null attrib"); } }