diff --git a/src/ApplicationCore/Interfaces/IEmployeesRepository.cs b/src/ApplicationCore/Interfaces/IEmployeesRepository.cs index b959760..b7c9fc7 100644 --- a/src/ApplicationCore/Interfaces/IEmployeesRepository.cs +++ b/src/ApplicationCore/Interfaces/IEmployeesRepository.cs @@ -9,9 +9,6 @@ public interface IEmployeesRepository Task GetEmployeeAsync(string alias, string country); Task AddOrUpdateEmployeeInformation(Employee employee); - Task UpdateEmployeeInformation(string alias, string country, - UpdateEmployeeInformation employeeInformation); - /// /// Deletes the employee from the database, if they exist, and returns the image url to the employees image blob that needs to be cleaned up /// diff --git a/src/ApplicationCore/Services/EmployeesService.cs b/src/ApplicationCore/Services/EmployeesService.cs index 6a3d227..5331ab3 100644 --- a/src/ApplicationCore/Services/EmployeesService.cs +++ b/src/ApplicationCore/Services/EmployeesService.cs @@ -60,12 +60,6 @@ public Task AddOrUpdateEmployee(Employee employee) return _employeesRepository.EnsureEmployeesWithEndDateBeforeTodayAreDeleted(); } - public async Task UpdateEmployeeInformationByAliasAndCountry(string alias, string country, - UpdateEmployeeInformation employeeInformation) - { - return await _employeesRepository.UpdateEmployeeInformation(alias, country, employeeInformation); - } - public async Task GetEmergencyContactByEmployee(string alias, string country) { return await _emergencyContactRepository.GetByEmployee(alias, country); diff --git a/src/Infrastructure/Repositories/EmployeeRepository.cs b/src/Infrastructure/Repositories/EmployeeRepository.cs index a2ff581..9f73127 100644 --- a/src/Infrastructure/Repositories/EmployeeRepository.cs +++ b/src/Infrastructure/Repositories/EmployeeRepository.cs @@ -118,26 +118,6 @@ await _db.AddAsync(new EmployeeEntity await _db.SaveChangesAsync(); } - public async Task UpdateEmployeeInformation(string alias, string country, - UpdateEmployeeInformation employeeInformation) - { - var employee = await GetEmployeeEntity(alias, country); - - if (employee == null) - { - return false; - } - - employee.Telephone = employeeInformation.Phone; - employee.AccountNumber = employeeInformation.AccountNumber; - employee.Address = employeeInformation.Address; - employee.ZipCode = employeeInformation.ZipCode; - employee.City = employeeInformation.City; - - var changes = await _db.SaveChangesAsync(); - return changes > 0; - } - /// /// Deletes the employee from the database, if they exist, and returns the image url to the employees image blob that needs to be cleaned up /// diff --git a/src/Web/Controllers/EmployeesController.cs b/src/Web/Controllers/EmployeesController.cs index 9a041bb..9f59d64 100644 --- a/src/Web/Controllers/EmployeesController.cs +++ b/src/Web/Controllers/EmployeesController.cs @@ -98,25 +98,6 @@ public async Task> GetExtendedByAlias(string return ModelConverters.ToEmployeeExtendedJson(employee); } - [EnableCors("DashCorsPolicy")] - [HttpPost("information/{country}/{alias}")] - public async Task UpdateEmployeeInformation(string alias, string country, - [FromBody] UpdateEmployeeInformation employeeInformation) - { - var updateSuccess = - await _employeeService.UpdateEmployeeInformationByAliasAndCountry(alias, country, employeeInformation); - if (updateSuccess) - { - return NoContent(); - } - - _logger.LogError( - "Can't update EmployeeInformation because there is no matching Employee to alias {alias} and country {country}", - alias, country); - return NotFound(); - } - - [EnableCors("DashCorsPolicy")] [HttpPost("emergencyContact/{country}/{alias}")] public async Task UpdateEmergencyContact(string alias, string country, diff --git a/tests/ComponentTests/Tests/EmployeeTests.cs b/tests/ComponentTests/Tests/EmployeeTests.cs index 970acba..d46a848 100644 --- a/tests/ComponentTests/Tests/EmployeeTests.cs +++ b/tests/ComponentTests/Tests/EmployeeTests.cs @@ -125,50 +125,6 @@ public async void Given_EmployeeDoesNotExists_When_CallingEmployeeControllerGETE employeeResponse.StatusCode.Should().Be(HttpStatusCode.BadRequest); } - [Fact] - public async void Given_EmployeeExists_When_CallingEmployeeControllerPOSTInformation_Then_UpdateDatabase() - { - // Arrange - var firstSeededEmployee = Seed.GetSeedingEmployees()[0]; - var firstSeededEmployeeAlias = firstSeededEmployee!.Email.Split("@").First(); - var firstSeededEmployeeCountry = firstSeededEmployee!.Email.Split(".").Last(); - - const string json = """ - { - "Phone": "11223344", - "AccountNumber": "12341234123", - "Address": "Et annet sted", - "ZipCode": "7000", - "City": "Trondheim" - } - """; - - // Act - var response = - await _client.PostAsync($"/employees/information/{firstSeededEmployeeCountry}/{firstSeededEmployeeAlias}", - new StringContent(json, Encoding.UTF8, "application/json")); - - // Assert - response.StatusCode.Should().Be(HttpStatusCode.NoContent); - - var employeeResponse = - await _client.GetAsync( - $"/employees/{firstSeededEmployeeAlias}/extended?country={firstSeededEmployeeCountry}"); - var employee = - JsonConvert.DeserializeObject(await employeeResponse.Content - .ReadAsStringAsync()); - - employee!.Name.Should().BeEquivalentTo(firstSeededEmployee.Name); - employee!.OfficeName.Should().BeEquivalentTo(firstSeededEmployee.OfficeName); - employee!.Telephone.Should().BeEquivalentTo("11223344"); - employee.AccountNumber.Should() - .BeEquivalentTo("12341234123"); - employee!.Address.Should() - .BeEquivalentTo("Et annet sted"); - employee!.ZipCode.Should().BeEquivalentTo("7000"); - employee!.City.Should().BeEquivalentTo("Trondheim"); - } - [Fact] public async void Given_EmployeeExists_When_CallingEmployeeControllerPOSTEmergencyContact_Then_UpdateDatabase()