public IActionResult Put(PatientPutBM inputs) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else { PatientLogic patLogic = new PatientLogic(_unitOfWork); try { if (patLogic.Update(inputs.Id, inputs.FirstName, inputs.LastName, inputs.DateOfBirth) > 0) { return(Ok()); } else { return(NotFound()); } } catch (Exception ex) { return(BadRequest(ex)); } } }
public void Update_PatientDoesNotExist_False() { // Arrange var logic = new PatientLogic(new PatientRepo(new MemoryPatientContext())); var patient = GenerateValidPatient(); // Act var isAccepted = logic.Update(patient); // Assert Assert.False(isAccepted); }
public void Update_ValidPatient_True() { // Arrange var logic = new PatientLogic(new PatientRepo(new MemoryPatientContext())); var existingPatient = GenerateValidPatient(); var patient = existingPatient; // Act logic.Insert(existingPatient); var isAccepted = logic.Update(patient); // Assert Assert.True(isAccepted); }
public void Update_NameWhitespace_False() { // Arrange var logic = new PatientLogic(new PatientRepo(new MemoryPatientContext())); var existingPatient = GenerateValidPatient(); var patient = new Patient { Name = " ", Age = 18, IsApproved = false }; // Act logic.Insert(existingPatient); var isAccepted = logic.Update(patient); // Assert Assert.False(isAccepted); }