public int Insert(OfficeLocation changedOfficeLocation) { var officeDto = changedOfficeLocation.ExtractDto(); var id = _officeDataTableGateway.Insert(officeDto); return(id); }
public void ShouldUpdateOfficesWithNewInfo() { var testHelper = new TestHelper(); testHelper.DatabaseDataDeleter(() => { var officeDto0 = new OfficeDto() { Name = "Austin", Address = "Dimensional Place 6300 Bee Cave Road", CountrySlug = "C1", Switchboard = "***REMOVED***", Fax = "+***REMOVED***", Operating = 1 }; var expectedOfficeId = testHelper.InsertOfficeDto(officeDto0); var userWrapper = testHelper.GetUserWrapper(); userWrapper.MakeUserPartOfGroup(userWrapper.GroupNameConstants.AdminGroup); var controller = testHelper.CreateController(); var updatedOfficeDto = SimulateUpdatingOfficeLocation(expectedOfficeId); var country1 = testHelper.GetCountryRepository().GetCountryBySlug(updatedOfficeDto.CountrySlug); var locationModel = new WebOfficeLocation(updatedOfficeDto, country1); locationModel.HasChanged = "True"; var locationOffice = new OfficeModel() { Offices = new[] { locationModel, null, new WebOfficeLocation() }, }; var actionResult = controller.Save(locationOffice); //************************ var officeLocationRepository = testHelper.GetOfficeLocationRepository(); var offices = officeLocationRepository.GetAll(); offices.Length.Should().Be(1); offices[0].OfficeId.Should().Be(expectedOfficeId); offices[0].Name.Should().Be("Changed"); offices[0].Address.Should().Be("Updated"); offices[0].Country.Name.Should().Be("Country 1"); offices[0].Country.Slug.Should().Be("C1"); offices[0].Switchboard.Should().Be("Different value here"); offices[0].Fax.Should().Be("This had changed"); offices[0].Operating.Should().Be("Closed"); //**************************** var messages = testHelper.GetEmailClient().GetSentMessage(); messages.Count.Should().Be(1); var message = messages.First(); var originalCountry = testHelper.GetCountryRepository().GetCountryBySlug(officeDto0.CountrySlug); var originalOfficeLocation = new OfficeLocation(officeDto0, originalCountry); var expectedSubject = OfficeLocationFacadeHelper.GenerateUpdateEmailSubject( originalOfficeLocation); var expectedBody = OfficeLocationFacadeHelper.GenerateUpdateEmailBody( locationModel, originalOfficeLocation); message.Body.Should().Be(expectedBody); message.Subject.Should().Be(expectedSubject); message.To.Count.Should().Be(2); var toArray = message.To.ToArray(); toArray[0].Should().Be("*****@*****.**"); toArray[1].Should().Be("*****@*****.**"); message.From.Should().Be("*****@*****.**"); }); }
public void Update(OfficeLocation changedOfficeLocation) { var officeDto = changedOfficeLocation.ExtractDto(); _officeDataTableGateway.Update(officeDto); }