Ejemplo n.º 1
0
        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));
                }
            }
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }